User:HorsePunchKid/monobook.js

///////////////////////////////////////////////////////////////////////////////// // User:Lupin/popups.js - please include this line

mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'             + '&action=raw&ctype=text/javascript&dontcountme=s'); popupDelay=2.0; simplePopups=true; popupAdminLinks=true;

window.onload = Main; function Main { //changelinks; //addtoolboxlinks //addpurge; morelinks; //LivePreviewInstall; addPipesToHistory;

document.getElementById("ca-talk").removeAttribute("acccesskey"); if(document.getElementById("ca-unwatch")) document.getElementById("ca-unwatch").removeAttribute("acccesskey"); }

// Add a pipe to make using Template:Unsigned2 easier. function addPipesToHistory {   if(document.title.indexOf("- History -") > 0) {       var items=getElementsByClass(document, "history-user", "span"); for(i=0;i<items.length;i++) {           var hidden=document.createElement("span"); hidden.appendChild(document.createTextNode("|")); hidden.setAttribute("style", "color: white;"); items[i].childNodes[0].insertBefore(hidden,                   items[i].childNodes[0].childNodes[0]); }   } }

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); } } // function morelinks { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(document.title.indexOf("Editing ") == 0) {       addlilink(tabs, 'javascript:replace', 'replace', ''); addlilink(tabs, "javascript:insertTags('  "+getISO8601Date+" "+getISO8601Time+"Z ',,)", 'sign', 's'); document.getElementById("wpSave").removeAttribute("acccesskey"); } } // function getISO8601Date { var d=new Date; return(""+d.getUTCFullYear+"-"+(d.getUTCMonth<9?"0":"")+(d.getUTCMonth+1)+"-"+(d.getUTCDate<10?"0":"")+d.getUTCDate); }

function getISO8601Time { var d=new Date; return(""+(d.getUTCHours<10?"0":"")+d.getUTCHours+":"+(d.getUTCMinutes<10?"0":"")+d.getUTCMinutes+":"+(d.getUTCSeconds<10?"0":"")+d.getUTCSeconds); }

///////////////////////////////////////////////////////////////////////////////// // Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited function addSinceTab {   var tabs=document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) do_since_I_last_edited; else if (!/wiki\/Special:|w\/index.php?title=Special:/.test(window.location.href)) {      var pageTitle=document.title.slice(0, String(document.title).indexOf(" - ")); var l=addlilink(tabs, "/w/index.php?title="+pageTitle+"&action=history&gotosince=true", 'since', ''); l.lastChild.title="Changes since I last edited"; } } function do_since_I_last_edited {       var csub=document.getElementById("contentSub"); var msg=document.createElement("p"); msg.appendChild(document.createTextNode("Parsing history, please wait...")); msg.className="error"; csub.insertBefore(msg, csub.firstChild);

var username=document.getElementById("pt-userpage").textContent; var users=getElementsByClass(document, "history-user", "span");

for(i=0;i<users.length;i++) {           if(users[i].textContent==username) {               document.location=users[i].parentNode.childNodes[1].href; return; }       }

msg.replaceChild(document.createTextNode("You have not edited this page recently."), msg.firstChild); }

if (window.addEventListener) window.addEventListener("load", addSinceTab, false); else if (window.attachEvent) window.attachEvent("onload", addSinceTab);

///////////////////////////////////////////////////////////////////////////////// // Helper function; see Wikipedia:WikiProject User scripts/Scripts/Add LI link 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); }

///////////////////////////////////////////////////////////////////////////////// // http://www.dustindiaz.com/getelementsbyclass function getElementsByClass(node,searchClass,tag) { var classElements = new Array; 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; }