MediaWiki:Gadget-rollback.js
Note: After saving, you have to bypass your browser's cache to see the changes. The simplest method that will work for most users is to hold down the ⇧ Shift key and click the Reload toolbar button. For details and other methods, see Help:Clear your browser cache.
/* global mw */
/* jshint strict:true, jquery:true, esversion:5, bitwise:true, curly:true, eqeqeq:true, undef:true, latedef:true, trailingcomma:true */
( function () {
'use strict';
/* Translation strings */
var i18n = {
msg: 'Are you sure you want to revert all consecutive edits made by the most recent editor? This should only be used to revert vandalism or erroneous bot edits.',
};
/*
* Confirm rollback with prompt
*/
function rollbackPrompt(e) {
if ( ! confirm(i18n.msg) ) {
e.preventDefault();
}
}
/* Fires when wiki content is added. */
mw.hook('wikipage.content').add( function ($wikipageContent) {
var links = document.querySelectorAll('.mw-rollback-link a');
if ( links.length > 0 ) {
for ( var i = 0; i < links.length; i++ ) {
var link = links[i];
link.addEventListener('click', rollbackPrompt);
}
}
} );
}() );