User:Northern Muriqui/rollbacksummary.js
Appearance
(Redirected from User:Lucas Thoms/rollbacksummary.js)
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Northern Muriqui/rollbacksummary. |
/* 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);