User:Will Pittenger/monobook.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
/* By manually purging this page, you will be able to see the divisions I have set up for easy navigation. Please purge manually as using the [[Wikipedia:WikiProject User scripts/Scripts/Add purge to tabs|purge tab]] will have no effect. ==[[User:Lupin/popups.js]] == <pre style="overflow:auto"><nowiki> */ document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); // </nowiki></pre> end of popup code /* == [[User:Kbh3rd/whackamole.js]] == <pre style="overflow:auto"><nowiki> */ // // Edit tools for the vandal whack-a-mole game // [[User:Kbh3rd/whackamole.js]] - please include this line // document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Kbh3rd/whackamole.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');// </nowiki></pre> end of whack vandal code /* == [[User:Cacyle/wikEd|wikEd]] by [[User:Cacycle]] == === wikEd helpers === ==== [[User:Cacycle/diff]] text diff code ==== <pre style="overflow:auto"><nowiki>*/ document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/diff.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); // </nowiki></pre> end of text diff code /* ==== [[User:Pilaf/Live_Preview]] page preview tool ==== <pre style="overflow:auto"><nowiki>*/ 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>'); // </nowiki></pre> end of Live Preview code /* === wikEd core === [[User:Cacycle/wikEd]] <pre style="overflow:auto"><nowiki>*/ document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); var wikEdShowSourceButton = true; // </nowiki></pre> end of wikEd code /* == Takes the wikipage "page" and includes its raw text as javascript. == <pre style="overflow:auto"><nowiki>*/ function import_module(page) { if(document.createElement && document.childNodes) { var url = 'http://en.wikipedia.org/w/index.php?title=' + page.replace(/ /g, "_") + '&action=raw&ctype=text/javascript&dontcountme=s'; var scriptElem = document.createElement('script'); scriptElem.setAttribute('src',url); scriptElem.setAttribute('type','text/javascript'); document.getElementsByTagName('head')[0].appendChild(scriptElem); } } // </nowiki></pre> end of Import Module code /* == [[Wikipedia:WikiProject User scripts/Scripts/Edit Top]] == <pre style="overflow:auto"><nowiki>*/ import_module("User:Gerbrant/edit/top.js"); // </nowiki></pre> end of code to put edit links at the top of articles /* == [[Wikipedia:WikiProject User scripts/Scripts/Add purge to tabs]] == <pre style="overflow:auto"><nowiki>*/ import_module("Wikipedia:WikiProject User scripts/Scripts/addLink"); import_module("Wikipedia:WikiProject User scripts/Scripts/Add purge to tabs"); // </nowiki></pre> /* == [[Wikipedia:WikiProject User scripts/Scripts/Add changes since I lasted edited]] == <pre style="overflow:auto"><nowiki>*/ import_module('Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited'); // </nowiki></pre> /* == [[Wikipedia:WikiProject User scripts/Scripts/Watchlist since]] == <pre style="overflow:auto"><nowiki>*/ import_module('Wikipedia:WikiProject User scripts/Scripts/Watchlist since'); // </nowiki></pre> /* == add user tabs [[Wikipedia:WikiProject User scripts/Scripts/User tabs]] == <pre style="overflow:auto"><nowiki>*/ import_module('Wikipedia:WikiProject User scripts/Scripts/Add LI link'); import_module('Wikipedia:WikiProject User scripts/Scripts/Add tab'); /* == [[Wikipedia:WikiProject User scripts/Scripts/Quick wikify]] == <pre style="overflow:auto"><nowiki>*/ import_module('Wikipedia:WikiProject User scripts/Scripts/Quick wikify'); // </nowiki></pre> /* ===[[user:Where/usertabs]] Actual code === */ addOnloadHook(function() { if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history return; } if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) { username_a = document.URL.match(/:.*:(.*)/); username=username_a[1]; addTab("http://en.wikipedia.org/wiki/Special:Contributions/" + username, "contrib", "ca-contrib", "contribs", ""); addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=move&user=" + username, "page moves", "ca-pagemoves", "page moves", ""); addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=" + username, "block log", "ca-blog", "blog", ""); addTab("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=" + username, "edit count", "ca-kate", "kate", ""); } }); // </nowiki></pre> /* ==[[Wikipedia:WikiProject User scripts/Scripts/test-enhanced]] == <pre style="overflow:auto"><nowiki>*/ import_module("Wikipedia:WikiProject User scripts/Scripts/test-enhanced");// </nowiki></pre> /* ==[[Wikipedia:WikiProject User scripts/Scripts/Talk page section tabs]]== <pre style="overflow:auto"><nowiki>*/ import_module("Wikipedia:WikiProject User scripts/Scripts/Talk page section tabs");// </nowiki></pre> /* ==[[Wikipedia:WikiProject User scripts/Scripts/CleanupTab.js]] == <pre style="overflow:auto"><nowiki>*/ import_module("Wikipedia:WikiProject User scripts/Scripts/CleanupTab.js");// </nowiki></pre> /* == [[Wikipedia:WikiProject User scripts/Scripts/Unwatch]]== <pre style="overflow:auto"><nowiki>*/ addOnloadHook(function () { var query_prefix = "title=Special:Watchlist&action=submit&remove=1&id[]="; //var query_prefix = "action=unwatch&title="; if (window.location.href.indexOf("Special:Watchlist") < 0) return; if (window.location.href.indexOf("Special:Watchlist/edit") >= 0) return; var links = document.getElementById('content').getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].href.substring(links[i].href.length-15) != '&action=history') continue; var unwatch = document.createElement('a'); unwatch.href = "/w/index.php?" + query_prefix + encodeURIComponent(links[i].title); unwatch.title = "Unwatch "+links[i].title; unwatch.appendChild(document.createTextNode("unwatch")); links[i].parentNode.insertBefore(unwatch, links[i].nextSibling); // kluge to handle case where "diff" is unlinked: var delim = links[i].previousSibling; delim = (delim.nodeType == 3 ? delim.nodeValue : ""); links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch); } });// </nowiki></pre> end of [[Wikipedia:WikiProject User scripts/Scripts/Unwatch]] /* == [[Wikipedia:WikiProject User scripts/Scripts/Watchlist since]]== <pre style="overflow:auto"><nowiki>*/ import_module("Wikipedia:WikiProject User scripts/Scripts/Watchlist since");// </nowiki></pre> /* ==sigContract code from [[User:Where/sigcontract.js]]== <pre style="overflow:auto"><nowiki>*/ //Conflicts with force edit summary script! var scIndex = 0; var scKeys = new Array(); var scValues = new Array(); function scFormSubmit() { var i=0 var textArea = document.getElementById("wpTextbox1"); var text = textArea.value; while (i<scIndex) { text = text.replace(scKeys[i], scValues[i]); ++i; } textArea.value = text; } addOnloadHook(function() { if (document.title.indexOf("Editing ") != 0) {return;} document.getElementById("wpSave").onclick = scFormSubmit; document.getElementById("wpPreview").onclick = scFormSubmit; document.getElementById("wpDiff").onclick = scFormSubmit; //TODO: make it work with previews too! }); addOnloadHook(function() { if (document.title.indexOf("Editing ") != 0) {return;} var textArea = document.getElementById("wpTextbox1"); var text = textArea.value; var re = /<!--\[\[User:Where\/sigContract\]\];(.*)-->.*<!--ESC:(.*)-->/g; var lastIndex = 0; /* while (1) { var textSubstr = text.substr(lastIndex); alert(lastIndex); alert(textSubstr); //TODO: remove var newIndex = textSubstr.search(re); alert("newindex:" + newIndex); if (newIndex == -1) { break; } lastIndex += newIndex+1;*/ text = text.replace(re, function(str, p1, p2, offset, s) { // alert("In replacement function"); if (p1 == p2) { var newString = "-[[User:" + p1 + "|" + p1 + "]]"; scKeys[scIndex] = newString; scValues[scIndex] = str; ++scIndex; return newString; } else { return str; } }); //} textArea.value = text; });// </nowiki></pre> End of sigContract code /* ==Localized time/date script by [[User:Where/commentLocalize]] == <pre style="overflow:auto"><nowiki>*/ function numToMonth(num) { if (num==0) {return "Janurary";} else if (num==1) {return "February";} else if (num==2) {return "March";} else if (num==3) {return "April";} else if (num==4) {return "May";} else if (num==5) {return "June";} else if (num==6) {return "July";} else if (num==7) {return "August";} else if (num==8) {return "September";} else if (num==9) {return "October";} else if (num==10) {return "November";} else if (num==11) {return "December";} } function monthToNum(month) { var tmp = new Date(month + " 1, 2006"); return tmp.getMonth(); } function adjustTime(str, hour, minute, day, month, year, offset, s) { var time = new Date(); time.setUTCHours(hour); time.setUTCMinutes(minute); time.setUTCDate(day); time.setUTCMonth(monthToNum(month)); time.setUTCFullYear(year); var timeStr = ""; if (time.getHours()<10) {timeStr += "0";} timeStr += parseInt(time.getHours()) + ":"; if (time.getMinutes()<10) {timeStr += "0";} timeStr += parseInt(time.getMinutes()); timeStr += ", "; timeStr += time.getDate(); timeStr += " "; timeStr += numToMonth(time.getMonth()); timeStr += " "; timeStr += time.getFullYear(); timeStr += " (UTC"; var offset = -1*time.getTimezoneOffset()/60; if (offset >= 0) {timeStr += "+";} timeStr += offset + ")"; return timeStr; } function adjustTime2(str, hour, minute, month, day, year, offset, s) { return adjustTime(str, hour, minute, day, month, year, offset, s); } addOnloadHook(function() { if (document.title.indexOf("Editing ") == 0) { return; } if (document.location.href.indexOf("action=history") != -1) { return; } if (document.title.indexOf("Talk:") == 0 || document.title.indexOf("talk:") != -1 || document.title.indexOf("Wikipedia:") == 0) { var newDoc = document.getElementById("column-content").innerHTML.replace(/(\d\d):(\d\d), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/g, adjustTime); document.getElementById("column-content").innerHTML = newDoc; } /* if (document.location.href.indexOf("&action=history") != -1) { var newDoc = document.getElementById("bodyContent").innerHTML.replace(/(\d\d):(\d\d), ([A-Z][a-z]+) (\d{1,2}), (\d{4})/g, adjustTime2); document.getElementById("bodyContent").innerHTML = newDoc; }*/ }); // </nowiki></pre> End of commentLocalize code /* == George Money's scripts == /* ===Helpers=== */ ////// // Helpers for George Money's scripts //***************** /* ==== Var ==== <pre style="overflow:auto"><nowiki>*/ var myname=wgUserName.replace(' ', '_'); //use underscores instead of spaces var mypage="User:"+myname; var mytalk="User_talk:"+myname; var mycontribs="Special:Contributions/"+myname; var serverurl="http://en.wikipedia.org"; var wikiurl=serverurl+"/wiki/"; var pathurl=serverurl+"/w/"; var phpurl=pathurl+"index.php?title="; var editcounturl="http://tools.wikimedia.de/~essjay/edit_count/Count.php"; var editcount=editcounturl+"?username="; // </nowiki></pre> end of vars code /* ==== Cookies ==== <pre style="overflow:auto"><nowiki>*/ //COOKIE FUNCTIONS function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0; i < ca.length; i++) { var c = ca[i]; while(c.charAt(0) == ' ') c = c.substring(1, c.length); if(c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } function createCookie(name, value, days) { if(days) { var date = new Date(); date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function eraseCookie(name) { createCookie(name, "", -1); } // </nowiki></pre> end of Cookies code /* ==== Links ==== <pre style="overflow:auto"><nowiki>*/ // --- ADD VARIOUS LINKS ---- function addToolboxLink(url, name, id) { var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, url, name, id); } function addTopLink(url, name, id) { var personal = document.getElementById('p-personal').getElementsByTagName('ul')[0]; addlilink(personal, url, name, id); } function addNavLink(url, name, id) { var navigation = document.getElementById('p-navigation').getElementsByTagName('ul')[0]; addlilink(navigation, url, name, id); } function addTab(url, name, id, title, key) { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); } // ------ MORE MAJOR LINKAGE ----- function addLink(where, url, name, id, title, key, after) { //* where is the id of the toolbar where the button should be added; // i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb". // //* url is the URL which will be called when the button is clicked. // javascript: urls can be used to do more complex things. // //* name is what will appear as the name of the button. // //* id is the id of the button; it's best to define one. // Use a prefix to make sure its unique. Optional. // //* title is the tooltip title that gives a longer description // of the button; if you define a accesskey, mention it here. Optional. // //* key is the char you want for the accesskey. Optional. // //* after is the id of the button you want to follow this one. Optional. // var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; if(after) { tabs.insertBefore(li,document.getElementById(after)); } else { tabs.appendChild(li); } if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title]; } } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } // // ------------- LINKAGE ---------------- function addlilink(tabs, url, name, id, title, key) { var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title]; } } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } // </nowiki></pre> End of links /* ==== Include ==== <pre style="overflow:auto"><nowiki>*/ function loadJS(s) { s = s.replace(/^\[\[/, '').replace(/\]\]$/, '').replace(" ", "_"); document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=' + s + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); } function loadJSext(s) { document.write('<script type="text/javascript" src="'+ s + '"></script>'); } function loadCSS(page) { page=page.replace(" ", "_"); document.write('<style type="text/css">@import "'+phpurl+page+'&action=raw&ctype=text/css";</style>'); } function loadCSSext(page) { document.write('<style type="text/css">@import "'+page+'";</style>'); } // </nowiki></pre> End of Include //****************** // End of Helpers for George Money's scripts ////// /* === [[User:GeorgeMoney/UserScripts/newmessages]] === <pre style="overflow:auto"><nowiki>*/ import_module("User:GeorgeMoney/UserScripts/newmessages"); // </nowiki></pre> /* === Start of archive code === <pre><nowiki>*/ //The header to put on top of all archives (if the archive is in 'w' mode (modes explained below)) var archiveheader = ''; //Your talk page header for to use when archiving. Remember to keep the <noinclude> tags or else your archive will have your talk page header along with it. var talkheader = '<noinclude>{{User:Will Pittenger/Archive Indexer}}</noinclude>'; //Your talk page archive page. Insert "NUMBER" where the number of archive you are on goes var archiveurl = "User_talk:Will Pittenger/Archive NUMBER"; //The mode to archive your talk page. Making this value 'a' will make the script add your archive to the bottom of the current archive. Making it 'w' will totally erase the contents of the current archive (usually you should set the current archive value to a new archive to avoid erasing old archives, where as in append mode (a), you should set it to your current archive to append the contents) var archivemode = 'a'; // if(readCookie('archive1') == 'yes' && window.location.href.indexOf('archivestep') == -1) { (window.location.href) = wikiurl+mytalk+'?action=edit&archivestep=2'; } function changearccontents() { document.title = "Archival Script Manager"; document.getElementById('bodyContent').innerHTML = '<div class="dontshow" style="display: none !important;"></div>\n' + '<h1 class="firstHeading" style="display:block;">Archive Script Manager</h1>\n' + 'Current archive number (the one that you haven\'t done yet (like if I want to archive to archive 2 then that is the next one not done)): <br> <input type="text" id="archnuminput" value="' + readCookie('archivenum') + '" size="1" maxlength="4" /> <input type="button" value="save number" onclick="createCookie(\'archivenum\', document.getElementById(\'archnuminput\').value); document.getElementById(\'arclink\').href = wikiurl+archiveurl.replace(\'NUMBER\',readCookie(\'archivenum\'))+\'?action=edit&archivestep=1\';" /><br><br>\n'+ '<a href="'+wikiurl+archiveurl.replace('NUMBER',readCookie('archivenum'))+'?action=edit&archivestep=1" id="arclink" style="font-size: 2em; font-weight: bold;">Click here to begin the archive</a><br>\n' + ''; document.write('<style type="text/css">.firstHeading, .editsection {display:none;} .dontshow { display: none !important; } #content {background: honeydew !important; border: 3px solid green;} #p-cactions {display: none;}</style>'); } if(window.location.href.indexOf('archivemanage') != -1||window.location.href.indexOf('Archivemanage') != -1) { addOnloadHook(function(){ changearccontents(); }); } if (window.location.href.indexOf('archivestep=1') != -1 && window.location.href.indexOf('action=edit') != -1) { addOnloadHook(function (){ if(!readCookie('archivenum') != 'yes') { (window.location.href) = wikiurl+'User:GeorgeMoney/archivemanage' } if(archivemode == 'a') { document.getElementById('wpTextbox1').value += "\n{{sub"+"st:"+mytalk+"}}"; } else { document.getElementById('wpTextbox1').value = archiveheader+"\n{{sub"+"st:"+mytalk+"}}"; } document.getElementById('wpSummary').value = "JS: Copying talkpage to archive"; createCookie('archive1', 'yes'); document.getElementById('editform').submit(); }); } if (window.location.href.indexOf('archivestep=2') != -1 && window.location.href.indexOf('action=edit') != -1) { addOnloadHook(function (){ if(readCookie('archive1') != 'yes') { alert("You shouldn't be at \"&archivestep=2\" because you haven't completed &archivestep=1. Please read the instructions on this archiving script. Redirecting to archive manager. "); (window.location.href) = wikiurl+'User:GeorgeMoney/archivemanage'; return; } createCookie('archive1', 'no'); document.getElementById('wpTextbox1').value = talkheader; document.getElementById('wpSummary').value = "JS: Archiving talk page"; document.getElementById('editform').submit(); }); }// </nowiki></pre> end of archive code by [[User:GeorgeMoney/UserScripts/archive]] /* ==[[user:Where/easy db]] == <pre><nowiki>*/ 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"); 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"); 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 (window.location.href.indexOf("Special:") != -1) return; addTab("javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", ""); addTab("javascript:easyDb(1)", "db (reason)", "ca-db0", "Request speedy deletion with reason", ""); }); function easyDb(n) { if (n == 0) { //edit page var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free')); location.assign("/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=off"); } if (n == 1) { //edit page var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free')); location.assign("/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=on"); } } //</nowiki></pre> /////////////////////////////// // Must be after all other tabs /* == [[Wikipedia:WikiProject User scripts/Scripts/Duplicate tabs at bottom]] == <pre style="overflow:auto"><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> end of [[Wikipedia:WikiProject User scripts/Scripts/Duplicate tabs at bottom]] code /* == See also == *[[User:Will Pittenger/monobook.css]]*/