User:Technical 13/MRollback.js
Appearance
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:Technical 13/MRollback. |
/* global mw:true, Flash:true */
/**
* Mass Rollback Script
*
* Creates a form to mass rollback edits
*
* @author Kangaroopower
* @credits Ale_jrb (UI)
*
* From: [[User:Kangaroopower/Scripts]]
*
* To Do :
* - From what time
*
*/
$(function () {
importScript('User:Kangaroopower/Flash.js');
window.MRollback = {
version: "2.22",
active: false,
GUI: {}
};
var MRollback = window.MRollback;
MRollback.init = function () {
if ( mw.config.get('wgCanonicalSpecialPageName') === "Contributions" && $.inArray( mw.config.get('wgUserGroups'), ["reviewer", "rollbacker", "sysop"]) ) {
mw.util.addPortletLink('p-cactions', 'javascript:MRollback.GUI.initiate();', "Mrollback", "ca-mrollback", "Mass Rollback");
}
};
/* GUI Module */
MRollback.GUI.initiate = function () {
if (MRollback.active !== true) {
MRollback.active = true;
var popupHTML = '<div id="mr-ui" style="display: none; z-index: 1000; background-color: #FFDBDB; padding: 4px; border: 1px solid #BB7070; border-radius: 6px; text-align: left; font-size: 11px; color: black; display: block; position: absolute; top: 200px; left: 500px;" class="ui-draggable"><form action="#" method="get"><div style="font-weight: bold; border-bottom: 1px solid #AAA; padding: 4px;"><span id="mr-title">Mass Rollback</span><span style="float: right; text-transform: none;"><a id="mr-close" style="cursor: pointer" onclick="MRollback.GUI.close();"><img src="/media/wikipedia/commons/b/b6/Chrome_close_button.png"/></a></span></div><div><div style="display: inline-block; padding: 4px; vertical-align: middle;"><div style="margin: 4px auto;"><div style="display: inline-block; width: 4em; margin-right: 10px;">Summary:</div><textarea id="mr-sum" width="128" rows="2"></textarea></div><div style="margin: 4px auto;"><div style="display: inline-block; width: 4em;">How many:</div><input id="mr-limit" value="25" max="500" size="3" pattern="[\d]{1,3}" title="1-999" type="text" autocomplete="off" style="background-color: #FF0;" /><input id="mr-some" style="width: 100px; font-size: 12px; margin-bottom: 4px; background-color: #FFFFBD;" type="button" value="Rollback\nSome" /><input id="mr-all" style="width: 100px; font-size: 12px; margin-bottom: 4px; background-color: #DDACAC;" type="button" value="Rollback\nAll" /></div></div></div></form></div>';
$('body').append(popupHTML);
$('#mr-ui').show();
$('#mr-ui').draggable();
$("#mr-all").click(function () {
MRollback.rollback(true);
});
$("#mr-some").click(MRollback.rollback);
}
};
MRollback.GUI.close = function () {
if (MRollback.active !== false) {
MRollback.active = false;
$('#mr-ui').hide();
}
};
/* API functions */
MRollback.rollback = function (all) {
var mrlimit = $('#mr-limit').val(), rbcontribs = 0;
if (all === true) {
mrlimit = 500;
} else {
if (mrlimit !== '' && /^\d+$/.test(mrlimit)) mrlimit = parseInt(mrlimit, 10);
else return;
}
var ucuser = encodeURIComponent($('#contentSub a:first').html());
Flash('getUserContribs').load({number: mrlimit, user: ucuser}).wait(function (data) {
for(var i in data.query.usercontribs) {
if(data.query.usercontribs[i].top == '') {
var rbsummary = $('#mr-sum').val(),
latestcontribs = data.query.usercontribs[i].title;
console.log("Latest Contribs:" + latestcontribs);
Flash('rollback').load({targ: latestcontribs, user: ucuser, summary: rbsummary}).wait(function () {
rbcontribs++
console.log("rbcontribs:" + rbcontribs);
}).run();
}
}
}).run();
};
$(document).ready(MRollback.init);
});