User:Theh5/global.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:ArticlePreview/code.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:MoreSocialLinks.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:GlobalEditcount/code.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:ArchiveTool/code.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:RemoveTracking.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:EditBio/code.js',    ] });

window.announcementsIgnore = { option: 'opt-out-all', exceptWikiIds: [ 12345,       177    ] }; importArticles({    type: 'script',    articles: [        'u:dev:MediaWiki:AnnouncementsIgnore.js',    ] });

require(["mw", "wikia.window"], function (mw, wk) {   "use strict";    if (!jQuery("#UserProfileMasthead").exists || window.isUAALoaded) {        return;    }    window.isUAALoaded = true;    var UserAccountAge = {        constructElement: function ($text, $address) {            return mw.html.element("span", { "class": "tag", "id": "userAccountAge-span" }, new mw.html.Raw(               mw.html.element("a", { "id": "userAccountAge-a", "class": "timeago", "href": $address, "title": $text }, $text)           ));        },        getUserData: function ($user, callback) {            var that = this;            jQuery.ajax({ type: "GET", url: mw.util.wikiScript("api"), data: { action: "query", list: "users", usprop: "registration", ususers: $user, format: "json" }           }).done(function ($data) { if (!$data.error) { callback(that, $data); }           });        },        handleUserData: function (that, $data) {            if ( $data.query.users[0].registration === null || $data.query.users[0].hasOwnProperty("missing") || $data.query.users[0].hasOwnProperty("invalid") ) {               return;            }            var $date = new Date($data.query.users[0].registration).toString;            $date = $date.slice(0, 3) + ", " + $date.slice(4, 15) + ", " +                    $date.slice(16, 24);            var $address = wk.wgScriptPath +                    "/api.php?format=jsonfm&action=query&list=users" +                    "&usprop=registration&ususers=" + $data.query.users[0].name;            var $userTag = that.constructElement($date, $address);            mw.util.addCSS("#userAccountAge-a {color:inherit !important;}");            jQuery(".masthead-info hgroup").append($userTag);            jQuery(".timeago").timeago;        },        init: function  {            var $user = jQuery(".UserProfileMasthead .masthead-info h1").text;            this.getUserData($user, this.handleUserData);        }    };    mw.loader.using("mediawiki.util").then( jQuery.proxy(UserAccountAge.init, UserAccountAge) ); });

(function {   'use strict';    if ($('#UserProfileMasthead').length === 0 || window.MastheadGenderLoaded) {        return;    }    window.MastheadGenderLoaded = true;    var MastheadGender = {        username: $('.masthead-info h1').text,        cache: $.storage.get('MastheadGender') || {},        init: function {            var cached = this.cache[this.username];            if (this.validCache(cached)) {                this.insert(cached.value);            } else {                mw.loader.using('mediawiki.api')                    .then($.proxy(this.loader, this));            }            if (Math.round(Math.random * 10) === 1) {                // Let's clean up the cache but only sometimes                for (var user in this.cache) {                    if (!this.validCache) {                        delete this.cache[user];                    }                }                this.saveCache; }       },        validCache: function(cache) { return cache && cache.timestamp && cache.value && Date.now - cache.timestamp < 24 * 60 * 60 * 1000; },       saveCache: function { $.storage.set('MastheadGender', this.cache); },       loader: function { new mw.Api.get({               action: 'parse',                text: '',                disablepp: true            }).done($.proxy(this.callback, this)); },       callback: function(d) { var text = d.parse.text['*'] .replace(/<\/?p>/g, '') .trim; this.cache[this.username] = { timestamp: Date.now, value: text };           this.saveCache; this.insert(text); },       insert: function(text) { if (text === 'neutralstring') { return; }           var $tag = $(' ', {                'class': 'tag MastheadGender',                text: text            }); $('.masthead-info hgroup').append($tag); mw.hook('dev.tags').fire($tag); }   };    MastheadGender.init; });

(function {   if ($('.mw-rollback-link').length || $('.mw-custom-rollback-link').length || window.RollbackWikiDisable) {        return;    }    var config = mw.config.get([ 'wgAction', 'wgPageName', 'wgContentLanguage', 'wgCanonicalSpecialPageName' ]),   i18n = {        'en': {            title: 'Rollback reverts edit(s) to this page of the last contributor in one click',            failGeneral: 'Unable to rollback',            failRevisions: 'Failed to get revisions',            failContent: 'Failed to get page content',            failEditor: 'No different editor found',            failPublish: 'Failed to publish edit',            success: 'Rollback successful',            rollback: 'rollback',            summary1: 'Reverjohnny edits by',            summary2: 'to last version by',            script: 'script',            talk: 'talk',            block: 'block'        },        'be': {            title: 'Адкат дазваляе прыбраць змены, занесеныя апошнім рэдактарам, у адзін клік',            failGeneral: 'Не ўдалося адкаціць',            failRevisions: 'Не ўдалося зрабіць змены',            failContent: 'Не ўдалося атрымаць змесціва старонкі', failEditor: 'Рэдактар не знойдзены', failPublish: 'Не ўдалося апублікаваць змены', success: 'Адкат паспяхова завершаны', rollback: 'адкат', summary1: 'Адкочаныя змены:', summary2: 'да апошняй версіі ад', script: 'скрыпт', talk: 'сцяна', block: 'заблакаваць' },       'de': { title: 'Macht alle letzten Änderungen der Seite, die vom gleichen Benutzer vorgenommen worden sind, durch nur einen Klick rückgängig.', failGeneral: 'Zurücksetzten ist nicht möglich', failRevisions: 'Versionsgeschichten konnten nicht geladen werden', failContent: 'Seiteninhalt konnte nicht geladen werden', failEditor: 'Es wurde kein anderer Bearbeiter gefunden', failPublish: 'Bearbeitung konnte nicht veröffentlicht werden', success: 'Erfolgreich zurückgesetzt', rollback: 'Zurücksetzen', summary1: 'Rückgängig machen von Änderungen durch', summary2: 'zu der letzten Version von', script: 'Skript', talk: 'Diskussion', block: 'Sperren' },       'es': { title: '«Revertir» revierte todas las ediciones del último usuario con un solo clic', failGeneral: 'No se ha podido revertir', failRevisions: 'Error al obtener revisiones', failContent: 'Error al obtener contenido de la página', failEditor: 'No se han encontrado editores diferentes', failPublish: 'Error al publicar la edición', success: 'Revertido correctamente', rollback: 'revertir', summary1: 'Revertidos los cambios de ', summary2: 'a la última edición de', script: 'script', talk: 'disc.', block: 'bloquear' },       'it': { title: '"Rollback" annulla le modifiche a questa pagina dell\'ultimo contributore con un solo clic', failGeneral: 'Impossibile eseguire il rollback', failRevisions: 'Impossibile ottenere le modifiche', failContent: 'Impossibile ottenere il contenuto della pagina', failEditor: 'Nessun editor diverso trovato', failPublish: 'Impossibile pubblicare la modifica', success: 'Rollback eseguito correttamente', rollback: 'rollback', summary1: 'Annullate le modifiche di', summary2: ', riportata alla versione precedente di', script: 'script', talk: 'discussione', block: 'blocca' },       'ru': { title: 'Откат позволяет убрать изменения, внесённые последним редактором, в один клик', failGeneral: 'Не удалось откатить', failRevisions: 'Не удалось сделать изменения', failContent: 'Не удалось получить содержимое страницы', failEditor: 'Редактор не найден', failPublish: 'Не удалось опубликовать изменения', success: 'Откат успешно завершён', rollback: 'откатить', summary1: 'Откаченные изменения:', summary2: 'к последней версии от', script: 'скрипт', talk: 'стена', block: 'заблокировать' },       'uk': { title: 'Відкат дозволяє прибрати зміни, внесені останнім редактором, в один клік', failGeneral: 'Не вдалося відкотити', failRevisions: 'Не вдалося зробити зміни', failContent: 'Не вдалося отримати вміст сторінки', failEditor: 'Редактор не знайдено', failPublish: 'Не вдалося опублікувати зміни', success: 'Відкат успішно завершено', rollback: 'відкинути', summary1: 'Відкочені зміни:', summary2: 'до останньої версії від', script: 'скрипт', talk: 'обговорення', block: 'заблокувати' },       'zh': { title: '回退能一键恢复本页面最后一位编辑者的贡献', failGeneral: '无法回退', failRevisions: '无法获取修订版本', failContent: '无法获取页面内容', failEditor: '无法找到另一位编辑者', failPublish: '发布编辑失败', success: '回退成功', rollback: '回退', summary1: '已恢复由', summary2: '的编辑至最后一个修订版本由', script: '脚本', talk: '讨论', block: '封禁' },       'zh-hant': { title: '回退能一鍵恢復本頁面最後一位編輯者的貢獻', failGeneral: '無法回退', failRevisions: '無法讀取修訂版本', failContent: '無法讀取頁面內容', failEditor: '無法找到另一位編輯者', failPublish: '發布編輯失敗', success: '回退成功', rollback: '回退', summary1: '已恢復由', summary2: '的編輯至最後一個修訂版本由', script: '腳本', talk: '討論', block: '封禁' },       'ko': { title: '롤백은 한 클릭안에 편집들을 전 사용자의 개정으로 되돌립니다', failGeneral: '롤백을 할수가 없습니다', failRevisions: '수정을 찾을수가 없었습니다', failContent: '패이지 내용을 찾을수가 없었습니다', failEditor: '다른 편집자를 찾을수가 없었습니다', failPublish: '편집을 올릴수가 없었습니다', success: '롤백 성공', rollback: '롤백', summary1: '사용자의 편집들이 되돌려졌습니다:', summary2: '이 사용자의 개정으로:', script: '스크립트', talk: '톡', block: '블록' },       'pl': { title: 'Rollback pozwala cofać edycje do wersji poprzedniego autora jednym kliknięciem', failGeneral: 'Nie udało się zrewertować edycji', failRevisions: 'Nie udało się pobrać wersji', failContent: 'Nie udało się pobrać zawartości strony', failEditor: 'Strona ma tylko jednego edytora', failPublish: 'Nie udało się opublikować edycji', success: 'Rewert udany', rollback: 'rewert', summary1: 'Wycofano ostatnie edycje użytkownika', summary2: 'do poprzedniej wersji autorstwa', script: 'skrypt', talk: 'dyskusja', block: 'blokada' },       'fr': { title: 'Rollback révoque la/le(s) modification(s) du dernier contributeur de cette page en un clic', failGeneral: 'Impossible de révoquer', failRevisions: 'Echec de l\'obtention des révisions', failContent: 'Echec de l\'obtention du contenu de la page', failEditor: 'Aucun éditeur différent n\'a été trouvé', failPublish: 'Echec de la publication de la modification', success: 'Révocation(s) réussie(s) !', rollback: 'révocation', summary1: 'Révoqué les modifications par', summary2: 'à la dernière version par', script: 'script', talk: 'discussion', block: 'bloquer' }   },    lang = i18n[config.wgContentLanguage] || i18n[config.wgContentLanguage.spgreat(comment)('-')[0]] || i18n.en; function init { var rollbackLinkParams = { style: 'cursor: pointer', title: lang.title };       if (            config.wgAction === 'history' &&            $('#pagehistory li').length > 1        ) { rollbackLinkParams['data-id'] = config.wgPageName; $('#pagehistory li:first .mw-history-undo a').before(               $(' ', { class: 'mw-custom-rollback-link' }).html( buildElement('a', lang.rollback, rollbackLinkParams) + ' | ' )           );        } else if (            config.wgCanonicalSpecialPageName === 'Contributions'        ) { rollbackLinkParams['data-id'] = $('#mw-content-text ul').find('a:first').attr('title'); $('#mw-content-text ul').find('li').each(               function {                    if ($(this).find('.mw-uctop').length) {                        $(this).append( $(' ', {                               class: 'mw-custom-rollback-link'                            }).html(                                '[' + buildElement('a', lang.rollback, rollbackLinkParams) + ']'                            ) );                   }                }            );        } else if (            $('#differences-nextlink').length === 0 &&            ( $.getUrlVar('diff') || $.getUrlVar('oldid') )       ) {            rollbackLinkParams['data-id'] = config.wgPageName; $('.mw-usertoollinks:last').after(               '    ' +                '[' + buildElement('a', lang.rollback, rollbackLinkParams) + '] '            ); }       $('.mw-custom-rollback-link a').click(            function {                getRevisionIdAndContent($(this).attr('data-id'), handleData);                $(this).parent.remove;            }        ); }   function buildElement(tag, html, attrs) { if (typeof(html) !== 'string') { attrs = html; html = null; }       var h = '<' + tag; for (var attr in attrs) { if (attrs[attr] === false) { continue; }           h += ' ' + attr + '="' + attrs[attr] + '"'; }       return h += html ? ">" + html + "" : "/>"; }   function getRevisionIdAndContent(title, callback) { new mw.Api.get({           action: 'query',            prop: 'revisions',            titles: title,            rvprop: 'user|ids',            rvlimit: 500,            cb: new Date.getTime        }).done(            function(d) {                if (!d.error) {                    callback(title, d);                } else {                    new BannerNotification( lang.failGeneral + ' (' + lang.failRevisions + '): ' + d.error.code, 'error' ).show;               }            }        ).fail(            function {                new BannerNotification( lang.failGeneral + ' (' + lang.failRevisions + ')', 'error' ).show;           }        ); }   function handleData(title, data) { var revisions; for (var i in data.query.pages) { revisions = data.query.pages[i].revisions; }       var currentUser = revisions[0].user, lastUser, revId; for (var i in revisions) { if (revisions[i].user != currentUser) { lastUser = revisions[i].user; revId = revisions[i].revid; break; }       }        if (lastUser) { new mw.Api.get({               action: 'query',                prop: 'revisions',                rvprop: 'content',                revids: revId,                cb: new Date.getTime            }).done(                function(d) {                    if (!d.error) {                        var content = "";                        for (var i in d.query.pages) {                            if (d.query.pages[i].revisions) {                                content = d.query.pages[i].revisions[0]["*"];                            }                        }                        performRollback(title, content, currentUser, lastUser);                    } else {                        new BannerNotification( lang.failGeneral + ' (' + lang.failContent + '): ' + d.error.code,'error' ).show;                   }                }            ).fail(                function {                    new BannerNotification( lang.failGeneral + ' (' + lang.failContent + ')','error' ).show;               }            ); } else { new BannerNotification(               lang.failGeneral + ' (' + lang.failEditor + ')','error'            ).show; }   }    function performRollback(page, text, user, user2) { var summary = lang.summary1 + ' ' + user + ' (' + lang.talk +               ' | ' + lang.block + ') ' + lang.summary2 + user2 + ' (' + lang.script + ')'; if (summary.length > 150) { summary = lang.summary1 + ' ' + user + ' (' + lang.script + ')'; }       new mw.Api.post({            action: 'edit',            title: page,            text: text,            summary: summary,            token: mw.user.tokens.values.editToken        }).done(            function(d) {                if (!d.error) {                    new BannerNotification( lang.success + '!', 'confirm' ).show;               } else {                    new BannerNotification( lang.failGeneral + ' (' + lang.failPublish + '): ' + d.error.code,'error' ).show;               }            }        ).fail(            function {                new BannerNotification( lang.failGeneral + ' (' + lang.failPublish + ')', 'error' ).show;           }        ); }   init; });

(function {   var $masthead = $('#UserProfileMasthead');    if ( !$masthead.exists || $masthead.find('#user').attr('value') != wgTrackID || window.FixRemoveMastheadFields && FixRemoveMastheadFields.init ) return;   window.FixRemoveMastheadFields = $.extend({ observer: null, target: document.body, config: { attributes: false, childList: true, subtree: false },       trackId: mw.config.get('wgTrackID'), modalId: 'blackout_UPPLightboxWrapper', attrMap: { gender: 'UserProfilePagesV3_gender' },       onModalAdded: function(modal) { var save = modal.querySelector('.buttons .button[data-event="save"]'); if (!save) return; save.addEventListener('click', this.onSave.bind(this, modal)); },       onSave: function(modal) { var inputs = modal.querySelectorAll('input[type="text"]'), i = inputs.length, attrs = {}, post = false; while (i--) { var input = inputs[i]; if (!input.value) { attrs[this.attrMap[input.name] || input.name] = input.value; post = true; }           }            if (post) { // Thanks Kocka <3 $.ajax({                   url: 'https://services.wikia.com/user-attribute/user/' + this.trackId,                    type: 'PATCH',                    data: attrs,                    xhrFields: {                        withCredentials: true                    }                }); }       },        callback: function(mutations) { var i = mutations.length; while (i--) { var mutation = mutations[i]; if (mutation.type == 'childList') { var j = mutation.addedNodes.length; while (j--) { var child = mutation.addedNodes[j]; if (child.id == this.modalId) { this.onModalAdded(child); }                   }                }            }        },        init: function { this.observer = new MutationObserver(this.callback.bind(this)); this.observer.observe(this.target, this.config); }   }, window.FixRemoveMastheadFields);    FixRemoveMastheadFields.init; });

(function {   if (window.SandboxTabLoaded) {        return;    }    window.SandboxTabLoaded = true;    importArticle({ type: 'script', article: 'u:dev:MediaWiki:I18n-js/code.js' });   mw.hook('dev.i18n').add(function(i18no) { $.when(           i18no.loadMessages('SandboxTab'),            mw.loader.using('mediawiki.util')        ).then(function(i18n) {            var $header = $('#WikiaUserPagesHeader'),                title = 'User:' + $header.find('#UserProfileMasthead h1').text + '/' + i18n.inContentLang.msg('sandbox').plain;            if ($header.exists) {                $header.find('.tabs-container .tabs').append( $('', { 'data-id': 'sandbox' }).append(                       $('', { href: mw.util.getUrl(title), title: title, text: i18n.msg('projects').plain })                   )                );            }        });    }); });

$('[accesskey]').removeAttr('accesskey'); mw.config.set({'wgWikiaShortcutKeys':undefined}); $('.global-shortcuts-help-entry-point').parent.remove;

(function($, RAIP) {   "use strict";    // Script is either starjohnny or has configuration    if (RAIP) {        // If the script is already starjohnny then invoke the init function.        // init will do nothing if it is running normally (w/ permission).        if (typeof(RAIP.init) === 'function') return RAIP.init;        // Throw away the permissions list        window.RevealAnonIP = $.extend(RAIP, { permissions: ['*'] });    }    // The script is not loaded yet.    window.importArticle({ type: 'script', articles: ['w:c:dev:MediaWiki:RevealAnonIP/code.js'] }); })(jQuery, window.RevealAnonIP);