User:Hotaru Natsumi/js/substub track helper.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/* ============================================================ *
* [[User:Hotaru_Natsumi/小小作品状态追踪]] Helper
* @author: Hotaru Natsumi
* @version: 1.0
*
* 该脚本协助[[User:Hotaru_Natsumi/小小作品状态追踪]]页面的使用
* 需要手动加载,不加载该脚本不会影响页面的功能,仍可逐个手动移除项目
*
* 该脚本仅在[[User:Hotaru_Natsumi/小小作品状态追踪]]页面生效
* ============================================================ */
/* _addText : "For [[User:Hotaru_Natsumi/小小作品状态追踪]]" */
(function($, mw){
if(mw.config.values.wgPageName !== 'User:Hotaru_Natsumi/小小作品状态追踪') return;
var selectorItems = document.getElementsByClassName('hnsel-substub-item')
for (var i = 0; i < selectorItems.length; i++) {
var _name = selectorItems[i].id
_name = _name.replace('_', ' ')
selectorItems[i].innerHTML = '<input type="checkbox" id="' + _name + '" name="' + _name + '" class="hnsel-substub-item-select">'
}
document.getElementById('hnsel-substub-action-th').innerHTML = '<a href="javascript:;">移除所选</a>'
document.getElementById('hnsel-substub-action-th').addEventListener('click', function(){
var payload = ""
var checkboxItems = document.getElementsByClassName('hnsel-substub-item-select')
for (var i = 0; i < checkboxItems.length; i++) {
if(checkboxItems[i].checked) payload += checkboxItems[i].name + '|'
}
if (payload == "") {
$('.mw-parser-output').after('<div id="hnsel-substub-result" style="border:solid #eaeaea; padding:5px; margin:3px; background:#efefef; border-radius: 3px">未选择选项</div>')
var result = document.getElementById('hnsel-substub-result')
result.scrollIntoView()
}
if (payload.slice(-1) == '|') payload = payload.slice(0, -1)
$.ajax({
url: 'https://hnatsumi-bot.toolforge.org/pop?titles=' + payload,
type: 'GET',
success: function(response){
$('.mw-parser-output').after('<div id="hnsel-substub-result" style="border:solid #eaeaea; padding:5px; margin:3px; background:#efefef; border-radius: 3px">API返回:\r\n' + response + '</div>')
var result = document.getElementById('hnsel-substub-result')
result.scrollIntoView()
}
})
})
})(jQuery, mediaWiki)