User:Stabber/monobook.js

var ArticlePath = '/wiki'; var ScriptPath = '/wiki';

// Copied from Wikiwyg function getArticleName {	var loc = document.location; var havetitle = false; var rtn = "";

// Check to see of loc.pathname is ScriptPath+'/index.php'. If it is, then we must use the query string if ( loc.pathname == (ScriptPath) ) { var query = loc.search; try { rtn = query.match(/[&?]title=([^&]+)/)[1]; } catch(er) { // No query, or title doesn't exist return 'Main_Page'; }	} else { // We're using the conical name var arti = ''; // Not using a trailing slash below because it may not exist if (loc.pathname.indexOf(ArticlePath) == 0) { // Using pretty URLs arti = loc.pathname.substring(ArticlePath.length, loc.pathname.length); } else if (loc.pathname.indexOf(ScriptPath) == 0) { // Using less pretty URLs arti = loc.pathname.substring(ScriptPath.length, loc.pathname.length); } else { return 'Main_Page'; }

if (arti.indexOf('/') == 0) { arti = arti.substring(1, arti.length); } else { return 'Main_Page'; }		rtn = arti; }	return unescape(rtn); }

function addTab(id, after, caption, url) { if (!document.getElementById(id)) { var edit = document.getElementById(after); if (!edit) return; //If the previous tab doesn't exist, don't add this one var editparent = edit.parentNode; //+   var aseclinkcaption = document.createTextNode(caption) //'' var aseclink = document.createElement('a'); aseclink.setAttribute('href',url); var addsectionlinkcaption = aseclink.appendChild(aseclinkcaption); //'' var asec = document.createElement('li'); asec.setAttribute('id',id); var addsectionlink = asec.appendChild(aseclink); var addsection = editparent.insertBefore(asec,edit.nextSibling); } }

function addEditSection { var arti = getArticleName; addTab("ca-editfirst", 'ca-edit', '0', ScriptPath+"?title="+escape(arti)+"&action=edit&section=0"); addTab("ca-addsection", 'ca-edit', '+', ScriptPath+"?title="+escape(arti)+"&action=edit&section=new"); addTab("ca-purgeme", 'ca-edit', 'purge', ScriptPath+"?title="+escape(arti)+"&action=purge"); } if (window.addEventListener) window.addEventListener("load",addEditSection,false); else if (window.attachEvent) window.attachEvent("onload",addEditSection);