User:Patrick/myskin.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

// install [[User:Cacycle/wikEd]] in-browser text editor
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//==============================================
// edit top link and row of links at the bottom
//==============================================

setTimeout("editTopLink()", 0) // this is equivalent of onload
function editTopLink() {

// if this is preview page or generated page, stop
if(document.getElementById("wikiPreview") || window.location.href.indexOf("w/index.php?title=Special:") != -1) return;

// get the page title
var pageTitle = document.title.split(" - ")[0].replace(" ", "_"); 

// create div and set innerHTML to link
var divContainer = document.createElement("div");
divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-top:3px;"><a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">edit top</a></div>';

var divContainer1 = document.createElement("div");
divContainer1.innerHTML = '<ul><li><a href="/wiki/Special%3AWhatlinkshere/'+pageTitle+'">what links here</a> <a href="/wiki/Special%3ARecentchangeslinked/'+pageTitle+'">rcl</a> - <a href="/w/index.php?title=Special%3AAllpages&namespace=0">m</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=1">t</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=2">u</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=3">ut</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=4">w</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=5">wt</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=6">i</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=7">it</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=8">mw</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=9">mwt</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=10">t</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=11">tt</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=12">h</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=13">ht</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=14">c</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=15">ct</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=100">p</a> <a href="/w/index.php?title=Special%3AAllpages&namespace=101">pt</a></li></ul>';

// insert divContainer into the Document Object Model (DOM) before the h1
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
document.getElementById("p-cactions").insertBefore(divContainer1, document.getElementsByTagName("h5")[0]);

}