User:Northern Muriqui/rollbacksummary.js

/* 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('] ')); }       }    } } $(rollbackSummaryOnload);