User:Ursuul/global.js

window.RevealAnonIP = { permissions : ['user'] };

if (mw.config.get("wgUserGroups").indexOf('bureaucrat') > -1) { massRenameDelay = 1000; // Optional massRenameSummary = 'automated'; // Optional massRedirectDelay = 1000; massBlockDelay = 1000; importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:MassCategorization/code.js',        'u:dev:MassRedirect/code.1.js',        'u:dev:MassProtect/code.js',        'u:dev:MediaWiki:MassRename/code.js',        'u:dev:MediaWiki:AnchoredRollback/code.js',        'u:dev:MassUserRights/code.js',        'u:dev:MediaWiki:MassBlock/code.js',        'u:dev:MassRenameRevert/code.js',        'u:dev:AutoEditPages/code.js'    ] }); }

if (mw.config.get("wgUserGroups").indexOf('sysop') > -1) { massRenameDelay = 1000; // Optional massRenameSummary = 'automated'; // Optional massRedirectDelay = 1000; massBlockDelay = 1000; importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:MassCategorization/code.js',        'u:dev:MassRedirect/code.1.js',        'u:dev:MassProtect/code.js',        'u:dev:MediaWiki:MassRename/code.js',        'u:dev:MediaWiki:AnchoredRollback/code.js',        'u:dev:MassUserRights/code.js',        'u:dev:MediaWiki:MassBlock/code.js',        'u:dev:MassRenameRevert/code.js',        'u:dev:AutoEditPages/code.js'    ] }); }

if (mw.config.get("wgUserGroups").indexOf('content-moderator') > -1) { importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:AnchoredRollback/code.js',        'u:dev:AutoEditPages/code.js'    ] }); }

if (mw.config.get("wgUserGroups").indexOf('rollback') > -1) { importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:AnchoredRollback/code.js'    ] }); }

//importScriptPage('YouTubeModal/code.js', 'dev');

importArticles({   type: 'script',    articles: [        "w:c:dev:RevealAnonIP/usercode.js",        'u:dev:MediaWiki:ContribsLink/code.js',        //'u:dev:MediaWiki:Rollback/code.js',        'u:dev:MarkBlocked.js',        'u:dev:Message/code.js',        'u:dev:MediaWiki:ViewRemoved/code.js',        'u:dev:MediaWiki:BlankBlogBugfix/code.js',        'u:dev:YouTubeModal/code.js',        'u:dev:PurgeButton/code.js',        'u:dev:AutoEditDropdown/code.js'    ] });

/* mw.loader.using('mediawiki.api', function { var main = {	init: function {		//check if conventional rollback links are present		if ($('.mw-rollback-link').length) return;		if (mw.config.get('wgAction') == "history" && $('#pagehistory li').length > 1) 			$('#pagehistory li:first .mw-history-undo a').before(' rollback | ');		else if (mw.config.get('wgCanonicalSpecialPageName') == "Contributions") {			$('#mw-content-text ul').find('li').each(function { if ($(this).find('.mw-uctop').length) $(this).append(' [rollback] '); });		}		else if (($.getUrlVar('diff') || $.getUrlVar('oldid')) && $('#differences-nextlink').length === 0)			$('.mw-usertoollinks:last').after('   [rollback] ');		$('.mw-custom-rollback-link a').click(function { main.getRevisionIdAndContent($(this).attr('data-id')); $(this).parent.remove; });	},	getRevisionIdAndContent: function(title) {		var API = new mw.Api;		API.get({ action: 'query', prop: 'revisions', titles: title, rvprop: 'user|ids', rvlimit: 500, cb: new Date.getTime })		.done(function(d) { if (!d.error) { var revisions; for (var i in d.query.pages) { revisions = d.query.pages[i].revisions; }				var currentUser = revisions[0].user, //current user rollbacking from lastUser, revId; for (var i in revisions) { if (revisions[i].user != currentUser) { lastUser = revisions[i].user; //remember last author revId = revisions[i].revid; //get revision to revert to						break; }				}				if (lastUser) { API.get({					action: 'query',					prop: 'revisions',					rvprop: 'content',					revids: revId,					cb: new Date.getTime					}) .done(function(d) {						if (!d.error) {							var content = ""; //can be no content on page so initialise empty as failsafe							for (var i in d.query.pages) {								if (d.query.pages[i].revisions)									content = d.query.pages[i].revisions[0]["*"];							}							main.performRollback(title,content,currentUser,lastUser);						}						else							new BannerNotification('Unable to rollback (failed to get page content): ' + d.error.code,'error').show;					}) .fail(function {						new BannerNotification('Unable to rollback: failed to get page content!','error').show;									}); }				else new BannerNotification('Unable to rollback: no different editor found!','error').show; }			else new BannerNotification('Unable to rollback (failed to get revisions): ' + d.error.code,'error').show; })		.fail(function { new BannerNotification('Unable to rollback: failed to get revisions!','error').show; });				},	performRollback: function(page,text,user,user2) {		var API = new mw.Api,		summary = 'Reverted edits by ' + user + ' (talk | block) to last version by ' + user2 + ' (script)';		API.post({ action: 'edit', title: page, text: text, summary: summary, token: mw.user.tokens.values.editToken })		.done(function(d) { if (!d.error) { new BannerNotification('Rollback successful!','confirm').show; }			else new BannerNotification('Unable to rollback (failed to publish edit): ' + d.error.code,'error').show; })		.fail(function { new BannerNotification('Unable to rollback: failed to publish edit!','error').show; });		} }; main.init; }); //////End Rollback
 * Rollback
 * Perform rollbacks without needing to be in the usergroup
 * @author Ozuzanna