user:Will Pittenger/monobook.js

/* 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 purge tab will have no effect.

Tools by [[User:Lupin]]

[[Wikipedia:User:Lupin/popups.js]]

*/

mw.loader.load(

'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'

+ '&action=raw&ctype=text/javascript&dontcountme=s'); //

End of popup code

// end of popup code

/*

== Options for Popups ==

*/

//popupFixDabs=true;

//popupRevertSummaryPrompt=true;//

/*

= [[User:Lupin/Anti-vandal tool|Filter Recent Changes]] =

*/

// Script from User:Lupin/recent2.js

document.write('');//

end of whack vandal code

/*

[[User:Cacycle/wikEd|wikEd]] by [[User:Cacycle]]

= wikEd helpers =

== [[User:Cacycle/diff]] text diff code ==

*/

document.write('');

//

end of text diff code

/*

== [[User:Mboverload/RegExTypoFix|RegExTypoFix]] common typo fixer ==

*/

document.write('');//

/*

Takes the wikipage "page" and includes its raw text as javascript.

*/

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

}

}

//

end of Import Module code

/*

[[Wikipedia:WikiProject User scripts/Scripts/Add purge to tabs]]

*/

import_module("Wikipedia:WikiProject User scripts/Scripts/addLink");

import_module("Wikipedia:WikiProject User scripts/Scripts/Add purge to tabs");

//

/*

[[Wikipedia:WikiProject User scripts/Scripts/Watchlist since]]

*/

import_module('Wikipedia:WikiProject User scripts/Scripts/Watchlist since');

//

/*

add user tabs [[Wikipedia:WikiProject User scripts/Scripts/User tabs]]

*/

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]]

*/

import_module('Wikipedia:WikiProject User scripts/Scripts/Quick wikify');

//

/*

=[[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", "");

}

}); //

/*

[[Wikipedia:WikiProject User scripts/Scripts/test-enhanced]]

*/

import_module("Wikipedia:WikiProject User scripts/Scripts/test-enhanced");//

/*

[[Wikipedia:WikiProject User scripts/Scripts/Talk page section tabs]]

*/

//import_module("Wikipedia:WikiProject User scripts/Scripts/Talk page section tabs");//

/*

[[Wikipedia:WikiProject User scripts/Scripts/CleanupTab.js]]

*/

import_module("Wikipedia:WikiProject User scripts/Scripts/CleanupTab.js");//

/*

[[Wikipedia:WikiProject User scripts/Scripts/Unwatch]]

*/

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

}

});//

end of Wikipedia:WikiProject User scripts/Scripts/Unwatch

/*

sigContract code from [[User:Where/sigcontract.js]]

*/

////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

// 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 = /.*/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 = "-" + p1 + "";

// scKeys[scIndex] = newString;

// scValues[scIndex] = str;

// ++scIndex;

// return newString;

// }

// else {

// return str;

// }

// });

// //}

// textArea.value = text;

//});//

End of sigContract code

/*

Localized time/date script by [[User:Where/commentLocalize]]

*/

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;

}*/

}); //

End of commentLocalize code

/*

[[User:GeorgeMoney|George Money's]] [[User:GeorgeMoney/UserScripts|scripts]]

/*

=Helpers=

  • /

//////

// Helpers for George Money's scripts

//*****************

/*

== [[User:GeorgeMoney/UserScripts/helpers/all#Vars|Var]] ==

*/

var myname=mw.config.get('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="; //

end of vars code

/*

== [[User:GeorgeMoney/UserScripts/helpers/all#Cookies|Cookies]] ==

*/

//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);

} //

end of Cookies code

/*

== [[User:GeorgeMoney/UserScripts/helpers/all#Links|Links]] ==

*/

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

} //

End of links

/*

== [[User:GeorgeMoney/UserScripts/helpers/all#Include|Include]] ==

*/

function loadJS(s)

{

s = s.replace(/^\[\[/, ).replace(/\]\]$/, ).replace(" ", "_");

document.write('');

}

function loadJSext(s)

{

document.write('');

}

function loadCSS(page)

{

page=page.replace(" ", "_");

document.write('');

}

function loadCSSext(page)

{

document.write('');

} //

End of Include

//******************

// End of Helpers for George Money's scripts

//////

/*

= [[User:GeorgeMoney/UserScripts/newmessages]] =

*/

loadJS("User:GeorgeMoney/UserScripts/newmessages"); //

/*

= [[User:GeorgeMoney/UserScripts/archive|George Money's Archive Manager]] =

*/

/AUTO ARCHIVE

//Written by GeorgeMoney

//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 tags or else your archive will have your talk page header along with it.

var talkheader = '{{User:Will Pittenger/Archive Indexer}}';

//Your talk page archive page. Insert "NUMBER" where the number of archive you are on goes. (Dont put a real number!! just put the text "NUMBER")

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 = 'w';

//do not edit below this line

var mtyalk = ("User talk:"+mw.config.get('wgUserName')).replace(/ /g, '_');

var wikiurl = mw.config.get('wgServer')+mw.config.get('wgArticlePath').replace('$1', '');

if(readCookie('archive1') == 'yes' && window.location.href.indexOf('archivestep') == -1) { (window.location.href) = document.getElementById('ca-edit').firstChild.href+'&archivestep=2'; }

function changearccontents() {

document.title = "Archival Script Manager";

document.getElementById('bodyContent').innerHTML =

'

\n' +

'

Archive Script Manager

\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)):


\n'+

'Click here to begin the archive
\n' +

'';

document.write('');

}

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();

});

}

//-------

//

//

end of archive code by User:GeorgeMoney/UserScripts/archive

/*

== Code to add Archive to the sidebar toolbox ==

*/

if(mw.config.get('wgPageName') == 'User_talk:Will_Pittenger')

{

addOnloadHook(

function()

{

var nav = document.getElementById('p-navigation').getElementsByTagName('ul')[0];

addlilink(nav, "http://en.wikipedia.org/wiki/Archivemanage", "archive", 'p-archive');

});

}

//

/*

= [[User:GeorgeMoney/UserScripts/autowelcome]] =

== Options ==

*/

if(welcome == undefined)

{

var welcome={};

welcome.edit={};

welcome.link={};

welcome.link.tab={};

welcome.link.newUserLog={};

welcome.link.redLinkTalk={};

welcome.options={};

//config

welcome.edit.summary = "Welcome to Wikipedia!";

welcome.edit.text = "{{sub" + "st:User:Will Pittenger/templates/Welcome}}";

welcome.edit.textAnon = "{{sub" + "st:User:Will Pittenger/templates/Welcome IP}}";

welcome.edit.button = 'wpSave';

welcome.link.newUserLog.defaultColor = "blue";

welcome.link.newUserLog.clickedColor = "green";

welcome.link.newUserLog.text = "[welcome]";

welcome.link.redLinkTalk.defaultColor = "blue";

welcome.link.redLinkTalk.clickedColor = "green";

welcome.link.redLinkTalk.text = "[welcome]";

welcome.link.redLinkTalk.blink = false;

welcome.link.tab.text = "Welcome!";

welcome.link.tab.accessKey = '';

welcome.options.newUserLogaddReloadButton = true;

welcome.options.newUserLogEnabled = true;

welcome.options.redLinkTalkEnabled = true;

welcome.options.addTab = true;

welcome.options.askIfPageIsNotBlank = true;

welcome.options.maxLinks = 6000;

welcome.options.warnIfOverMaxLinks = true;

//end config

}//

/*

== Actual Import of AutoWelcome code ==

*/

import_module("User:GeorgeMoney/UserScripts/autowelcome"); //

/*

[[user:Where/easy db]]

*/

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 (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");

}

}

//

///////////////////////////////

// Must be after all other tabs

/*

[[Wikipedia:WikiProject User scripts/Scripts/Duplicate tabs at bottom]]

*/

addOnloadHook(function () {

var tabs = document.getElementById('p-cactions').cloneNode(true);

tabs.id = 'mytabs';

var listitems = tabs.getElementsByTagName('LI');

for (i=0;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

});//

end of Wikipedia:WikiProject User scripts/Scripts/Duplicate tabs at bottom code

/*

See also