User:Kofirs2634/global.js

// WAM Settings window.railWAM = { lang: 'ru' };

// Some imports importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:PortableCSSPad/code.js',        'u:dev:MediaWiki:RailWAM/code.js',        'u:dev:MediaWiki:GlobalEditcount/code.js',        'u:dev:MediaWiki:AjaxDiff/code.js',        'u:dev:MediaWiki:EditBio/code.js',        'u:ru.koffee:MediaWiki:EditorInfo.js'    ] });

// MultiUpload importScriptPage('MultiUpload/code.js', 'dev'); var MultiUploadoption = { max: 100 };

// From Dev Wiki "Sandbox Link" with my additional buttons (function {   if (window.SandboxLinkLoaded) {        return;    }    window.SandboxLinkLoaded = true;    importArticle({ type: 'script', article: 'u:dev:MediaWiki:I18n-js/code.js' });   mw.hook('dev.i18n').add(function(i18no) { $.when(           i18no.loadMessages('SandboxLink'),            mw.loader.using('mediawiki.util')        ).then(function(i18n) {            var conf = mw.config.get([ 'wgFormattedNamespaces', 'wgUserName' ]);           $('.wds-global-navigation__user-menu .wds-list').append( $('', {                   id: 'MySandbox'                }).append(                    $('', { 'class': 'wds-global-navigation__dropdown-link', href: mw.util.getUrl(conf.wgFormattedNamespaces[2] + ':' + conf.wgUserName + '/' + i18n.inContentLang.msg('sandbox-subpage').plain), text: i18n.msg('sandbox').plain })               )            );            $('.wds-global-navigation__user-menu .wds-list').append( $('', {                   id: 'MyCSS'                }).append(                    $('', { 'class': 'wds-global-navigation__dropdown-link', href: mw.util.getUrl(conf.wgFormattedNamespaces[2] + ':' + conf.wgUserName + '/wikia.css'), text: 'Мой CSS' })               )            );            $('.wds-global-navigation__user-menu .wds-list').append( $('', {                   id: 'MyCSS'                }).append(                    $('', { 'class': 'wds-global-navigation__dropdown-link', href: mw.util.getUrl(conf.wgFormattedNamespaces[2] + ':' + conf.wgUserName + '/common.js'), text: 'Мой JS' })               )            );        });    }); });

// Hide Global Nav Menu $(function($) {   if (window.hideGNM) return;    window.hideGNM = true;    window.hideGlobalNav = function {        $('.wds-global-navigation-wrapper').addClass('hide-it');        $('#wds-global-navigation__unhide').removeClass('hide-it')    }    window.unhideGlobalNav = function {        $('#wds-global-navigation__unhide').addClass('hide-it');        $('.wds-global-navigation-wrapper').removeClass('hide-it')    }    // Hide button    $('.wds-global-navigation__content-bar-right').append(' ');    $('.wds-global-navigation__hide').append('▲');    // Unhide button    $('.wds-global-navigation-wrapper').after(' ');    $('#wds-global-navigation__unhide').append('▼') })

// Page's length mw.loader.using('mediawiki.api', function {   var config = mw.config.get(['wgPageName', 'wgNamespaceNumber', 'wgScriptPath']);    if (config.wgNamespaceNumber % 2 != 0 || config.wgNamespaceNumber == -1) return;    $.ajax({ type: 'get', url: config.wgScriptPath + '/api.php?action=query&format=json&prop=info|revisions&rvlimit=2&rvprop=size&titles=' + config.wgPageName, success: function(data) { var length = data.query.pages[Object.keys(data.query.pages)[0]].length, lengthBefore = 0, text = ' Размер: ' + length + ' байт'; if (data.query.pages[Object.keys(data.query.pages)[0]].revisions[1]) lengthBefore = data.query.pages[Object.keys(data.query.pages)[0]].revisions[1].size; diff = length - lengthBefore; if (length % 10 == 2 || length % 10 == 3 || length % 10 == 4) { if (diff > 0) text += 'а (+' + diff + ') ' else if (diff < 0) text += 'а (' + diff + ') ' else text += 'а (0) ' } else { if (diff > 0) text += ' (+' + diff + ') ' else if (diff < 0) text += ' (' + diff + ') ' else text += ' (0) ' }           $('.page-header__main').prepend(text); if (Math.abs(diff) > 500) $('.page-length #size').css('font-weight', 'bold') },       error: function { $('.page-header__main').prepend(' Произошла ошибка ') }   }) })

// One stupid thing $(function {	if (!$('#UserProfileMasthead').length || window.EditsShareInTotal) return;	window.EditsShareInTotal = true;

var api = new mw.Api, c = mw.config.get(['wgUserName', 'wgNamespaceNumber', 'wgTitle']), ref = mw.util.getUrl('Special:Editcount/' + c.wgUserName), localEdits, globalEdits;

if (c.wgTitle != c.wgUserName || c.wgNamespaceNumber != 2) return;

api.get({		action: 'query',		list: 'users',		ususers: c.wgUserName,		usprop: 'editcount'	}, function(data) {		localEdits = data.query.users[0].editcount;		getGlobal	});

function getGlobal { $.get(ref, function(data) {			globalEdits = $(data).find('.TablePager tr:nth-child(2) .ecrowright:nth-child(4)').text.replace(/\s+/, '');			appendCount		}) }

function appendCount { $('.contributions-details').after($(' ', { 'class': 'edits-share tally' })			.append($('', { href: ref }).append($(' ', { style: 'font-size: 18px', text: parseFloat((localEdits / globalEdits * 100).toFixed(2)) + '%' })).append($(' ', { style: 'font-size: 60%', text: 'доля в общем числе правок' }))))	}

do { if ($('.globaledit-details')) $('.globaledit-details').before($('.edits-share')); } while (!$('.globaledit-details')) })