User:Quarl/edit top link.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
// 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);

