User:Abelmoschus Esculentus/MassRollback.js

// jQuery(document).ready(function ($) {	var test = 1;	function setup {		if (mw.config.get('wgCanonicalSpecialPageName') === "Contributions" && $.inArray(mw.config.get('wgUserGroups'), ["rollbacker", "sysop"])) {			$("#firstHeading").append(' [ Mass Rollback ] ');			$("#firstHeading").append(' [ Mass Rollback (S) ] ');			$("#mr-link").click(function { var confirmation = confirm("Perform mass rollback?"); if (confirmation === false) { return; }				SetAjaxRollback; rollbackEverything; });			$("#mr-link2").click(function { SetAjaxRollback2; rollbackEverything; });		}	}	function SetAjaxRollback {		$('span.mw-rollback-link').click(function(e) { e.preventDefault; var $rblink = $(this); var href = this.getElementsByTagName('a')[0].href; this.innerHTML = '';			$.ajax({				url: href,				success: function {					$rblink.text(function (i, val) {return val + '[reverted]';});					loadPageData;				},				error: function {					$rblink.text(function (i, val) {return val + '[rollback failed]';});					loadPageData;				}			}); });	}	function SetAjaxRollback2 {		var summary = prompt("Enter summary (leave blank will cancel the action)", "Reverted edits by $2 (talk) to last version by $1");		if (summary === null || summary === "") {			test = 0;			return;		}		$('span.mw-rollback-link').click(function(e) { e.preventDefault; var $rblink = $(this); var href = this.getElementsByTagName('a')[0].href; this.innerHTML = '';			$.ajax({				url: href.replace("?", "?summary=" + encodeURIComponent(summary) + "&"),				success: function {					$rblink.text(function (i, val) {return val + '[reverted]';});					loadPageData;				},				error: function {					$rblink.text(function (i, val) {return val + '[rollback failed]';});					loadPageData;				}			}); });	}	function rollbackEverything {		if (test === 0) {			return;		}		for (var i in document.links) {			if (document.links[i].href.indexOf('action=rollback') != -1) {				document.links[i].click;			}		}	}	mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.Title', 'mediawiki.RegExp'], function { setup; }); }); //