User:ReedemBot/MassRollback.js

/* Make necessary changes and then paste into developer console and run */ var timestamp = "2018-06-19T05:30:00.000Z"; /* (UTC) Change this to time right before first edit*/ var username = "Username"; /* Change this to user whom you want to rollback */ var maxcontribs = 500; /* Change this to the maximum number of edits you want rolled back */ var summary = 'Automatic reversion of pages';

var pageIDs = []; var pageNames = [];

a = new mw.Api;

var i = 0;

function getChanges { a.get({action:"query",list:"usercontribs",uclimit:maxcontribs,ucend:timestamp,ucuser:username}).done(function (data) {       for (rev in data.query.usercontribs) {            revision = data.query.usercontribs[rev];            pageIDs.push(revision.pageid);            pageNames.push(revision.title);            console.log(revision.pageid);        }        rollbackEdits;        return;    }).fail(function (data) {        console.log("Failed to get revisions");        return;    }); }

function rollbackEdits { if (i == pageIDs.length) { console.log("Done!"); return; }   a.postWithToken("rollback",{action:"rollback",markbot:1,pageid:pageIDs[i],user:username,summary:summary}).done(function (data) {        i++;        rollbackEdits;        return;    }).fail(function (code, data) {        console.log("Page " + pageNames[i] + " failed, maybe because this user wasn't the most recent to edit. Reason given: " + code);        i++;        rollbackEdits;        return;    }); }

getChanges;