User:Fleela/monobook.js: Difference between revisions

From Tolkien Gateway
mNo edit summary
mNo edit summary
Line 1: Line 1:
hookEvent("load", function ()
addOnloadHook(function(){
{
var h2s = document.getElementsByTagName('H2');
if(window.location.href.indexOf("/wiki/Special:") != -1) return;
var h2 = h2s[0];
if(document.getElementById("wikiPreview")) return;
if (!h2) return;
if(document.getElementById("histlegend‎")) return;
if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
if(document.getElementById("difference‎")) return;
if (!h2) return;
if(document.getElementById("watchdetails")) return;
var span = h2.firstChild;
if(document.getElementById("mainpage")) return;
if (!span || span.className != 'editsection') return;
 
var zero = span.cloneNode(true);
if(window.location.href.indexOf("&action=edit") == -1)
if (document.getElementById('featured-star')) zero.style.marginRight = '25px'
{
var parent = document.getElementsByTagName('H1')[0];
var pageTitle = document.title.split(" - ")[0].replace(" ", "_");
parent.insertBefore(zero, parent.firstChild);
var divContainer = document.createElement("div");
var a = zero.getElementsByTagName('A')[0];
divContainer.innerHTML = '<div class="editsection" style="float:right;">\
a.title = a.title.replace(/:.*$/,': 0');
[<a href="/w/index.php?title=' + pageTitle + '&action=edit&section=0" \
a.setAttribute('href', a.href.replace(/&section=1/,'&section=0'));
title="' + document.title.split(" - ")[0] + '">edit</a>]</div>';
})
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 */ ";
}
});

Revision as of 23:14, 17 June 2007

addOnloadHook(function(){
 var h2s = document.getElementsByTagName('H2');
 var h2 = h2s[0];
 if (!h2) return;
 if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
 if (!h2) return;
 var span = h2.firstChild;
 if (!span || span.className != 'editsection') return;
 var zero = span.cloneNode(true);
 if (document.getElementById('featured-star')) zero.style.marginRight = '25px'
 var parent = document.getElementsByTagName('H1')[0];
 parent.insertBefore(zero, parent.firstChild);
 var a = zero.getElementsByTagName('A')[0];
 a.title = a.title.replace(/:.*$/,': 0');
 a.setAttribute('href', a.href.replace(/&section=1/,'&section=0'));
})