User:Howcheng/monobook.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
// <pre> // [[Wikipedia:WikiProject User scripts/Scripts/addLink]] function addLink(where, url, name, id, title, key, after) { // addLink() accepts either an id or a DOM node, addPortletLink() only takes a node if (after && !after.cloneNode) after = document.getElementById(after); return addPortletLink(where, url, name, id, title, key, after); } function addTab(url, name, id, title, key){ return addLink('p-cactions', url, name, id, title, key); } // From [[en:Wikipedia:WikiProject User scripts/Scripts/Get Page Name]] function getPname() { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") { var pname = z[n].textContent ? z[n].textContent : z[n].innerText; return pname; } } } // [[User:Lupin/popups.js]] importScript('User:Lupin/popups.js'); popupAdminLinks=true; popupFixDabs=true; /**** afd helper ****/ document.write('<script type="text/javascript"' + 'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' + 'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */ // Live Preview customization, // edit this to your own liking. wpUserName = 'Howcheng'; // User name to display in signatures wpShowImages = true; // Enable downloading and displaying of images // Include Live Preview... //document.write('<script type="text/javascript"' + // 'src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/' + // 'livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"><\/script>'); // Now set everything up //window.onload = Main; function Main() { LivePreviewInstall(); // You may include here other "extensions" } /* This is to keep track of who is using the Live Preview: [[User:Pilaf/livepreview.js]] */ //If you are not editing a page, a tab will appear allowing you to edit the 0th section of a page (the top area usually used as an introduction. addOnloadHook(function () { var x; if (!(x = document.getElementById('ca-edit') )) return; var url; if (!(url = x.getElementsByTagName('a')[0] )) return; if (!(url = url.href )) return; var y = addLink('p-cactions', url+"§ion=0", '0', 'ca-edit-0', 'Edit the lead section of this page', '0', x.nextSibling); y.className = x.className; // steal classes from the the edit tab... x.className = 'istalk'; // ...and make the edit tab have no right margin // exception: don't steal the "selected" class unless actually editing section 0: if (/(^| )selected( |$)/.test(y.className)) { if (!document.editform || !document.editform.wpSection || document.editform.wpSection.value != "0") { y.className = y.className.replace(/(^| )selected( |$)/g, "$1"); x.className += ' selected'; } } }); function addLastDiff() { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") { var pname=z[n].textContent; } } var l=addTab("http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev", 'last', ''); l.lastChild.title="Show most recent diff"; } if (window.addEventListener) window.addEventListener("load", addLastDiff, false); else if (window.attachEvent) window.attachEvent("onload", addLastDiff); // <nowiki>If you are editing a page, click the wikify button on your tab bar to add "{{Wikify-date|{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}" to the top, set "Marked for wikification." as the edit summary, mark it as a minor edit, and submit.</nowiki> function doQwikify() { document.editform.wpTextbox1.value = '{' + '{' + 'Wikify-date|' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'Marked for wikification.'; document.editform.wpMinoredit.checked = true; document.editform.submit(); } function addQwikify() { addTab("javascript:doQwikify()", "wikify", "ca-wikify", "Mark for wikification", ""); akeytt(); } addOnloadHook(function() { if (document.title.indexOf("User:") != -1 || document.title.indexOf("User talk:") != -1) { return; } if (document.title.indexOf("Editing ") != -1) { addOnloadHook(addQwikify); } }); // by [[User:Raylu|raylu]] // // AutoCopyvio - Adds copyright violation notice to article and adds entry to Copyright Problems page // Created by Bmicomp from modified AutoVFD(by Korath) function add_link2(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(li); } function strip_namespace(target) { var colon = target.indexOf(':'); if (colon != -1) { var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category'); var ns = target.substring(0, colon); if (ns == '' || ns == 'Talk') return target.substring(colon + 1); else for (var i = 0; i < spaces.length; ++i) { if (ns == spaces[i] || ns == spaces[i] + '_talk') return target.substring(colon + 1); } } return target; } function copyvio() { document.editform.wpTextbox1.value = '{' + '{' + 'copyvio|url=}}'; document.editform.wpSummary.value = 'copyvio'; var target = document.editform.action; target = target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit')); var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date(); var datestring = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate(); var pagename = strip_namespace(target); window.open('/w/index.php?title=Wikipedia:Copyright_problems/' + datestring + '&action=edit&fakeaction=copyviolist&faketarget=' + pagename, 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); } function autocopyvio() { if (document.title.indexOf('Editing ') == 0) { var action = ''; var target = ''; if (location.search) { var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; ++i) { var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') action = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); } } if (action == 'copyviolist') { document.editform.wpTextbox1.value += '*[[' + target + ']] <span class="plainlinks">([http://en.wikipedia.org/{{localurl:' + target + '|action=history}} history] ยท [http://en.wikipedia.org/{{localurl:' + target + '|diff=0}} last edit])</span>' + ' from [' + '] ~' + '~~' + '~'; document.editform.wpSummary.value = 'Copyvio ' + '[[' + target + ']]'; } else add_link2('javascript:copyvio()', 'copyvio'); } } if (window.addEventListener) window.addEventListener('load', autocopyvio, false); else if (window.attachEvent) window.attachEvent('onload', autocopyvio); /**** delaid ****/ document.write('<script type="text/javascript"' + 'src="http://en.wikipedia.org/w/index.php?title=User:R3m0t/' + 'delaid.js&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /* This is to keep track of who is using this extension: [[User:R3m0t/delaid.js]] */ /* wpvfdhide */ 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 vfdlinks(){ if(document.title.indexOf("Wikipedia:Articles for deletion") == 0 && location.href.indexOf("Log") > -1){ addLink('p-cactions', 'javascript:hidevfd()', 'Hide'); addLink('p-cactions', 'javascript:showvfd()', 'Show'); } } if (window.addEventListener) window.addEventListener("load",vfdlinks,false); else if (window.attachEvent) window.attachEvent("onload",vfdlinks); document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Howcheng/quickimgdelete.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); function replace() { var s = prompt("Search regexp?"); if(s) { var r = prompt("Replace regexp?"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } } addOnloadHook(function () { if(document.forms.editform) { addLink('p-cactions', 'javascript:replace()', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history'); } }); // [[User:Ais523/topcontrib.js]] // This script color-codes lines according to who has the top contribution for a page. //<pre><nowiki> addOnloadHook(function () { if((location.href.indexOf("Special:Contributions")!=-1|| location.href.indexOf("Special%3AContributions")!=-1) &&location.href.indexOf("&Howcheng")==-1&&location.href.indexOf("?Howcheng")==-1) { var i,li,a; li=document.getElementById("bodyContent"); //li.getElementsByTagName("ul")[0].tagName="ol"; li=li.getElementsByTagName("li"); i=-1; a=new Array(); while(++i<li.length) { var s,t; t=li[i].innerHTML.match(/"\/wiki\/([^"]*)"/)[1]; if(li[i].getElementsByTagName("strong").length>0) s="#CCCCFF"; else s="#FFCCCC"; if(a[t]!=undefined) s=(a[t]=="#CCCCFF"?"#CCFFFF":"#FFFFCC"); else a[t]=s; li[i].innerHTML="<SPAN STYLE='background-color:"+s+"'>"+li[i].innerHTML+"</SPAN>"; } } }); // </pre>