User:Voyagerfan5761/rollbacksummary.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.
/* This script adds a second rollback link on page histories, diff pages, and user contrib lists to ask for an edit summary via a prompt box. Thanks to Alex Smotrov's wlunwatch.js for some of the code! */ /* ******** STABLE ******** */ /* This script is fully functional, even if it does put links in odd places at times. */ importScript('User:Voyagerfan5761/rollbackbits.js'); function rollbackSummaryOnload() { var links = false; switch(RollbackBits.GetType()) { case 'hist': links = document.getElementById('pagehistory').getElementsByTagName('a'); break; case 'diff': links = document.getElementById('mw-diff-ntitle2').getElementsByTagName('a'); break; case 'trib': links = document.getElementById('bodyContent').getElementsByTagName('a'); break; } for(var linkid = links.length - 1; linkid >= 0; linkid--) { //append prompt links after rollback links if (links[linkid].href.match(/[?&]action=rollback[&]/)) { var rbsumm = links[linkid].cloneNode(false); rbsumm.onclick = RollbackBits.PromptForSummary; rbsumm.innerHTML = 'revert'; switch(RollbackBits.GetType()) { case 'hist': links[linkid].parentNode.appendChild(document.createTextNode(' | ')); links[linkid].parentNode.appendChild(rbsumm); break; case 'diff': case 'trib': links[linkid].parentNode.appendChild(document.createTextNode(' [')); links[linkid].parentNode.appendChild(rbsumm); links[linkid].parentNode.appendChild(document.createTextNode('] ')); } } } } addOnloadHook(rollbackSummaryOnload);