User:Fleela/monobook.js: Difference between revisions

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

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 = '<div class="editsection" style="float:right;">\
[<a href="/w/index.php?title=' + pageTitle + '&action=edit&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 */ ";
	}
});