User:Patchouli/monobook.js

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

// Adds a tab allowing you to edit the 0th section of a page (the top area usually used as an introduction).

// NOTE: This version requires a recent version of the addLink helper function.

//

$(function {    var x;    if (!(x = document.getElementById('ca-edit') )) return;    var url;    if (!(url = x.getElementsByTagName('a')[0] )) return;    if (!(url = url.href )) return;    var y = addLink('p-cactions', url+"&section=0", '0', 'ca-edit-0', 'Edit the lead section of this page', '0', x.nextSibling);

y.className = x.className; // steal classes from the the edit tab... x.className = 'istalk';    // ...and make the edit tab have no right margin

// exception: don't steal the "selected" class unless actually editing section 0: if (/(^| )selected( |$)/.test(y.className)) { if (!document.editform || !document.editform.wpSection           || document.editform.wpSection.value != "0") { y.className = y.className.replace(/(^| )selected( |$)/g, "$1"); x.className += ' selected'; }   } });

//

//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 or DOM node 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.appendChild(li); } else if (after.cloneNode) { // looks like a DOM node tabs.insertBefore(li,after); } else { // assume this is an ID string tabs.insertBefore(li,document.getElementById(after)); }   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; }

// This will add an [edit] link at the top of all pages except preview pages and the main page // Originally by User:Pile0nades, modified by User:Gerbrant.

// Add an [edit] link to pages hookEvent("load", function {	if(window.location.href.indexOf("/wiki/Special:") != -1) return;	if(document.getElementById("wikiPreview")) return;	if(document.getElementById("histlegend‎")) return;	if(document.getElementById("difference‎")) return;	if(document.getElementById("watchdetails")) return;	if(document.getElementById("mainpage")) return;

if(window.location.href.indexOf("&action=edit") == -1) {		var pageTitle = document.title.split(" - ")[0].replace(" ", "_"); var divContainer = document.createElement("div"); divContainer.innerHTML = ' \ [edit] '; var coos = document.getElementById("coordinates"); if(coos) coos.style.right = "4.5em"; document.getElementById("content").insertBefore(			divContainer, document.getElementsByTagName("h1")[0]); }	else if(window.location.href.indexOf("&action=edit&section=0") != -1) {		e = document.getElementById("wpSummary"); if(e) e.value = "/* Intro */ "; } });