User:LuvOf99Th/common.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:WallGreetingButton/code.js',    ] });

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:BackToTopButton/code.js',    ] });

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:SnowStorm.js',    ] });

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

/* created by Curiouscrab */ (function {   'use strict';    var config = mw.config.get([ 'wgNamespaceNumber', 'wgTitle' ]),       inUserNamespace = $.inArray(config.wgNamespaceNumber, [2, 3, 1200]) !== -1,        i18n,        date = new Date;    if (!inUserNamespace || window.StatusLoaded) {        return;    }    window.StatusLoaded = true;    date.setUTCHours(date.getUTCHours - 1);    function getRecentEdits(userName) {        return $.get('/api.php', { action: 'query', list: 'usercontribs|logevents', ucuser: userName, leuser: userName, ucend: date.toJSON, leend: date.toJSON, format: 'json' });   }    function getUserStatus(data) {        var recentEdits = data.query && (data.query.usercontribs.length + data.query.logevents.length);        if (recentEdits > 0 && recentEdits < 10) {            return {                status: i18n.msg('online').plain,                color: 'green',                image: 'https://vignette.wikia.nocookie.net/scratchpad/images/5/58/Ledgreen.png/revision/latest/scale-to-width-down/20'            };        } else if (recentEdits > 0) {            return {                status: i18n.msg('busy').plain,                color: 'orange',                image: 'https://vignette.wikia.nocookie.net/scratchpad/images/8/80/Ledorange.png/revision/latest/scale-to-width-down/20'            };        } else {            return {                status: i18n.msg('offline').plain,                color: 'red',                image: 'https://vignette.wikia.nocookie.net/scratchpad/images/6/6d/Ledred.png/revision/latest/scale-to-width-down/20' };       }    }    function addToContent($content) { var $statusElements = $content.find('span[data-user-status]:not(.loaded)'); if (!$statusElements.length) { return; }       $statusElements.each(function {            var $element = $(this).addClass('loaded');            if (!$element.data('userStatus')) {                return;            }            getRecentEdits($element.data('userStatus')).done(function(data) { var userStatus = getUserStatus(data); $element .css('color', userStatus.color) .text(userStatus.status) .append(                       ' ',                        $(' ', { src: userStatus.image })                   );            });        });    }    function addToMasthead { if (!inUserNamespace) { return; }       var userName = config.wgTitle.split('/')[0]; if (mw.util.isIPv4Address(userName) || mw.util.isIPv6Address(userName)) { return; }       getRecentEdits(userName).done(function(data) {            var userStatus = getUserStatus(data);            $('.UserProfileMasthead .details').append( $('', {                   css: {                        color: userStatus.color                    }                }).append(                    $(' ', { text: i18n.msg('status').plain }),                   ' ',                    $(' ', {                        text: userStatus.status }),                   ' ',                    $(' ', {                        css: { 'vertical-align': 'bottom' },                       src: userStatus.image })               )            );        });    }    mw.hook('dev.i18n').add(function(i18np) {        i18np.loadMessages('Status').then(function(i18np) { i18n = i18np; addToContent(mw.util.$content); mw.hook('wikipage.content').add(addToContent); addToMasthead; });   });    importArticle({        type: 'script',        article: 'u:dev:MediaWiki:I18n-js/code.js'    }); });