User:Sophiedp/global.js

//Imports importArticles({   type: 'script',    articles: [        'u:dev:ChatBanLogModal.js',        'u:dev:UnhideUserMasthead/code.js',        'u:dev:UserAccountAge/code.js',        'u:dev:VanguardTools.js'    ] });

//Chatconnect if (mw.config.get('wgCityId') === '177') { importScriptPage('MediaWiki:ChatConnect.3.js', 'internal-community'); }

//Extend ProtectionIcons to work in the MW namespace if (   mw.config.get('wgCityId') !== '7931' &&    mw.config.get('wgNamespaceNumber') === 8 &&    !/sysop/.test(mw.config.get('wgUserGroups')) ) { mw.hook('dev.wds').add(function (wds) {       $('#ca-edit svg').hide;        $('#ca-edit').prepend( wds.icon('alert-small') ).attr('title', 'You are editing this page without admin powers!');   }); importArticle({       type: 'script',        article: 'u:dev:WDSIcons/code.js'    }); } importArticle({   type: 'script',    article: 'u:dev:ProtectionIcons.js', });

//Make threads easier to archive mw.loader.using('mediawiki.api').then(function {    var api = new mw.Api,        config = mw.config.get([ 'wgCityId', 'wgNamespaceNumber', 'wgTitle', 'wgMonthNames' ]);   if ( config.wgCityId === '177' && config.wgNamespaceNumber === 1201 && $('.page-header__page-subtitle > nav > a[title="My wall"]').exists ) {       api.get({ action: 'query', prop: 'revisions', rvprop: 'timestamp|user', pageids: config.wgTitle }).then(function (d) { var a = d.query.pages[config.wgTitle].revisions[0], date = new Date(a.timestamp), time = config.wgMonthNames[date.getMonth + 1] + ' ' + date.getDate + ', ' + date.getFullYear, string = ''; $('#PageHeader').append('Archive '); $('#archive').click(function {                api.get({ action: 'query', prop: 'revisions', rvprop: 'content', titles: 'User:Sophiedp/Archive' }).then(function (c) { api.post({                       action: 'edit',                        title:  'User:Sophiedp/Archive',                        text: Object.values(c.query.pages)[0].revisions[0]['*'].replace(/(\|})(?![\s\S]*\1)/, string + '\n|}'),                        token: mw.user.tokens.get('editToken')                    }); $.nirvana.sendRequest({                       controller: 'WallExternalController',                        method: 'deleteMessage',                        type: 'POST',                        format: 'json',                        data: {                            mode: 'remove',                            msgid: config.wgTitle,                            formdata: [{                                name: 'reason',                                value: 'Archived'                            }],                            token: mw.user.tokens.get('editToken')                        },                        callback: function  {                            location.reload;                        }                    }); });           });        });    } });

//Hide the rail if empty mw.hook('wikipage.content').add(function {    if (!$('#WikiaRail').children.exists) {        $('#WikiaRailWrapper').hide;        $('.WikiaMainContent').css('width', '100%');    } });