User:莴苣笋/monobook.js
外观
< User:莴苣笋
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/*这是从阿福那里的monobook.js盗来的。有些没看懂,可能是用于管理员权限下的操作,先不管那么多。*/
/*稍微改了几个字,用用试试看再说。*/
/* <nowiki> */
function closevfd(bold, notbold){
var txt = document.editform.wpTextbox1;
txt.value = "{{subst:vt}} '''" + bold + "'''" + notbold + ". – ~~~~\n" + txt.value + "\n{{subst:vb}}\n";
txt = document.editform.wpSummary;
txt.value = "close discussion: " + bold + notbold;
document.editform.wpWatchthis.checked = false;
}
function replace(){
var s = prompt("Search regexp?");
if(s){
var r = prompt("Replace regexp?");
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp(s, "g"), r);
}
}
function vfdresult(){
var res = prompt("Result?");
if(!res) return;
document.editform.wpSummary.value = 'VFD result - ' + res;
var txt = document.editform.wpTextbox1;
if(txt.value.length > 0) txt.value += '\n';
txt.value += '==VFD==\nOn [[DAY MONTH]] [[2005]], this article was nominated for deletion. The result was ' + res + '. See [[Wikipedia:Votes for deletion/{{subst:PAGENAME}}]] for a record of the discussion. – ~~~~';
txt.focus();
}
function hidevfd(){
var divs = document.getElementsByTagName("div");
for(var x = 0; x < divs.length; ++x)
if(divs[x].className.indexOf("vfd") != -1)
divs[x].style.display = "none";
document.getElementById('footer').style.display = 'none';
}
function showvfd(){
var divs = document.getElementsByTagName("div");
for(var x = 0; x < divs.length; ++x)
if(divs[x].className.indexOf("vfd") != -1)
divs[x].style.display = "";
document.getElementById('footer').style.display = '';
}
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.id = id;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.appendChild(na);
tabs.appendChild(li);
return li;
}
function vfdlinks(){
if(!document.getElementById) return;
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, 'javascript:hidevfd()', 'hide closed', 'ca-hide');
addlilink(tabs, 'javascript:showvfd()', 'show closed', 'ca-show');
}
function addPurge(){
ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
if(!document.getElementById) return;
var x = document.getElementById('ca-history');
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(!x) return;
if(x.children) x = x.children[0];
else x = x.childNodes[0];
addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
}
function addEditSection0(){
ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
if(!document.getElementById) return;
var x = document.getElementById('ca-edit');
if(!x) return;
var y = document.createElement('LI');
y.id = 'ca-edit-0';
if(x.className == 'selected'){
if(new RegExp("&action=edit§ion=0$").test(window.location.href)){
x.className = 'istalk';
y.className = 'selected';
} else {
x.className = 'selected istalk';
}
} else if(x.className == 'selected istalk'){
if(new RegExp("&action=edit§ion=0$").test(window.location.href)){
x.className = 'istalk';
y.className = 'selected istalk';
} else {
y.className = 'istalk';
}
} else {
y.className = x.className;
x.className = 'istalk';
}
var z = document.createElement('A');
if(x.children){
z.href = x.children[0].href + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
}else{
z.href = x.childNodes[0].href + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
}
}
function changeLinks(){
if(!document.getElementById) return;
document.getElementById('pt-mytalk').firstChild.innerHTML = '看看有誰找我!';
document.getElementById('pt-watchlist').firstChild.innerHTML = '跟蹤追擊!';
document.getElementById('pt-mycontris').firstChild.innerHTML = '我貢獻了些啥?';
}
function addForceSummary(){
if(!new RegExp("&action=edit").test(window.location.href)) return;
if(new RegExp("§ion=new").test(window.location.href)) return;
if(!document.forms.editform) return;
document.forms.editform.wpSave.onclick = forceSummary;
}
function forceSummary(){
if(!document.forms.editform.wpSummary.value.replace(new RegExp("^(?:/\\*.*\\*/)? *(.*) *$"),'$1')){
var r = prompt('你對這個條目做了什麽手腳?\n寫下來,説不定對人有幫助!',document.forms.editform.wpSummary.value);
if(r == null) return false;
document.forms.editform.wpSummary.value = r;
}
return true;
}
function morelinks(){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(document.title.indexOf("Editing Wikipedia:Votes for deletion") == 0){
addlilink(tabs, 'javascript:closevfd("keep", "")', 'keep', '');
addlilink(tabs, 'javascript:closevfd("merge and redirect", " to [[" + prompt("Merge and redirect to?") + "]]")', 'merge', '');
addlilink(tabs, 'javascript:closevfd("redirect", " to [[" + prompt("Redirect to?") + "]]")', 'redir', '');
addlilink(tabs, 'javascript:closevfd("transwiki", " to " + prompt("Transwiki to?"))', 'trans', '');
addlilink(tabs, 'javascript:closevfd("transwiki", " to Wiktionary")', 'wikt', '');
addlilink(tabs, 'javascript:closevfd("speedy delete", "")', 'speedy', '');
addlilink(tabs, 'javascript:closevfd("delete", "")', 'del', '');
addlilink(tabs, 'javascript:closevfd(prompt("Result?"), "")', 'other', '');
addlilink(tabs, 'javascript:replace()', 'replace', '');
}else if(document.title.indexOf("Editing ") == 0){
addlilink(tabs, 'javascript:replace()', 'replace', '');
addlilink(tabs, 'javascript:vfdresult()', 'vfd result', '');
}
}
function addToolBoxLinks(){
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
addlilink(tb, '/wiki/Special:DoubleRedirects', 'DoubleRedirects', '');
addlilink(tb, '/wiki/Special:Shortpages', 'ShortPages', '');
addlilink(tb, '/wiki/Special:Uncategorizedpages', 'Uncategorize','');
addlilink(tb, '/wiki/Special:Unusedcategories', 'UnUsedCategories','');
}
function myLoadFuncs(){
addPurge();
addEditSection0();
changeLinks();
addForceSummary();
if(document.title.indexOf("Wikipedia:Votes for deletion") != -1 && document.title.indexOf("Editing ") != 0) vfdlinks();
morelinks();
addToolBoxLinks();
}
if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false);
else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs);
else{
window._old_ABCD_onload = window.onload;
window.onload = function(){
window._old_ABCD_onload();
myLoadFuncs();
}
}
/* </nowiki> */