User:Nx/Scripts/Addcomment.js
From RationalWiki
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
/* bottomedit Add an edit section link to the bottom of a section */ importScript('User:Nx/Scripts/Shared.js'); function bottomedit() { if (!(document.getElementById("ca-addsection"))) return; var bodyContent = document.getElementById("bodyContent"); var headings = getElementsByClassName(bodyContent,"*","mw-headline"); var i; var editsection2; var editsection; var j; var first; first = -1; for (i=0;i<headings.length && first < 0;++i) { if (headings[i].parentNode.parentNode == bodyContent) { first = i; } } j = first; for (i=first+1;i<headings.length;++i) { if (headings[i].parentNode.parentNode == bodyContent) { if (headings[j].parentNode.firstChild.className == "editsection") { editsection = headings[j].parentNode.firstChild.firstChild.nextSibling; editsection2 = document.createElement("span"); editsection2.innerHTML = "<a " + "href=\"" + editsection.getAttribute("href") + "\" title=\"" + editsection.getAttribute("title") + "\" >Add comment</a>" editsection2.className = "noprint"; bodyContent.insertBefore(editsection2,headings[i].parentNode); } j = i; } } if (first != -1) { if (headings[j].parentNode.firstChild.className == "editsection") { editsection = headings[j].parentNode.firstChild.firstChild.nextSibling; editsection2 = document.createElement("span"); editsection2.innerHTML = "<a " + "href=\"" + editsection.getAttribute("href") + "\" title=\"" + editsection.getAttribute("title") + "\" >Add comment</a>" editsection2.className = "noprint"; var asb = document.getElementById("addsectionbottom"); if (asb != null) { bodyContent.insertBefore(editsection2, asb); } else { var catlinks = document.getElementById("catlinks"); if (catlinks == null) { bodyContent.appendChild(editsection2); } else { bodyContent.insertBefore(editsection2, catlinks); } } } } } addOnloadHook(bottomedit);