User:Golfpecks256/global.js

/* Use Rollback anywhere */ var main = { init: function { //check if user has rollback permission already var userGroups = ["rollback","content-moderator","sysop","vstf","helper","staff"], ownGroups = mw.config.get('wgUserGroups'), hasPermissionAlready = true; for (var i in ownGroups) { if (userGroups.indexOf(ownGroups[i]) !== -1) { hasPermissionAlready = false; break; }		}		if (hasPermissionAlready) 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'));		}); },	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; API.post({		action: 'edit',		title: page,		text: text,		summary: 'Reverted edits by ' + user + ' (talk | block) to last version by ' + user2 + '',		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; }) (this.jQuery, this.mediaWiki); importScriptPage('MediaWiki:MassRenameRevert/code.js', 'dev'); importArticles({ type: 'script', articles: [ 'u:dev:FileUsageAuto-update/code.js', ] }); window.AutoCreateUserPagesConfig = {   content: {        2: ,        3: ,        1202: ''    },    summary: 'automatically creating user page for: Golfpecks256' };
 * (function($, mw) {

window.qtEnableUserPageOverwrite = true; importArticles({   type: 'script',    articles: [            'u:dev:AbuseLogRC.js',            'u:dev:Message/code.js',            'u:dev:RevertOldGlobalNav/code.js',            'u:dev:FixRemoveMastheadFields.js',            'u:kocka:AjaxCommentDelete/code.js',            'u:kocka:AjaxThreadDelete/code.js',            'u:dev:QuickCreateUserPage/code.js',            'u:dev:AjaxBatchDelete/code.2.js',            'u:dev:VSTFReport.js',            'u:dev:AdminDashboard JS-Button/code.js',            'u:dev:PortableCSSPad/code.js',            'u:dev:ProtectionIcons.js',            'u:dev:CommentPreview/code.js',            'u:dev:AjaxBlock/code.js',            'u:dev:AjaxRC/code.js',            'u:dev:AjaxRename/code.js',            'u:dev:AjaxThreadDelete/code.js',            'u:dev:AjaxUndo/code.js',            'u:dev:AnchoredRollback/code.js',            'u:dev:GlobalChatJS.js',            'u:dev:ContribsLinck/code.js', 'u:dev:DiscussionsFeed.js', 'u:dev:DiscussionsRailModule/code.js', 'u:dev:EditConflictAlert/code.js', 'u:dev:FindAndReplace/code.js', 'u:dev:MarkForDeletion/code.js', 'u:dev:MassEdit/code.js', 'u:dev:MassBlock/code.js', 'u:dev:MassCategorization/code.js', 'u:dev:MassCreate/code.js', 'u:dev:MassRename/code.js', 'u:dev:MassUserRights/code.js', 'u:dev:AjaxThreadDelete/code.js', 'u:dev:GlobalEditcount/code.js', 'u:dev:Nuke/code.js', 'u:dev:RailWAM/code.js', 'u:dev:RedirectManagement/code.js', 'u:dev:RevealAnonIP/code.js', 'u:dev:UserCheck/code.js', 'u:dev:UTCClock/code.js', 'u:dev:ViewRemoved/code.js', 'u:dev:WorkingMoreUsersCount.js', 'u:dev:MessageBlock/code.js', 'u:dev:QuickDelete/code.js', 'u:dev:QuickDiff/code.js', 'u:dev:Rollback/code.js', 'u:dev:Sine/code.js', 'u:dev:UserAccountAge/code2.js', 'u:dev:UsernameAvailability/code.js', 'u:dev:VSTF Report Menu/code.js', 'u:dev:ViewDeleted/code.js', ] });