User:AndyZaft/monobook.js

var wysiDir = ''; // Copied from Wikiwyg function getArticleName {	var url = document.URL;

/*	set startpos to the end of the first wysi dir bit, plus one for the slash after it */ var startPos = url.indexOf( wysiDir + "/" ) + wysiDir.length +1;

/*	set endpos to the start of the http arguments, or the end of the string if there are none */ var quest_pos = url.indexOf( "?" ); if( quest_pos == -1 ) quest_pos = url.length;

var hash_pos = url.indexOf( "#" ); if( hash_pos == -1 ) hash_pos = url.length;

var endPos = Math.min( hash_pos, quest_pos );

if( startPos == endPos ) return "mainpage"; else {		var rtn = url.substring( startPos, endPos ); return wiki_unescape( rtn ); } } function wiki_unescape( str ) {	str = unescape( str ); str = str.replace( /_/g, " " ); return str; }

function addEditSection { if (!document.getElementById('ca-addsection')) { var edit = document.getElementById('ca-edit'); var editparent = edit.parentNode; //+   var aseclinkcaption = document.createTextNode('+') //'' var aseclink = document.createElement('a'); aseclink.setAttribute('href',"/index.php?title="+getArticleName+"&action=edit&section=new"); var addsectionlinkcaption = aseclink.appendChild(aseclinkcaption); //'' var asec = document.createElement('li'); asec.setAttribute('id',"ca-addsection"); var addsectionlink = asec.appendChild(aseclink); var addsection = editparent.insertBefore(asec,edit.nextSibling); } } if (window.addEventListener) window.addEventListener("load",addEditSection,false); else if (window.attachEvent) window.attachEvent("onload",addEditSection);