User:Thesublime514/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.
If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
/*<pre><nowiki>*/ if ((wgNamespaceNumber % 2 || wgNamespaceNumber==4) && document.URL.match(/&action=(edit|submit)/)) addOnloadHook(function(){ var wpSave = document.getElementById('wpSave'); if (!wpSave) return; if (window.sigText) //change normal sig button as well mwEditButtons[9].tagOpen = sigText; else sigText = '-- ~~~~'; //create button var btn = document.createElement('input'); btn.type='button'; btn.value = '~'; btn.onclick = function(){ insertTags(sigText,'','') }; btn.style.marginRight = '4px'; btn.title = 'Put your signature'; if (window.sigAccessKey){ btn.accessKey = sigAccessKey; btn.title += ' [' + tooltipAccessKeyPrefix + btn.accessKey + ']'; } wpSave.parentNode.insertBefore(btn, wpSave); //for 'Wikipedia:' namespace: Sig is ok on Forum pages, on all others put it after Save button if ( ( wgNamespaceNumber == 4 ) && ( !wgTitle.match('^(Village pump [(]|Reference desk/|Deletion review/|Articles for deletion/|Templates for deletion/|.*noticeboard.*|Requests for (adminship|checkuser|arbitration|feedback|page protection|mediation)|Bot requests|Help desk|Editor review|Adminship survey|Cleanup|Miscellany for deletion|New contributors\' help page|Media copyright questions)') ) ) { wpSave.parentNode.insertBefore(btn, wpSave.nextSibling); return; //avoid warning below } //warn if saving without signature wpSave.onclick = function(){ if (document.editform.wpTextbox1.value.indexOf('~~~') >= 0 ) return true else return confirm('No signature?') } }) /*</nowiki></pre>*/ // <pre><nowiki> // HistoryCount addOnloadHook(function (){ var N = 250; // <<== CHANGE TO YOUR LIKING var x = document.getElementById('ca-history'); if(!x) return; x.getElementsByTagName('a')[0].href += "&limit=" + N; }); // </nowiki></pre> // <pre><nowiki> addOnloadHook(function () { var tabs = document.getElementById('p-cactions').cloneNode(true); tabs.id = 'mytabs'; var listitems = tabs.getElementsByTagName('LI'); for (i=0;i<listitems.length;i++) { if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id; } content = document.getElementById("content"); // Find the content div content.parentNode.insertBefore(tabs, content.nextSibling); // Place tab list right after content div }); // </nowiki></pre> // <pre><nowiki> // [[User:Dschwen/highlightredirects.js]] - please include this line document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Dschwen/highlightredirects.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); // </nowiki></pre> // <pre><nowiki> //Please leave the following line //[[user:Where/easy db]] //Start db script addOnloadHook(function() { //check if called from deletion request if (document.title.indexOf("Editing ") != -1) { if (document.URL.lastIndexOf("&fakeaction=huff") == -1) return; if (document.URL.lastIndexOf("&reason=off") != -1) { var type = prompt("Enter criteria for speedy deletion, e.g. A1, G3"); if (type == null) return; var f = document.editform, t = f.wpTextbox1; t.value = "{{db-" + type.toLowerCase() + "}}\n" + t.value; f.wpSummary.value = "JS: Requesting speedy deletion ([[WP:CSD#" + type + "|CSD " + type + "]])"; f.wpSave.click(); return; } else if (document.URL.lastIndexOf("&reason=on") != -1) { var type = prompt("Enter reason for speedy deletion"); if (type == null) return; var f = document.editform, t = f.wpTextbox1; t.value = "{{db|" + type + "}}\n" + t.value; f.wpSummary.value = "JS: Requesting speedy deletion"; f.wpSave.click(); return; } } if (wgCanonicalNamespace == "Special") return; addPortletLink("p-cactions", "javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", ""); addPortletLink("p-cactions", "javascript:easyDb(1)", "db (reason)", "ca-db1", "Request speedy deletion with reason", ""); }); function easyDb(n) { if (n == 0) { //edit page location.assign("/w/index.php?title=" + wgPageName + "&action=edit&fakeaction=huff&reason=off"); } if (n == 1) { //edit page location.assign("/w/index.php?title=" + wgPageName + "&action=edit&fakeaction=huff&reason=on"); } } //End db script // </nowiki></pre> // <pre><nowiki> // <nowiki>If you are editing a page, click the wikify button on your tab bar to add "{{Wikify|{{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|' + '{' + '{' + '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(); } addOnloadHook(function() { if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") { // wouldn't it make more sense to just check for wgCanonicalNamespace != "", or am I missing something? return; } if (document.editform) { addPortletLink("p-cactions", "javascript:doQwikify()", "wikify", "ca-wikify", "Mark for wikification", ""); } }); // by [[User:Raylu|raylu]] // </nowiki></pre> // <pre><nowiki> function welcome() { // Find the edit box var txt = document.editform.wpTextbox1; //The welcome template you are wanting to use var welcome_msg = 'w-basic|cookies=true|heading=true|headtext=Hello from [[User:Thesublime514|Nick]]' // The tag to be included is an welcome message var tag = '{{'+'subst'+':'+ welcome_msg +'}}'; // If the edit box doesn't already have this tag... if (txt.value.indexOf(tag) == -1) { // Append the tag txt.value += tag; // Add an edit summary document.editform.wpSummary.value = 'Welcome to Wikipedia!'; // Press the Save page button document.editform.submit(); } // If the tag was already there, turn the tab background red to indicate // that the script is functioning properly, but that there is no action // to do. This doesn't interrupt the user's work like an alert() would. else { document.getElementById('ca-unverified').firstChild.style.backgroundColor = "#ff4444"; document.getElementById('ca-unverified').style.backgroundColor = "#ff4444"; } } // Create a tab that calls this function when pressed addOnloadHook(function () { if(document.title.indexOf("Editing User talk:") == 0) { addPortletLink('p-cactions', 'javascript:welcome()', 'welcome', 'ca-welcome', 'Adds a welcome note to a new user', '', ''); } }); /* This is to keep track of who is using this extension: [[User:Nmajdan/welcome_newuser.js]] */ // </nowiki></pre> // <pre><nowiki> // Please leave the following line // [[user:Where/usertabs]] addOnloadHook(function() { if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1) //no subpages or history return; if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") { var username = encodeURIComponent( wgTitle ); addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "Contribs", "ca-contrib", "User contributions"); addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "Edit count", "ca-editcount", "Edit count from Interiot's Tool1"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=move&user=" + username, "Page moves", "ca-pagemoves", "Page moves by this user"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks received", "ca-blog", "Blocks received by this user"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspace", "", "List of pages in this user's userspace"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&user=" + username, "Blocks given", "", "Blocks by this user"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=protect&user=" + username, "Protections", "", "Protections by this user"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=delete&user=" + username, "Deletions", "", "Deletions by this user"); } }); // </nowiki></pre> // <pre><nowiki> // Autolink [[wikilinks]] and {{templates}} (especially useful for monobook.js and similar pages) addOnloadHook(function () { // Get the HTML of just the main body of the page, not including textareas hopefully if (document.title.indexOf("Editing ") != 0 && document.title.indexOf("Template:") != 0) { targetdiv = document.getElementById('bodyContent'); // bodyContent div for most pages } else if (document.getElementById('wikiPreview')) { targetdiv = document.getElementById('wikiPreview'); // wikiPreview if it's there } else if (document.getElementById('wikiDiff')) { targetdiv = document.getElementById('wikiDiff'); // wikiDiff if it's there } else { return; } content = targetdiv.innerHTML; content = content.replace(/([^\[])\[{2}([^\[\]\|\<\>\n]*)([^\[\]\<\>\n]*?)?\]{2}([^\]])/g, '$1<a class="autolink" href="/wiki/$2">[[$2$3]]</a>$4'); // Make wikilink code into links content = content.replace(/([^\{])\{{2}(subst\:|msg\:)?([^\{\}\|\<\>\n]*)([^\{\}\<\>\n]*?)?\}{2}([^\}])/g, '$1<a class="autolink" href="/wiki/Template:$3">{{$2$3$4}}</a>$5'); // Make template code into links targetdiv.innerHTML = content; // Write it back }); // </nowiki></pre>