User:Kofirs2634/global.js

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

// ArticleCounter $(function {	if (window.ArticlesCount) return;	window.ArticlesCount;	const c = mw.config.get(['wgCityId', 'wgArticlePath']);	if (!$('.fandom-community-header').length) return;	$.ajax({ method: 'get', url: 'https://community.fandom.com/api/v1/Wikis/Details?ids=' + c.wgCityId }).done(render)	.fail(function(e) { console.error('ArticlesCount got an error: ', e) })	function plural(x, forms) {		var ld = x % 10; var pld = x % 100;		if (11 <= pld && pld <= 19) return forms[2]		else if (2 <= ld && ld <= 4) return forms[1]		else if (ld == 1) return forms[0]		else return forms[2]	}	function render(r) {		var articles = r.items[c.wgCityId].stats.articles;		$('.fandom-community-header__community-name-wrapper').after( $(' ', { class: 'articles-count' }).append($('', { href: c.wgArticlePath.replace('$1', 'Special:Allpages'), html: ' ' + articles + ' ' + plural(articles, ['статья', 'статьи', 'статей']) }))		)		$('head').append($(' ', {			id: 'articlescount-styles',			text: '.articles-count{line-height:26px;margin-left:auto}.articles-count a:hover,.articles-count a:active,.articles-count a:focus{text-decoration:none}.articles-count span{font-size:22px;font-weight:bold}.fandom-community-header .wiki-tools{margin-left:20px}'		}))	} });

// Pages' Length mw.loader.using('mediawiki.api', function {    if (window.PagesLength) return;    window.PagesLength = true;

const c = mw.config.get(['wgPageName', 'wgNamespaceNumber', 'skin']), api = new mw.Api;

if (c.wgNamespaceNumber % 2 != 0 || c.wgNamespaceNumber == -1) return; if (!['fandomdesktop', 'oasis'].includes(c.skin)) return;

api.get({       action: 'query',        prop: 'revisions',        rvlimit: 2,        rvprop: 'size',        titles: c.wgPageName    }) .done(render) .fail(function(e) {       console.error('Pages\' Length caught an error:', e);        var selector = c.skin == 'oasis' ? '.page-header__main' : '.page-header__top';        $(selector).prepend($(' ', { class: 'pages-length' }).css('color', '#F00').text('При загрузке Pages\' Length произошла ошибка.'))    }) function render(d) { var r = d.query.pages[Object.keys(d.query.pages)[0]].revisions, diff, percent, el = $(' ', { class: 'pages-length' }), co = $(' '); if (d.missing == '') diff = percent = 0; if (r.length) { if (r.length == 1) { diff = r[0].size; percent = 100 } else { diff = r[0].size - r[1].size; percent = ((r[0].size / r[1].size - 1) * 100).toFixed(2) }       }

el.html(' Размер: ' + (r.length ? r[0].size : diff) + ' байт '); if (diff == 0) co.addClass('mw-plusminus-null').text('(0; = 0%)') else if (diff > 0) co.addClass('mw-plusminus-pos').text('(+' + diff + '; ▲+' + percent + '%)') else if (diff < 0) co.addClass('mw-plusminus-neg').text('(' + diff + '; ▼' + percent + '%)'); if (Math.abs(diff) >= 500) co.css('font-weight', 'bold');

if (c.skin == 'oasis') $('.page-header__main').prepend(el.append(co)) else { $('.page-header__top').prepend(el.append(co)); $('head').append($(' ', { id: 'pageslength-styles', text: '.page-header__top { flex-wrap: wrap } .pages-length { width: 100% }' + '.mw-plusminus-pos{color:#006400}.mw-plusminus-neg{color:#8b0000}.mw-plusminus-null{color:#a2a9b1}' }))		}   } });

// WhileYouWereAway $(function {	if (window.WhileYouWereAway) return;	window.WhileYouWereAway = true;	const c = mw.config.get('wgCanonicalSpecialPageName');	var storage = localStorage.getItem('WYWATimemark');	if (c != 'Recentchanges') return;

var mark = findEntry('table'), firstTable = $('table.mw-changeslist-line').eq(0).attr('data-mw-ts'), submark = findEntry('tr'), firstTr = $('tr.mw-changeslist-line').eq(0).attr('data-mw-ts') function findEntry(el) { return $(el + '.mw-changeslist-line') .map(function(n, e) { return $(e).attr('data-mw-ts') }) .toArray.find(function(e) { return e < storage }) }	function toggleMark(e) { var state = $(e.target).parents.eq(3).hasClass('mw-collapsed'); $('.wywa-mark').css('display', state ? 'block' : 'none') }

if (!mark) $('.mw-changeslist').append($(' ', { class: 'wywa-mark' })) else if (firstTable != mark) $('table[data-mw-ts="' + mark + '"]').before($(' ', { class: 'wywa-mark' }))

if (submark && firstTr != submark) { $('tr[data-mw-ts="' + submark + '"]').before($(' ', { class: 'wywa-submark' }).append($(' ', { colspan: 99 }))); $('.wywa-submark').siblings.eq(0).find('.mw-collapsible-toggle').click(toggleMark) }	$('.wywa-mark, .wywa-submark').click(function(e) { $(e.target).remove }) storage = new Date.toISOString.match(/\d/g).join('').slice(0, 14) localStorage.setItem('WYWATimemark', storage) });