Jump to content

User:Greg Tyler/rollbackprompt.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// This script generates a little popup box when the user clicks on the "rollback" button, checking
// that they definitely want to rollback, and didn't click the button by mistake.

// Rather than executing immediately, we'll wait until the page has finished loading.
addEventListener('DOMContentLoaded',function() {
// Now we'll search for all the "span" tags, looking for the ones in the "mw-rollback-link" class
d = document.getElementsByTagName('span');
for(i=0;i<d.length;i++) {
// Found them! This changes the onClick action to show a confirmation box.
    if(d[i].className.indexOf("mw-rollback-link") >= 0) d[i].getElementsByTagName('a')[0].onclick=function() {if(!confirm('Are you sure you want to do a rollback?')) return false;};
}
}, false);