Jump to content

User:Writ Keeper/Scripts/massRollback.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Writ Keeper (talk | contribs) at 23:03, 29 July 2015 (what happens if i do this?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
//Mass rollback function
//Written by John254 and modified/rewritten by Writ Keeper; original is at https://en.wikipedia.org/wiki/User:John254/mass_rollback.js
//Adapted from User:Mr.Z-man/rollbackSummary.js
//Instructions: Selecting the "rollback all" tab when viewing a user's contributions history
//will open all rollback links displayed there. (Use with caution)
  
function rollbackEverythingWKMR() 
{
	var userName = /Contributions\/(.+)/.exec(mw.config.get("wgTitle"))[1];
	var tokenRegex = /token=([^&]+)/;
	var titleRegex = /title=([^&]+)/;
	$("a[href*='action=rollback']").each(function(ind, el)
	{
		var regexResults = tokenRegex.exec(el.href);
		rollbackToken = decodeURIComponent(regexResults[1]);
		
		var postInfo = {action:"rollback",title:titleRegex.exec(el.href)[1],token:rollbackToken,user:userName,markbot:true};
		$.post("/w/api.php", postInfo, function()
		{
			$(el).after("reverted");
			$(el).remove();
		});
	});
}
$(document).ready(function()
{
	if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0)
	{
		addPortletLink('p-cactions', 'javascript:rollbackEverythingWKMR()', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
		$("#ca-rollbackeverything").click(function(){return confirm("Really rollback *everything*?")});
	}
});