User:Gherald/monobook.js

// var addOnloadFunction=function(f) { if (window.addEventListener) window.addEventListener("load",f,false); else if (window.attachEvent) window.attachEvent("onload",f); else { var oldOnload='_old_onload_'+addOnloadFunction.uid; addOnloadFunction[oldOnload] = window.onload ? window.onload : function {}; window.onload = function { addOnloadFunction[oldOnload]; f; } ++addOnloadFunction.uid; } } addOnloadFunction.uid=0; //

//

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

//

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

function newTool(text,desc) { var tool = document.createElement("a"); tool.href = "javascript:inserts('"+text+" ','')"; var toolTxt = document.createTextNode(desc); tool.appendChild(toolTxt); return tool; }

function moreTools { var tools = document.getElementById('moretools'); tools.appendChild(newTool('+','added:')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('-','removed:')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('actor','actor')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('background','background information')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('category','category')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('citation','citation')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('IMDb','IMDb')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('de','Interwiki MA/de')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('nl','Interwiki MA/nl')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('ext. link(s)','external link(s)')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('link(s)','link(s)')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('picture(s)','picture(s)')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('stub','template:stub')); tools.appendChild(document.createTextNode(" || ")); tools.appendChild(newTool('rev','reverted:')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('vandalism','vandalism')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('disambig','disambig')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('duplication','duplication')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('formatting','formatting')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('linkfix','linkfix')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('spelling','spelling')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('typo','typo')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('wikified','wikified')); tools.appendChild(document.createTextNode(" || ")); tools.appendChild(newTool('copyvio','copyvio')); tools.appendChild(document.createTextNode(" | ")); tools.appendChild(newTool('see Talk','see Talk'));

tools.appendChild(document.createElement("BR")); } if (window.addEventListener) window.addEventListener("load",moreTools,false); else if (window.attachEvent) window.attachEvent("onload",moreTools);

function inserts(tag, sampleText) { var txtarea = document.editform.wpSummary; txtarea.value = txtarea.value + tag; }

//

//If you are not editing a page, a tab will appear allowing you to edit the 0th section of a page (the top area usually used as an introduction.

function addEditSection0 { ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page']; if (!document.getElementById) return; x = document.getElementById('ca-edit'); if(!x) return; y = document.createElement('LI'); y.id = 'ca-edit-0'; if (x.className == 'selected') { if (/&action=edit&section=0$/.test(window.location.href)) { x.className = 'istalk'; y.className = 'selected'; } else { x.className = 'selected istalk'; } } else if (x.className == 'selected istalk') { if (/&action=edit&section=0$/.test(window.location.href)) { x.className = 'istalk'; y.className = 'selected istalk'; } else { y.className = 'istalk'; } } else { y.className = x.className; x.className = 'istalk'; } z = document.createElement('A'); if (x.children) { z.href = x.children[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling); } else { z.href = x.childNodes[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling); } }

if (document.title.indexOf("Editing ") == -1) { if (window.addEventListener) window.addEventListener("load", addEditSection0, false); else if (window.attachEvent) window.attachEvent("onload", addEditSection0); }

//

// This will add an [edit top] link at the top of all pages except preview pages // by User:Pile0nades

setTimeout("editTopLink", 0) // this is equivalent of onload function editTopLink { // if this is preview page or generated page, stop if(document.getElementById("wikiPreview") || window.location.href.indexOf("w/index.php?title=Special:") != -1) return;

// get the page title var pageTitle = document.title.split(" - ")[0].replace(" ", "_");

// create div and set innerHTML to link var divContainer = document.createElement("div"); divContainer.innerHTML = ' [edit top] ';

// insert divContainer into the DOM before the h1 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);

}

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

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

//

//From http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510 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 thetitle=document.title.slice(0, String(document.title).indexOf(" - ")); var l=addlilink(tabs, "/w/index.php?title="+thetitle+"&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 hists=document.getElementById("pagehistory").childNodes; for (n=0;n<hists.length;n++) { if (hists[n].getElementsByTagName("span")[0].textContent==username) { document.location=hists[n].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);

//

function doLastDiff { var nurl = "http://en.wikipedia.org/w/index.php?title=" + getPname + "&diff=cur&oldid=prev"; document.location = nurl } function addLastDiff { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; var l=addlilink(tabs, "javascript:doLastDiff", 'last', ''); l.lastChild.title="Show most recent diff"; }

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

function getPname { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") return z[n].textContent; }; }

function morelinks { 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; } document.getElementById('column-content').appendChild(tabs); } if (window.addEventListener) window.addEventListener("load",morelinks,false); else if (window.attachEvent) window.attachEvent("onload",morelinks);

function openAdahLinks(kk) { var as = document.getElementsByTagName('a'); var k = 0; for (n=0; n<as.length; n++) { if (as[n].innerHTML == 'diff') { if (k <= kk) { PrivoxyWindowOpen(as[n].href, '_blank'); }     k++; } } }

/*

This script adds hyperlinks with the text "adah" (all diffs above here) to every entry in your watchlist, after the "diff" link. Clinking on one of them opens the corresponding diff and all the more recent ones. You can use this to study all the changes since you last checked the watchlist. This is most useful with a browser configured to open them in tabs.

Remarks:
 * This script uses the Get Page Name function.
 * It is only tested with Monobook and Firefox.
 * The script does not open newly created pages appearing on your watchlist.

*/

function openAdahLinks(kk) { var as = document.getElementsByTagName('a'); var k = 0; for (n=0; n<as.length; n++) { if (as[n].innerHTML == 'diff') { if (k <= kk) { PrivoxyWindowOpen(as[n].href, '_blank'); }     k++; } } }

function addAdahLinks { if (getPname == 'My watchlist') { var as = document.getElementsByTagName('a'); var k = 0; for (n=0; n<as.length; n++) { if (as[n].innerHTML == 'diff') { var tn = document.createTextNode(') ('); var link = document.createElement('a'); link.href = 'javascript:openAdahLinks(' + (k++) + ')'; link.appendChild(document.createTextNode('adah'), null); as[n].parentNode.insertBefore(tn, as[n].nextSibling.nextSibling); as[n].parentNode.insertBefore(link, as[n].nextSibling.nextSibling); }   }  } }

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

/* */