MediaWiki:Gadget-edittop.js
From Meta, a Wikimedia project coordination wiki
Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences.
function edittop() { // This will add an [edit] link at the top of all pages except preview pages and the main page if (wgNamespaceNumber < 0) return; if (wgAction == "edit") { var section = get_query_value(window.location.href, "section"); if (section == "0") { document.getElementById("wpSummary").value = "/* Intro */ "; } } else { //un-hide siteSub if it's hidden appendCSS('#siteSub {display:block !important;}'); // create span and set innerHTML to link var sectionZero = document.createElement('span'); sectionZero.setAttribute('class','editsection'); var a = document.createElement("a"); a.href = wgScript+'?title='+ encodeURIComponent(wgPageName)+'&action=edit§ion=0'; a.title = 'Edit section: Intro'; a.appendChild(document.createTextNode("edit")); sectionZero.appendChild(document.createTextNode("[")); sectionZero.appendChild(a); sectionZero.appendChild(document.createTextNode("]")); // insert sectionZero into the DOM before the first level 1 heading document.getElementById('siteSub').insertBefore(sectionZero,document.getElementById('siteSub').firstChild); } } if ( wgAction == "view" || wgAction == "purge" || wgAction == "edit" ) addOnloadHook(edittop); // [[Category:Gadgets|Edittop.js]]