// User:Quarl/edit_top_link.js
// requires: wikipage.js
// based on http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Add_Edit_Top_Link
// This will add an [edit top] link at the top of all pages except preview pages
// by User:Pile0nades
function editTopLink() {
// if this is preview page or generated page, stop
if (previewP || wikiPage.nsSpecialP) return;
// get the page title
var pageTitle = wikiPage.page;
var editURL = wikiPage.qurl + '&action=edit§ion=0';
// 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="'+editURL+' title="'+pageTitle+'">edit top</a>]</div>';
// insert divContainer into the DOM before the h1
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}
addOnloadHook(editTopLink);