User:Aerozoan/global.js

importArticles({   type: 'script',    articles: [        'w:dev:AjaxBatchDelete/code.2.js',        'w:dev:DisplayTimer/code.js',        'w:dev:ListFiles/code.js',        'w:dev:QuickDiff/code.js',        'w:dev:ReferencePopups/code.js',        'w:dev:UserAccountAge/code2.js',        'w:dev:View_Source/code.js',    ] });

/** * Name:       Matrix * Version:    v1.0 * Author:     KockaAdmiralac <1405223@gmail.com> * Description: Makes a UserActivity-ish table on User:Username/matrix *             Runs only on English Community Central */ require([   'wikia.window',    'jquery',    'mw',    'ext.wikia.design-system.loading-spinner' ], function(window, $, mw, Spinner) {    'use strict';    var config = mw.config.get([ 'wgCityId', 'wgUserName' ]);   if (config.wgCityId !== '177' || window.MatrixLoaded) {        return;    }    window.MatrixLoaded = true;    var Matrix = {        config: window.MatrixConfig || {},        init: function {            this.api = new mw.Api;            this.spinner = new Spinner(38, 2).html                .replace('wds-block', 'wds-spinner__block')                .replace('wds-path', 'wds-spinner__stroke');            $('#my-tools-menu').append( $('').append(                   $('', { 'class': 'custom', text: 'Publish user activity' }).click($.proxy(this.click, this))               ) );       },        click: function {            $(' ', { css: { background: 'rgba(255, 255, 255, 0.5)', position: 'fixed', height: '100%', width: '100%', left: '0', top: '0', 'z-index': '1000000000', },               html: this.spinner, id: 'matrix-spinner' }).appendTo(document.body);           $.nirvana.getJson('UserActivity\\Controller', 'index', { cb: Date.now, uselang: 'en' }, $.proxy(this.cbNirvana, this));       },        cbNirvana: function(d) {            var urlRegex = /^https?:\/\/(.*)\.(?:wikia|fandom)\.(?:com|org)\/(?:([^\/]+)\/?)?$/,                str = '\n' +                      '{| width="100%" class="article-table sortable"\n' +                      '|- class="useractivity-header"\n' +                      '! id="title-header" | \n' +                      '! id="edits-header" data-sort-type="number" | # of edits\n' +                      '! id="last-edit-header" | \n' +                      '! id="rights-header" | \n' +                      d.items.filter(function(item) { return !(config.private instanceof Array) || config.private.indexOf(item.url) === -1; }).reverse.map(function(item) { var match = urlRegex.exec(item.url), wiki = match[1]; if (match[2]) { wiki = match[2] + '.' + wiki; }                         urlRegex.lastIndex = 0; return '|-\n' + '| \'\'\'' + item.title + '\'\'\'\n' + '| ' + item.editString + '\n' + '| ' + item.lastEdit + '\n' + '| ' + item.groups; }).join('\n') +                     '\n|}';            this.api.post({ action: 'edit', title: 'User:' + config.wgUserName + '/matrix', text: str, token: mw.user.tokens.get('editToken'), summary: 'Updating wiki list with Matrix.js', minor: true, bot: true }).done($.proxy(this.cbAPI, this));       },        cbAPI: function(d) {            $('#matrix-spinner').remove;            if (!d.error && d.edit.result === 'Success') {                new BannerNotification('List of wikis successfully updated!', 'confirm').show;            }        }    };    mw.loader.using(['mediawiki.api']).then($.proxy(Matrix.init, Matrix)); });