User:Qinyongr/common.js
外观
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
//UserHighlight
importScript("User:Qinyongr/AGFhighlight.js");
importScript("User:Qinyongr/bhighlight.js");
importScript("User:Qinyongr/adminhighlight.js");
//OnlineAdmin
importScript("User:Qinyongr/onlineadmin.js");
//Wikiplus
mw.loader.load('https://wikiplus-app.smartgslb.com/Main.js');
localStorage.setItem('Wikiplus_Settings', JSON.stringify({
"defaultSummary":"function(w){return (w.sectionNumber > 0 && '/*' + w.sectionName + '*/ ' || (w.sectionNumber == 0 && '/* top */ ' || '') ) + ' | 此編輯使用[[Special:参数设置#mw-prefsection-gadgets|Wikiplus]]。' }"
}));
//Tabs
importScript("MediaWiki:Gadget-Tabs.js");
//BPanel
importScript("MediaWiki:Gadget-BPanel.js");
//Wordcount
importScript("MediaWiki:Gadget-Wordcount.js");
//popups
importScript("MediaWiki:Gadget-popups.js");
importStylesheet('MediaWiki:Gadget-popups.css');
//Google
importScript("MediaWiki:Gadget-GoogleImages.js");
//TinEye
importScript("MediaWiki:Gadget-Tineye.js");
//Others
//importScript("User:Qinyongr/toc.js");
//Test1
mw.loader.using('ext.gadget.site-lib', function(){
function deletemods(){
if (mw.config.get('wgAction') == "delete") {
var wpReason = document.getElementById("wpReason");
if (!wpReason) return;
var regexp = /(内容为|page was empty|content before blanking was)/i;
if (regexp.test(wpReason.value)){
wpReason.value = "";
}
}
}
});
$(deletemods);
//sectionlink
;(function($){
$('.mw-headline').each(function(i){
name = $(this).attr('id');
$(this).before('<input class="sectionlink" type="text" readonly="readonly" style="background-color:transparent; border: 1px solid #808080; float: right; font-size: 70%;" size="5" onfocus="this.select()" value="' + wgPageName + '#' + decodeURIComponent(name.replace(/\.([A-F0-9][A-F0-9])/g, '%$1')).replace('<', '<').replace('>', '>').replace('"', '"').replace("'", "'") + '" />');
});
})(jQuery);
/* Any JavaScript here will be loaded for sysops only */
mw.loader.using('ext.gadget.site-lib', function(){
//保護選項校正
if (mw.config.get('wgAction') == "protect") {
$(function () {
var pform = document.getElementById("mw-Protect-Form");
var timeoptions;
timeoptions = pform["wpProtectExpirySelection-edit"].options;
if (timeoptions[0].value != "existing") {
timeoptions[timeoptions.length - 1].selected = true;
ProtectionForm.updateExpiryList(pform["wpProtectExpirySelection-edit"]);
}
timeoptions = pform["wpProtectExpirySelection-move"].options;
if (timeoptions[0].value != "existing") {
timeoptions[timeoptions.length - 1].selected = true;
ProtectionForm.updateExpiryList(pform["wpProtectExpirySelection-move"]);
}
});
}
//擷取選單文字按鈕
$(function () {
var addGetMenuTextButton = function (id, $srcMenu, $targetText, tiptext, afterSelIdx) {
if($srcMenu.length==0 || $targetText.length==0) return null;
var $btnAdd = $('<input type="button">', {
'id': id,
'name': id
}).attr("value", ((!tiptext) ? "(+)" : tiptext) );
$btnAdd.get(0).srcMenu = $srcMenu.get(0);
$btnAdd.get(0).targetText = $targetText.get(0);
$btnAdd.get(0).afterSelIdx = (!afterSelIdx || isNaN(afterSelIdx)) ? 0 : afterSelIdx;
$btnAdd.click( function () {
this.targetText.value += this.srcMenu.options[this.srcMenu.selectedIndex].value;
this.srcMenu.selectedIndex = this.afterSelIdx;
}).insertAfter($srcMenu);
return $btnAdd;
}
if (mw.config.get('wgAction').match(/(?:un)?protect/i)) { //保護理由
addGetMenuTextButton("wpProtectReasonSelectionAdd", $("form[id='mw-Protect-Form'] select#wpProtectReasonSelection"), $("form[id='mw-Protect-Form'] input[id='mwProtect-reason']"), "加到附加的理由", 0);
} else if (("" + mw.config.get('wgCanonicalSpecialPageName')).match(/block(?:ip)?/i) ) { //封禁理由
addGetMenuTextButton("wpBlockReasonListAdd", $("form select[name='wpReason']"), $("form input[name='wpReason-other']"), wgULS("加到附带原因", "加到附帶原因"), $("form select[name='wpReason'] option[value='other']")[0].index);
}
});
});