User:Ursuul/global.js

/////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /*************************** Modified Rollback ***************************/ /*********************** Original Author: Ozuzanna ***********************/ /************ @http://dev.wikia.com/wiki/User_Talk: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*/

/////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /************************* Discussion Bio Import *************************/ /********************** Original Author: Flightmare **********************/ /********* @http://elderscrolls.wikia.com/wiki/User:Flightmare ***********/ /*************************************************************************/ /////////////////////////////////////////////////////////////////////////// $( document ).ready(function {   //Test page for masthead and link to discussions profile and check for double loads    if($('#discussion-bio').length === 0 && $('#UserProfileMasthead #discussionAllPostsByUser').attr('href')) {        var userId = $('#UserProfileMasthead #discussionAllPostsByUser').attr('href').split('/')[3];        //Fetch bio        $.ajax({ type: 'GET', url: 'https://services.wikia.com/user-attribute/user/' + userId + '/attr/bio', success: function(data) { //Create new masthead entry $('.UserProfileMasthead .details').append(' BIO ' + data.value.replace(/(?:\r\n|\r|\n)/g, ' ') + ''); //Add expand toggle button if overflow happens if($('#discussion-bio').prop('scrollHeight') > $('#discussion-bio').outerHeight) { $('#discussion-bio').after(' [Read more] '); $('#discussion-bio-toggle').click(function {                       if($('#discussion-bio').css('max-height') == '100px' ) {                            $('#discussion-bio').css('max-height', 'inherit');                            $('#discussion-bio-toggle').text('[Read less]');                        } else {                            $('#discussion-bio').css('max-height', '100px');                            $('#discussion-bio-toggle').text('[Read more]');                        }                    }); }           }        });    } });//End*/

/////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /***************************** Miscellaneous *****************************/ /*************************************************************************/ /////////////////////////////////////////////////////////////////////////// /* Make Collapsible Infobox sections closed by default * $(function {   if ($('.portable-infobox').length === 0) {        return;    }    if ($('.portable-infobox section').hasClass('pi-collapse-open')) {        $('.portable-infobox section').removeClass('pi-collapse-open').addClass('pi-collapse-closed');        return;    } });//End CI*/

/* 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: { 'Help:Vandalism': 'Vandalism', 'Help:Spam': 'Spam', 'Marked for deletion': 'Marked for deletion', 'Empty page': 'Empty', 'Author request': 'Author request', 'Irrelevant to Diep.io': 'Irrelevant' },   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']; //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*/

/* Quick Delete Options */ window.fdButtons = []; window.fdButtons.push(   {        summary: 'Housekeeping',        label: 'HK'    },    {        summary: 'Vandalism',        label: 'V'    },    {        summary: 'Spam',        label: 'S'    } );//End QDO*/

/* Mass Effect Configs */ batchDeleteDelay = 250; nukeDeleteReason = "Cleanup (Nuke Script)"; massRenameDelay = 500; massRenameSummary = 'Automatic Process'; massRedirectDelay = 500; massBlockDelay = 500; //End MEC*/

/////////////////////////////////////////////////////////////////////////// /*************************************************************************/ /******************************** Imports ********************************/ /*************************************************************************/ /////////////////////////////////////////////////////////////////////////// /* If Admin */ if (mw.config.get("wgUserGroups").indexOf('sysop') > -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: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',            'u:kocka:AjaxThreadDelete/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: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 ICM*/

/* If Rollback */ if (mw.config.get("wgUserGroups").indexOf('rollback') > -1) { importArticles({       type: 'script',        articles: [            '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 IR*/

/* If Chat Mod Mod */ if (mw.config.get("wgUserGroups").indexOf('chatmoderator') > -1) { importArticles({       type: 'script',        articles: [            'u:dev:LastEdited/code.js',            'u:dev:!mods/code.js'        ]    }); }//End IR*/

/* Universal Imports */ importArticles({   type: 'script',    articles: [        'u:kocka:VSTFReport/code.js',        'u:cohdev:User:Count_of_Howard/MUUW.coh',        'u:dev:CodeQuickLinks/code.js',        'u:dev:BlogLink/code.js',        'u:dev:QuickToolsv2/code.js',        'u:dev:WallGreetingButton/code.js',        'u:dev:RevealAnonIP/usercode.js',        'u:dev:MarkBlocked.js',        'u:dev:BlankBlogBugfix/code.js',        'u:dev:YouTubeModal/code.js',        'u:dev:AutoEditDropdown/code.js',        'u:dev:UsernameAvailability/code.js',        'u:dev:SkinSwitchButton/code.js',        'u:dev:FastDelete/code.js',        'u:dev:AjaxRedirect/code.js',        'u:dev:CacheCheck/code.js',        'u:dev:AllPagesHideRedirect/code.js',        'u:dev:UserTalkNotifications/code.js',        'u:dev:DiscussionsFeed.js',        'u:dev:PortableCSSPad/code.js',        'u:dev:AntiSoundcloud/code.js',        'u:dev:SearchSuggest/code.js', 'u:dev:ReferencePopups/code.js', 'u:dev:AjaxUndo/code.js', 'u:dev:BackToTopButton/code.js', 'u:dev:MarkForDeletion/code.js', 'u:dev:UserActivityTab/code.js', 'u:dev:Flags/code.js', 'u:dev:ViewRemoved/code.js', //'u:dev:ViewRemovedAlways/code.js', 'u:dev:NullEditButton/code.js', //'u:dev:ToggleSideBar/code.js', //'u:dev:GlobalChatJS.js   ] });//End UI*/