User:Pirr/global.js

require( [   'jquery',    'mw',    'wikia.window' ], function( $, mw, window ) {    // wgVariables    var config = mw.config.get( [ 'wgTrackID', 'wgContentLanguage', 'wgUserLanguage', 'wgUserGroups', 'wgUserName', 'wgSiteName' ] );   // Run restrictions    if ( config.wgTrackID !== 33612736 || window.GlobalJSLoaded ) return;    window.GlobalJSLoaded = true;    // Smart configuration of my importArticles statement    window.importScripts = {        userImports: [ // Import this array everywhere I go            'u:dev:MediaWiki:AjaxUndo/code.js',            'u:dev:MediaWiki:AjaxRC/code.js',            'u:dev:MediaWiki:ConsistentNotifications.js',            'u:dev:MediaWiki:NullEditButton/code.js',            'u:dev:MediaWiki:MultiUpload/code.js',             'u:dev:MediaWiki:RevealAnonIP/usercode.js',            'u:dev:MediaWiki:UnhideUserMasthead/code.js',            'u:dev:MediaWiki:View Source/code.js',            'u:dev:MediaWiki:LastEdited/code.js',            'u:dev:MediaWiki:QuickCreateUserPage/code.js',            'u:dev:MediaWiki:UnsafeScripts/code.js',            'u:dev:MediaWiki:SearchSuggest/code.js', 'u:dev:MediaWiki:DiscussionsViewer/code.js', 'u:dev:MediaWiki:FixPolishMonths.js', 'u:dev:MediaWiki:AnnouncementsIgnore.js', 'u:dev:MediaWiki:FindAndReplace/code.js', 'u:dev:MediaWiki:MobileEditor.js', 'u:dev:MediaWiki:ChromeToolbarColor.js', 'u:kocka:MediaWiki:ReportFormatter.js', 'u:rail-sandbox:MediaWiki:StalkerScript.js' ],       sysopImports: [ // Import only on wikis where I'm sysop 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:AjaxBatchDelete.js', 'u:dev:MediaWiki:AjaxPatrol/code.js', 'u:dev:MediaWiki:Discussions Delete All/code.js', 'u:dev:MediaWiki:AjaxCommentDelete/code.js', 'u:dev:MediaWiki:ViewRemoved/code.js', 'u:dev:MediaWiki:CategoryRenameAuto-update/code.js', 'u:dev:MediaWiki:FileUsageAuto-update/code.js' ]   };    // Use different summaries on language wikis window.actionSummaries = { en: { // English (en) deleteSummary: 'Housekeeping', blockSummary: 'Vandalism', commentDeleteSummary: 'Harmful comment', fileUpdateSummary: 'Auto-update of file names' },       pl: { // polski (pl) deleteSummary: 'Porządki', blockSummary: 'Wandalizm', commentDeleteSummary: 'Obraźliwy komentarz', fileUpdateSummary: 'Automatyczna aktualizacja nazw plików' }   };    window.actionSummaries = $.extend(        window.actionSummaries.en,        window.actionSummaries[config.wgContentLanguage]    ); // AjaxRC special pages window.ajaxSpecialPages = [ 'Recentchanges', 'Images', 'Videos', 'Watchlist', 'Newwikis', 'Log', 'NewPages', 'Wikiactivity' ];   // AnnouncementsIgnore configuration window.announcementsIgnore = { option: 'opt-out-all', exceptWikiIds: [ // wikia.php?controller=WikisApi&method=getDetails&ids= 7931,  // Dev Wiki 177,   // Community Central 1686,  // Centrum Społeczności ]   };    // Other minor configs window.ajaxRefresh = 15000; window.MultiUploadoption = { max: 75 }; window.lastEdited = { avatar: false }; window.qtUserPageTemplate = ''; window.WHAMDeleteReason = window.actionSummaries.deleteSummary; window.WHAMBlockReason = window.actionSummaries.blockSummary; window.AjaxCommentDeleteConfig = window.actionSummaries.commentDeleteSummary; LIRoptions = { editSummary: window.actionSummaries.fileUpdateSummary }; // Combine import arrays depending on user groups var importThis = ( /sysop|content-moderator|threadmoderator|bureaucrat/.test( config.wgUserGroups.join ) ? window.importScripts.userImports.concat( window.importScripts.sysopImports ) : window.importScripts.userImports ); // Wowee. Let's use combined array to import everything in one request importArticles( {       type: 'script',        articles: importThis    } ); // Other snippets mw.loader.using( 'mediawiki.util', function {       // Simple i18n system        var i18n = {            en: { // English (en)                'contribs': 'Contribs',                'recentchanges': 'Recent changes',                'blog': 'Blogs',                'global-nav-admins': 'Admins',                'global-nav-staff': 'Staff',            },            pl: { // polski (pl)                'contribs': 'Wkład',                'recentchanges': 'Ostatnie zmiany',                'blog': 'Blogi',                'global-nav-admins': 'Admini',                'global-nav-staff': 'Staff',            }        };        i18n = $.extend( i18n.en, i18n[config.wgUserLanguage] );       $( '.wds-global-navigation__user-menu ul.wds-list li:nth-of-type(2)' ).after( $( '' ).append( // User blog               $( '', { href: mw.util.getUrl( 'User blog:' + config.wgUserName ), text: i18n.blog } )           ),            $( '' ).append( // Contribs                $( '', { href: mw.util.getUrl( 'Special:Contributions/' + config.wgUserName ), text: i18n.contribs } )           )        );        // Global nav menu        function createNavLink( target, label ) {            return {                href: mw.util.getUrl( target ),                text: label,                class: 'wds-global-navigation__link',            };        }        $('.wds-global-navigation__links').append( $( '', createNavLink( 'Special:ListAdmins', i18n['global-nav-admins'] ) ), $( '', createNavLink( 'Special:Contact/general', i18n['global-nav-staff'] ) ) );       // Link replacement by Nanaki        $( '.wds-community-header__wiki-buttons a[data-tracking="wiki-activity"]' ).attr( { href: mw.util.getUrl( 'Special:Recentchanges' ), title: i18n.recentchanges } );       // Minor snippets        $( 'a.external' ).attr( 'target', '_blank' );        $( '#wpLeaveRedirect' ).attr( 'checked', false );        $( '#mw-delete-table #wpReason' ).val( window.actionSummaries.deleteSummary );        $( '[data-tracking-label], [data-tracking]' ).removeAttr( 'data-tracking-label data-tracking' );        $( ".WikiaBarWrapper .overflow-menu" ).remove;    } ); } );