User:Connel MacKenzie/tabs.js

//From Vild's monobook.js // EDIT SECTION 0

function addEditSection0 {

pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue; if (!pagetitle) pagetitle = wgPageName ; if (pagetitle.search(/Search/) != -1) { pagetitle = document.getElementById('searchInput').value; } pagename = pagetitle.replace(/Editing /g, ""); pagenamee = pagename.replace(/\ /g, "_"); pagenameee = pagename.replace(/\ /g, "+");

if (!document.getElementById) return; x = document.getElementById('ca-edit'); if(!x) return; y = document.createElement('LI'); y2 = document.createElement('LI'); y3 = document.createElement('LI'); y4 = document.createElement('LI'); y.id = 'ca-edit-0'; y2.id = 'ca-edit-0'; y3.id = 'ca-edit-0'; y4.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'); z2 = document.createElement('A'); z3 = document.createElement('A'); z4 = document.createElement('A'); if (x.children) { var v = x.children[0]; var w = x.children[0].parentNode; z.href = x.children[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); w.insertBefore(y,v); z2.href = x.children[0].href + '&section=new'; z2.appendChild(document.createTextNode('+')); y2.appendChild(z2); w.insertBefore(y2,y); z3.href = 'http://en.wiktionary.org/w/index.php?title=' + pagenamee + '&action=purge'; z3.appendChild(document.createTextNode('P')); y3.appendChild(z3); w.insertBefore(y3,y2); z4.href = 'http://tools.wikimedia.de/~cmackenzie/rnd-en-wikt.html'; z4.appendChild(document.createTextNode('$R')); y4.appendChild(z4); w.insertBefore(y4,y3); } else { if (x.nextSibling) { var w = x.parentNode; z.href = x.childNodes[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); w.insertBefore(y,x.nextSibling); z2.href = x.childNodes[0].href + '&section=new'; z2.appendChild(document.createTextNode('+')); y2.appendChild(z2); w.insertBefore(y2,x.nextSibling); z3.href = 'http://en.wiktionary.org/w/index.php?title=' + pagenamee + '&action=purge'; z3.appendChild(document.createTextNode('P')); y3.appendChild(z3); w.insertBefore(y3,x.nextSibling); z4.href = 'http://tools.wikimedia.de/~cmackenzie/rnd-en-wikt.html'; z4.appendChild(document.createTextNode('$R')); y4.appendChild(z4); w.insertBefore(y4,x.nextSibling); } } }

if (document.title.indexOf("Editing ") == -1) { addOnloadHook(addEditSection0); }