User:Thewinchester/monobook.js

// //Detect IE5.5+ if (navigator.appVersion.indexOf("MSIE")==-1) {                 // Normal contents go here

// From code by raylu // // // This script adds a "Australia Deletion" tab to the top of article pages // when in edit mode. It is disabled for the User namespace.

function dodeletion { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n{' + '{' + 'subst' + ':' + 'delsort' + '|' + 'Australia' + '}' + '}' + ' ' + '--' + ' ' + '~' + '~' + '~' + '~'; document.editform.wpSummary.value = 'Tagged as a Australia-related deletion.'; document.editform.wpMinoredit.checked = true; document.editform.submit; }

function adddeletion { addTab("javascript:dodeletion", "Australia deletion", "ca-Australiadeletion", "Australia Deletion", ""); akeytt; }

$(function { if (document.title.indexOf("User:") != -1 || document.title.indexOf("User talk:") != -1) {     return;  }  if (document.title.indexOf("Editing ") != -1) {  addOnloadHook(adddeletion);  } });

function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key) };

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; }

// jncsp-start The section below (up to jncsp-end) is maintained by WikiProject_User_scripts/User-script_manager // jncsp-config autoafd addPurgeTab

if (location.href == "http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/User-script_manager") document.write(' ');

// From WikiProject User_scripts/Scripts/addLink, revision 73544644

//A helper function to add a button to one of the toolbars in the interface. //An improved(I hope) version of addlilink. //JesseW, the juggling janitor 05:33, 8 November *2005 (UTC)

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; }

// From WikiProject User_scripts/Scripts/Add_purge_to_tabs, revision 76509603

// addPurge $( function {   var x = document.getElementById('ca-history');    if(!x) return;    if(x.children) x = x.children[0].href;    else x = x.childNodes[0].href;    addLink("p-cactions", x.replace(/=history/, "=purge"), 'purge', 'ca-purge', 'Purge the internal cache for this page', 0); });

// From WikiProject User_scripts/Scripts/AutoAFD.js, revision 75520536

//Auto AFD script

//Please include the two following lines //Modified version of AutoVFD script to work with AFD //Script Modified by User:Jtkiefer //Further modified to work with WP:AFDC by User:ais523

// This needs to change depending on skin used. function add_link(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 afd { document.editform.wpTextbox1.value = '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'afd';

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; date = date.getUTCFullYear + '_' + months[date.getUTCMonth] + '_' + date.getUTCDate;

var pagename = strip_namespace(target);

window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/' + pagename + '&action=edit&fakeaction=afdsub&faketarget=' + target,             'Afd ' + unescape(target),              'status,toolbar,location,menubar,directories,resizeable,scrollbars'); window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=afdlist&faketarget=' + pagename,             'AfdLog ' + unescape(target),              'status,toolbar,location,menubar,directories,resizeable,scrollbars'); }

function autoafd { 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 == 'afdlist') {         document.editform.wpTextbox1.value += '\n'; document.editform.wpSummary.value = 'Articles for deletion/' + target + ''; }     else if (action == 'afdsub') {         if (document.editform.wpTextbox1.value.length > 0) {             target = document.editform.action; target = unescape(target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit'))).replace(/_/g, ' '); window.alert("There's an old afd at the default location already.\n\n" +                          'Please either move it out of the way (and update existing links to it), or file the Afd by hand in another location (such as ' + target + ' (2)).'); }         else document.editform.wpTextbox1.value += '===' + target + '===\n' + '{'+'{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD|>>add cat here<<}}\n'+ 'Reason for nomination. ' + '\n*\n*\n*\n'; }     else add_link('javascript:afd', 'Afd'); } }

$(autoafd);

// jncsp-end

// Add date and time to your monobook "personal menu" list at the very top of the page. // Created by User:Mathwiz2020

// Indicate where you would like the time to appear: // 1 is first (before username), 2 is second (before talk link), ... 7 is last (after log out link) insertBeforeNum = 7;

// Do NOT edit below this line unless you're experiened in javascript insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout",""); insertBefore = insertBeforeArr[insertBeforeNum];

function makeTime { var li = document.createElement( 'li' ); li.id = 'pt-time';

var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( 'date and time' ) );

li.appendChild( mySpan );

if ( insertBefore ) {   var before = document.getElementById( insertBefore ); before.appendChild( li, before ); } else // append to end (right) of list {   document.getElementById( 'pt-logout' ).parentNode.appendChild( li ); }

getTime; }

if     ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false ); else if ( window.attachEvent     ) window.attachEvent      ( 'onload', makeTime      );

function getTime {   var time    = new Date; var date   = time.getUTCDate; var months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '); month  = months[time.getUTCMonth]; var year   = time.getUTCFullYear; var hours  = '0' + time.getUTCHours; hours  = hours.substr(hours.length-2, hours.length); var minutes = '0' + time.getUTCMinutes; minutes = minutes.substr(minutes.length-2, minutes.length); var seconds = '0' + time.getUTCSeconds; seconds = seconds.substr(seconds.length-2, seconds.length); var curTime = hours + ":" + minutes + ":" + seconds + ", " + date + " " + month + " " + year + " (UTC)"; datePlace  = document.getElementById('pt-time').childNodes[0].childNodes[0]; datePlace.replaceData(0, datePlace.length, curTime); doTime     = window.setTimeout("getTime", 1000); } //

/**** afd helper ****/ document.write(' ');

/* This is to keep track of who is using this extension: User:Jnothman/afd_helper/script.js */

//On diff pages this script replaces (Difference between revisions)with //different tools for reverting the edit and warning the user that made the edit. //For instructions see talk page. // Revert tools by Lorian function getElementsByClass(searchClass,node,tag) { // Function from http://www.dustindiaz.com/getelementsbyclass/ var classElements = new Array; if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } }  return classElements; }

// _GET code from NoGray JS Library http://www.nogray.com/new_site/ var _GET = new Array; var _uri = location.href;

var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");

var _temp_get_arr_1 = new Array;

for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){ _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("="); _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]); }

delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;

function getMessage (where, user1, user2) { var message = prompt ('What message would you like to leave?', ''); window.location = 'http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message; }

$(function { if (location.href.match(/diff=/)) {    // Get username of submitter    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;    document.getElementById('contentSub').innerHTML = '(Revert / Message) (Vandalism / Message) (Warn: Test / Blatant / Nonsense / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">Blanking</a>)'; } else if (location.href.match(/revert=1/)) { document.getElementById('wpSummary').value = 'Reverted edits by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+''; document.getElementById('editform').submit; } else if (location.href.match(/revert=2/)) { document.getElementById('wpSummary').value = 'Reverted edits by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+' ('+_GET['message']+')'; document.getElementById('editform').submit; } else if (location.href.match(/vandalism=1/)) { document.getElementById('wpSummary').value = 'Reverted vandalism by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+''; document.getElementById('editform').submit; } else if (location.href.match(/vandalism=2/)) { document.getElementById('wpSummary').value = 'Reverted vandalism by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+' ('+_GET['message']+')'; document.getElementById('editform').submit; } else if (location.href.match(/warn=1/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=2/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=3/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=4/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } });

$(function { if (mw.config.get('wgTitle').indexOf("/") != -1 || document.title.indexOf("- History -") != -1)  //no subpages or history     return;  if (mw.config.get('wgCanonicalNamespace') == "User" || mw.config.get('wgCanonicalNamespace') == "User_talk") {     var username = encodeURIComponent( mw.config.get('wgTitle') );     mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/wiki/Special:Contributions/" + username, "contribs", "ca-contrib", "User contributions");     mw.util.addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "count", "ca-editcount", "Edit count from Interiot's Tool1");     mw.util.addPortletLink("p-cactions", "http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=" + username + "&site=en.wikipedia.org", "Summary", "ca-summary", "Edit Summary");  } });

$(function { var subpage = "/Status";  var scheme = "/StatusTemplate";  var subpagelink = mw.config.get('wgServer') + "/w/index.php?title=User:" + encodeURIComponent(mw.config.get('wgUserName') + subpage);  var logout = document.getElementById( 'pt-logout' );  //Add the links  mw.util.addPortletLink("p-personal", subpagelink + "&action=edit&newstatus=in", "In", "pt-status-in", "I'm in!", "", logout);  mw.util.addPortletLink("p-personal", subpagelink + "&action=edit&newstatus=busy", "Busy", "pt-status-busy", "I'm busy!", "", logout);  mw.util.addPortletLink("p-personal", subpagelink + "&action=edit&newstatus=out", "Out", "pt-status-out", "I'm out!", "", logout);  if (location.href.indexOf("&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status?  //Get new status  var statusRegExp = /&action=edit&newstatus=(.*)/;  var status = statusRegExp.exec(location.href)[1]; //Modify the form document.getElementById('wpTextbox1').value = ""; document.getElementById('wpSummary').value = "Status: "+status; document.getElementById('wpMinoredit').checked = 'checked'; //Submit it! document.getElementById('editform').submit; });

function getXmlHttpObject { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest; } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }   catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }     catch (e) { xmlHttp = false; }   }  }  return xmlHttp; }

function changeTab { if (watchAction == 'watch') { watchLink.innerHTML = 'unwatch'; watchAction = 'unwatch'; } else if (watchAction == 'unwatch') { watchLink.innerHTML = 'watch'; watchAction = 'watch'; } }

function setWatch(action) { xmlHttp = getXmlHttpObject; if (xmlHttp == false) return; xmlHttp.onreadystatechange = changeTab; xmlHttp.open('GET', 'http://en.wikipedia.org/w/index.php?title=' + pageName + '&action=' + action, true); xmlHttp.send(null); }

function setWatchTab { if (document.getElementById('ca-watch') || document.getElementById('ca-unwatch')) { if (document.getElementById('ca-watch')) { watchLink = document.getElementById('ca-watch').getElementsByTagName('a')[0]; watchAction = 'watch'; } else if (document.getElementById('ca-unwatch')) { watchLink = document.getElementById('ca-unwatch').getElementsByTagName('a')[0]; watchAction = 'unwatch'; }     watchUrl = watchLink.href pageName = watchUrl.substring(watchUrl.indexOf('title=')+6,watchUrl.indexOf('&action')); watchLink.href = 'javascript:setWatch(watchAction);'; } } $(setWatchTab);

importScript('User:AzaToth/twinkle.js');

}

// From code by raylu // // // This script adds a "Schools Deletion" tab to the top of article pages // when in edit mode. It is disabled for the User namespace.

function doschooldeletion { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n{' + '{' + 'subst' + ':' + 'delsort' + '|' + 'Schools' + '}' + '}' + ' ' + '--' + ' ' + '~' + '~' + '~' + '~'; document.editform.wpSummary.value = 'Tagged as a Schools-related deletion.'; document.editform.wpMinoredit.checked = true; document.editform.submit; }

function addschooldeletion { addTab("javascript:doschooldeletion", "Schools deletion", "ca-Schoolsdeletion", "Schools Deletion", ""); akeytt; }

$(function { if (document.title.indexOf("User:") != -1 || document.title.indexOf("User talk:") != -1) {     return;  }  if (document.title.indexOf("Editing ") != -1) {  addOnloadHook(adddeletion);  } });

function addschoolTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addschoollilink(tabs, url, name, id, title, key) };

function addschoollilink(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; }

/* Watchlist notifier (User:Ais523/watchlistnotifier.js); displays a message every time a watched page changes. */

var wmwpajax; // From WP:US mainpage (wpajax renamed to wmwpajax) wmwpajax={ download:function(bundle) { // mandatory: bundle.url // optional: bundle.onSuccess (xmlhttprequest, bundle) // optional: bundle.onFailure (xmlhttprequest, bundle) // optional: bundle.otherStuff OK too, passed to onSuccess and onFailure var x = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false; if (x) { x.onreadystatechange=function { x.readyState==4 && wmwpajax.downloadComplete(x,bundle); };                       x.open("GET",bundle.url,true); x.send(null); }               return x;        }, downloadComplete:function(x,bundle) { x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true ) || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText+': '+bundle.url)); } }; // Example: // function dlComplete(xmlreq, data) { //     alert(data.message + xmlreq.responseText); // } // wmwpajax.download({url:'http://en.wikipedia.org/w/index.php?title=Thresher&action=raw', //                   onSuccess: dlComplete, message: "Here's what we got:\n\n" }); // End of WP:US quote function wmWatchEditFound(xmlreq, data) { var watchrev, watchsum, watchrevold, watchpage, junk; watchrev=xmlreq.responseText.split('timestamp="')[1].split('"')[0]; if(mw.config.get('wgPageName') == "Special:Watchlist") document.cookie="ais523wmwatchrev="+watchrev+".; path=/"; else {   watchsum=xmlreq.responseText.split('comment="')[1].split('"')[0]; watchpage=xmlreq.responseText.split('title="')[1].split('"')[0]; try {     watchrevold=document.cookie.split('ais523wmwatchrev=')[1].split('.')[0]; }   catch(junk) {watchrevold=0;} watchsum=watchsum.split('<').join('&lt;').split('>').join('&gt;'); watchpage=watchpage.split('<').join('&lt;').split('>').join('&gt;'); if(watchrev!=watchrevold) document.getElementById('contentSub').innerHTML+= " \""+watchpage+'" changed: "'+watchsum+'". '; } } $(function {  /* Find the top item in the watchlist, and its edit summary. We only need one item, so     set the limit to 1 to ease the load on the server. */  //if(location.href.indexOf("/wiki/")!=-1)    wmwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=watchlist&wllimit=1&'+ 'wldir=older&format=xml&wlprop=comment|timestamp|title', onSuccess: wmWatchEditFound}); }); //

$(function {

// Check if we're on the watchlist if (!mw.config.get('wgCanonicalSpecialPageName') || mw.config.get('wgCanonicalSpecialPageName') != "Watchlist") return; if (!document.forms[0] || !document.forms[0].namespace) return;

// Unwatch links go back to watchlist with "Removing requested items from watchlist..." message var query_prefix = "title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=submit&remove=1&id[]=";

// ...or... // Unwatch links go to "Removed from watchlist" page //var query_prefix = "action=unwatch&title=";

// get list of all links in content: var links = document.getElementById('content').getElementsByTagName('a');

// make a static copy of the nodelist and lose the original for speed // while we're at it, prune the uninteresting links from the list var linksCopy = new Array ; for (var i = 0; i < links.length; i++) { if (/[?&]action=history([&#]|$)/.test(links[i].href)) linksCopy.push(links[i]); }   links = linksCopy;

for (var i = 0; i < links.length; i++) { // create unwatch link and append it after history link var unwatch = document.createElement('a'); unwatch.href = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/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);

// insert a delimiter between the two links var delim = links[i].previousSibling; delimText = (delim.nodeType == 3 ? delim.nodeValue : ""); // kluge to handle case where "diff" is unlinked delim = document.createTextNode(delimText.replace(/^.*diff/, "")); links[i].parentNode.insertBefore(delim, unwatch); } });

//

// User:Henrik/live-edit-counter importScript('User:Henrik/js/live-edit-counter.js');

importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu'); importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css'); importScript('User:S/tags.js');

//