User:BeamerFan/smart rollback.js

function smartRollback(editSummary) {	if(editSummary === null) {		return false; }	var userName = mw.config.get("wgRelevantUserName"); var titleRegex = /title=([^&]+)/; mw.loader.using( 'mediawiki.api' ).done( function	{		var api = new mw.Api;		$("a[href*='action=rollback']").each(function(ind, el) {			var params = {}; if( editSummary != '' ) {				params.summary = editSummary; }			api.rollback( decodeURIComponent(titleRegex.exec(el.href)[1]), userName, params).done( function			{				$(el).after("reverted");				$(el).remove;			} ); } );	} );	return false; } $(document).ready(function {	if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0)	{		mw.loader.using("mediawiki.util").done( function {			mw.util.addPortletLink('p-cactions', '#', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here"); $("#ca-rollbackeverything").click( function(event)			{				event.preventDefault;				mw.loader.load( 'mediawiki.api' ); 					return smartRollback(prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)"));			}); });	} });