User:Banarama/global.js

/////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /*************************** Modified Rollback ***************************/ /********************** Original Author — Ozuzanna ***********************/ /*************** @http://dev.wikia.com/wiki/User:Ozank_Cx ****************/ /*************************************************************************/ /////////////////////////////////////////////////////////////////////////// mw.loader.using('mediawiki.api', function { 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 = false;		for (var i in ownGroups) {			if (userGroups.indexOf(ownGroups[i]) !== -1) {				hasPermissionAlready = true;				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'));			$(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; API.post({		action: 'edit',		title: page,		text: text,		summary: 'Reverted edits by ' + user + ' (talk | block) to last version by ' + user2 + ' (script)',		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 MR*/

/////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /*************************************************************************/ /******************* RefreshButton (Purge AND Debug!) ********************/ /*************************************************************************/ /*************************************************************************/ /////////////////////////////////////////////////////////////////////////// /* jshint browser:true, jquery:true */ /* global mediaWiki */ require(['wikia.window', 'jquery', 'mw', 'ext.wikia.design-system.loading-spinner'], function(window, $, mw, Spinner) {   'use strict';

var config = mw.config.get([       'skin',        'wgNamespaceNumber'    ]), $button, spinnerHTML = new Spinner(38, 2).html.replace('wds-block', 'wds-spinner__block').replace('wds-path', 'wds-spinner__stroke');

if (config.wgNamespaceNumber < 0 || window.PurgeButtonsLoaded || $('#control_purge').exists) { return; }   window.PurgeButtonsLoaded = true; // prevent duplicate running (but not dupe buttons from outside this code)

if (!window.dev || !window.dev.i18n) { importArticle({           type: 'script',            article: 'u:dev:MediaWiki:I18n-js/code.js'        }); }

function purgePage { $.get('?action=purge&debug=true', function {           location.reload(true);        }); $('html, body').css({           overflow: 'hidden',            display: 'block'        }); $(' ').css({           background: 'rgba(255, 255, 255, 0.5)',            position: 'fixed',            height: '100%',            width: '100%',            left: '0',            top: '0',            'z-index': '1000000000'        }).html(spinnerHTML).appendTo(document.body); }

function addOasisPurgeButton { switch (config.wgNamespaceNumber) { case 500: case 502: // Blog namespaces $('.page-header__contribution-buttons').append($button.addClass('wds-button wds-is-squished wds-is-secondary')); break; default: // .UserProfileActionButton is for root user pages (they don't use new page header yet) $('.UserProfileActionButton .wikia-menu-button .WikiaMenuElement, .page-header__contribution-buttons .wds-list').first .append($('').append($button)); }   }

function addPurgeButton(i18n) { i18n.useUserLang; $button = $('', {           'class': 'custom-purge-button',            href: '#',            title: i18n.msg('purge').plain,            text: window.PurgeButtonText || i18n.msg('refresh').plain        }).click(purgePage); switch(config.skin) { case 'uncyclopedia': case 'monobook': $('#p-cactions > .pBody > ul').append($('', { id: 'ca-purge' }).append($button)); break; case 'oasis': case 'wikia': addOasisPurgeButton; break; }   }

mw.hook('dev.i18n').add(function(i18no) {       i18no.loadMessages('PurgeButton').then(addPurgeButton);    }); });//End RB*/ /////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /***************************** Miscellaneous *****************************/ /*************************************************************************/ /////////////////////////////////////////////////////////////////////////// /* Rail Priority */ $(function { mw.hook('DiscordIntegrator.added').add(function {       $('.DiscordIntegratorModule').appendTo('#WikiaRail');    }); });//End RP*/ /* Stop Signature Check */ if (window.WikiaEditor && window.GlobalTriggers) {   window.GlobalTriggers.bind('WikiaEditorReady', function callback { window.GlobalTriggers.unbind('WikiaEditorReady', callback); window.setTimeout(function {           $('#wpSave').closest('form').off('submit.CheckSignature');        }, 0); }); }//End SSC*/ /////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /************************* Import Configurations *************************/ /*************************************************************************/ /////////////////////////////////////////////////////////////////////////// /* Ajax Delete */ window.AjaxDelete = {   deleteReasons: {        'Housekeeping': 'Housekeeping',        'Marked for deletion': 'Marked for deletion',        'Author request': 'Author request',        'Empty page': 'Empty',        'Irrelevant to Diep.io': 'Irrelevant',        'Broken Redirect': 'Broken Redirect',        'Help:Vandalism': 'Vandalism',        'Help:Spam': 'Spam',        'Other': 'Other'    },    imageDeleteReasons: {        'Innapropiate': 'Innapropiate',        'Harassment': 'Harassment', 'Housekeeping/Unused': 'Housekeeping', 'Copyright infringement': 'Copyright', 'Author request': 'Author request', 'Refuse Image': 'Refuse Image' },   autoCheckWatch: true, noUndelete: false };//End AD*/ /* Back to Top Button * window.BackToTopSpeed = 1500; window.BackToTopStart = 400;//End BtTB*/ /* Talk Notifications */ window.talkWikis = ['diepio', 'zh.diepio', 'rings-of-the-master'/*, 'dresdenfiles', 'es.diepio', 'ru.diepio', 'fr.diepio', 'tr.diepio', 'pl.diepio', 'pt-br.diepio', 'ko.diepio', 'ja.diepio', 'hu.diepio', 'diepio-conception', 'lightbringer-series', 'community', 'portability', 'communitycouncil', 'cohdev', 'mopeio', 'es.mopeio', 'fr.mopeio', 'pl.mopeio', 'ru.mopeio', 'doblonsio', 'ru.doblonsio', 'deeeep-io', 'pl.deeeep-io', 'geometry-dash', 'tbacontest', 'fallout', 'rezero', 'hordesio', 'blocksio', 'orange-io', 'shadowofmordor', 'bloonsconception', 'team-of-cool-peeps', 'cohdev2', 'town-of-salem', 'mithermages', 'slitherio', 'agario', 'psychokid', 'tes-mods', 'cinder-spires', 'steven-universe', 'spookys-house-of-jump-scares', 'warmetal', 'onceuponatime', 'hillclimbracing', 'driftinio', 'kurofox', 'extreme-test', 'totmgsrocks-creatures-and-stuff', 'the-outstanding-remarkable-robotguy39', 'vstf', 'subnautica-concept'*/]; //window.talkName = 'Talk';//End TN*/ /* Cache Check */ window.cacheSkip = []; window.cacheSkipLimit = 1000; window.topLevelCat = '';//End CC*/ /* Skin Switch */ window.monoBookText = "Switch to Monobook"; window.oasisText = "Switch to Oasis"; window.mobileText = "Switch to Mercury";//End SS*/ /* RevealAnonIP */ window.RevealAnonIP = { permissions : ['user'] };//End RAIP*/ /* Mass Effect Configs */ batchDeleteDelay = 250; nukeDeleteReason = "Cleanup (Nuke Script)"; massRenameDelay = 500; massRenameSummary = 'Automatic Process'; massRedirectDelay = 500; massBlockDelay = 500; WHAMDelay = 1000; //End MEC*/

/* AjaxRC */ window.ajaxSpecialPages = ["Recentchanges", "WikiActivity", "Watchlist", "Log", "Contributions"]; window.ajaxIndicator = 'http://slot1.images.wikia.nocookie.net/__cb1468579810/common/skins/common/images/ajax.gif'; window.ajaxRefresh = 30000; window.AjaxRCRefreshText = 'Auto refresh'; window.AjaxRCRefreshHoverText = 'Automatically refresh the page';

/* WHAM! */ WHAMDelay = 1000

/* MultipleFileDelete */ window.mfdExclude = [ 'Allpages' ];

/* RailWAM */ window.railWAM = { logPage: 'Project:WAM Log', loadOnPage: 'Special:WikiActivity', };

/* GlobalNavButtons */ var globalNavButtons = [ {   text: 'DIEP.IO', url: 'https://diepio.wikia.com', isMain: true, whoIsMain: false, shortName: 'diep' }, {    text: 'Recent Changes', url: 'https://diepio.wikia.com/wiki/Special:RecentChanges', isMain: false, whoIsMain: 'diep', shortName: 'rc1' }, {    text: 'MediaWiki:Wikia.css', url: 'https://diepio.wikia.com/wiki/MediaWiki:Wikia.css', isMain: false, whoIsMain: 'diep', shortName: 'css' }, {    text: 'CR', url: 'https://clashroyale.wikia.com', isMain: true, whoIsMain: false, shortName: 'cr' }, {    text: 'Recent Changes', url: 'https://clashroyale.wikia.com/wiki/Special:RecentChanges', isMain: false, whoIsMain: 'cr', shortName: 'rc2' }, {    text: 'Card Overviews', url: 'https://clashroyale.wikia.com/wiki/Card Overviews', isMain: false, whoIsMain: 'cr', shortName: 'cards' }, {    text: 'DEV', url: '', isMain: true, whoIsMain: false, shortName: 'dev' }, {    text: 'Recent Changes', url: 'https://dev.wikia.com/wiki/Special:RecentChanges', isMain: false, whoIsMain: 'dev', shortName: 'rc3' }, {    text: 'BlendGlobalNav', url: 'https://dev.wikia.com/wiki/MediaWiki:BlendGlobalNav.css', isMain: false, whoIsMain: 'dev', shortName: 'bgn' }, {    text: 'CC', url: 'https://c.wikia.com', isMain: false, whoIsMain: false, shortName: 'c' }, {   text: 'COUNCIL', url: 'https://cc.wikia.com', isMain: false, whoIsMain: false, shortName: 'cc' } ];

/////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /******************************** Imports ********************************/ /*************************************************************************/ /////////////////////////////////////////////////////////////////////////// /* If Admin */ if (mw.config.get("wgUserGroups").indexOf('sysop') > -1) { importArticles({       type: 'script',        articles: [            'u:dev:MediaWiki:!kick/code.js',            'u:dev:MassCategorization/code.js',            'u:dev:MassRedirect/code.1.js',            'u:dev:MassProtect/code.js',            'u:dev:MassRename/code.js',            'u:dev:MassEdit/code.js',            'u:dev:AnchoredRollback/code.js',            'u:dev:MassUserRights/code.js',            'u:dev:MassBlock/code.js',            'u:dev:MassRenameRevert/code.js',            'u:dev:MultipleFileDelete/code.js',            'u:dev:AutoEditPages/code.js',            'u:dev:RedirectManagement/code.js',            'u:dev:Nuke/code.js',            'u:dev:AjaxBatchDelete/code.js',            'u:dev:LastEdited/code.js',            'u:dev:PageRenameAuto-update/code.js',            //'u:dev:AjaxDelete/code.js'        ]    }); }//End IA*/ /* If Content Mod */ if (mw.config.get("wgUserGroups").indexOf('content-moderator') > -1) { importArticles({       type: 'script',        articles: [            'u:dev:MassCategorization/code.js',            'u:dev:MassRedirect/code.1.js',            'u:dev:MassProtect/code.js',            'u:dev:MassRename/code.js',            'u:dev:MassEdit/code.js',            'u:dev:AnchoredRollback/code.js',            'u:dev:MassRenameRevert/code.js',            'u:dev:MultipleFileDelete/code.js',            'u:dev:AutoEditPages/code.js',            'u:dev:RedirectManagement/code.js',            'u:dev:Nuke/code.js',            'u:dev:AjaxBatchDelete/code.js',            'u:dev:LastEdited/code.js',            'u:dev:PageRenameAuto-update/code.js',            'u:dev:AjaxDelete/code.js',        ]    }); }//End IfConMod*/ /* If Rollback */ if (mw.config.get("wgUserGroups").indexOf('rollback') > -1) { importArticles({       type: 'script',        articles: [            'u:dev:MassCategorization/code.js',            'u:dev:LastEdited/code.js',            'u:dev:AnchoredRollback/code.js'        ]    }); }//End IR*/ /* If Disc Mod */ if (mw.config.get("wgUserGroups").indexOf('threadmoderator') > -1) { importArticles({       type: 'script',        articles: [            'u:dev:LastEdited/code.js',            'u:dev:!mods/code.js'        ]    }); }//End IDM*/ /* If Chat Mod */ if (mw.config.get("wgUserGroups").indexOf('chatmoderator') > -1) { importArticles({       type: 'script',        articles: [            'u:dev:LastEdited/code.js',            'u:dev:!mods/code.js',            'u:dev:!kick/code.js',            'u:dev:MediaWiki:!kick/code.js'        ]    }); }//End ICM*/ /* Universal Imports */ importArticles({   type: 'script',    articles: [        'u:dev:AjaxDiff/code.js',        'u:dev:AjaxRC/code.js',        'u:dev:AjaxRedirect/code.js',        'u:dev:AjaxUndo/code.js',        'u:dev:AllPagesHideRedirect/code.js',        'u:dev:AntiSoundcloud/code.js',        'u:dev:AutoEditDropdown/code.js',        'u:dev:BlankBlogBugfix/code.js',        'u:dev:BlogLink/code.js',        'u:dev:CacheCheck/code.js',        'u:dev:CodeQuickLinks/code.js',        'u:dev:DisableCode/code.js',        'u:dev:DiscussionsFeed.js',        'u:dev:EditBio/code.js',        'u:dev:MediaWiki:FANSUN.js',        'u:dev:FindAndReplace/code.js',        'u:dev:Flags/code.js',        'u:dev:GlobalChatJS.js',        'u:dev:MediaWiki:GlobalNavButtons.js',        'u:dev:MarkBlocked.js',        'u:dev:NullEditButton/code.js',        'u:dev:PortableCSSPad/code.js',        'u:dev:RTCL.js',        'u:dev:RailWAM/code.js', 'u:dev:ReferencePopups/code.js', 'u:dev:RevealAnonIP/usercode.js', 'u:dev:SearchSuggest/code.js', 'u:dev:SeeMoreActivityButton/code.js', 'u:dev:ShowUserGroups.js', 'u:dev:SkinSwitchButton/code.js', 'u:dev:MediaWiki:UnhideUserMasthead/code.js', 'u:dev:UnsafeScripts/code.js', 'u:dev:UserAccountAge/code.js', 'u:dev:UserActivityTab/code.js', 'u:dev:UserCheck/code.js', 'u:dev:UsernameAvailability/code.js', 'u:dev:UserRightsRecord/code.js', 'u:dev:UserTalkNotifications/code.js', 'u:dev:WallGreetingButton/code.js', 'u:dev:WHAM/code.2.js', 'u:dev:WorkingMoreUsersCount.js', 'u:diepio:BackToThread/code.js', 'u:diepio:Miscellaneous/code.js', 'u:kocka:VSTFReport/code.js', 'u:dev:MediaWiki:ViewRemoved/code.js', 'u:dev:YouTubeModal/code.js', "u:dev:JWB/code.js", 'u:dev:FandomizedChat/core.js', 'u:dev:PageCreator/code2.js', 'u:dev:Message/code.js', //'u:dev:GlobalChatJS.js', //'u:dev:MarkForDeletion/code.js', //'u:dev:ToggleSideBar/code.js' ] });//End UI*/