User:Kofirs2634/global.js

importArticles({	type: 'script',	articles: [		'u:nkch:MediaWiki:ThemeToggler.js',		'u:dev:MediaWiki:QuickDiff/code.js',		'u:dev:MediaWiki:FirstEditDate.js',		'u:ru.koffee:MediaWiki:BrowserHeaderColor.js',		'u:dev:MediaWiki:InterwikisOnSpecialPages.js'	] }); mw.loader.load("https://raw.githack.com/Vonavy/nkch-css/main/dist/index.js");

// KofiedArticlePreview $(function {	if (window.KofiedArticlePreview) return	window.KofiedArticlePreview = true	const c = mw.config.get(['wgScriptPath', 'wgArticlePath'])	const LINKS = '#mw-content-text a:not(.extiw, .external, .new)'	var reqTimer, leaveTimer	importArticle({ type: 'style', article: 'u:ru.koffee:MediaWiki:KofiedArticlePreview.css' })	$('body').append($(' ', { class: 'preview-popup hidden' }) .append($('', { class: 'preview-image' }).append($(' '))) .append($(' ', { class: 'preview-descr' })			.append($(' ', { class: 'preview-name' }).append($('')))			.append($(' '))		) )	$(LINKS).mouseenter(function(e) { var target = decodeURI($(e.target).attr('href')).substr(c.wgArticlePath.length - 2) clearTimeout(reqTimer) clearTimeout(leaveTimer) if (!$('.preview-popup').hasClass('hidden')) reqTimer = setTimeout(function { makeRequest(target) }, 500) else reqTimer = setTimeout(function { makeRequest(target) }, 2000) })	$(LINKS).mouseleave(closePopup)	$(LINKS).mousemove(function(e) { $('.preview-popup').css({			top: e.pageY + 'px',			left: e.pageX + 'px'		}) })	function makeRequest(target) {		$.ajax({ method: 'get', url: c.wgScriptPath + '/wikia.php', data: { controller: 'ArticlesApi', method: 'getDetails', width: 250, height: 150, titles: target }		}).done(fillPopup)		.fail(function(err) { console.error('KAP caught an error:', err) })	}	function fillPopup(data) {		if (!Object.keys(data.items).length) return closePopup		$('.preview-popup').removeClass('hidden')		var entry = data.items[Object.keys(data.items)[0]]		$('.preview-image').attr('href', entry.url)		$('.preview-name a').attr('href', entry.url).text(entry.title)		$('.preview-descr span').text(entry.abstract)		if (!entry.thumbnail) $('.preview-image').addClass('hidden')		else {			$('.preview-image').removeClass('hidden')			$('.preview-image img').attr('src', entry.thumbnail)		}	}	function closePopup {		clearTimeout(reqTimer)		clearTimeout(leaveTimer)		leaveTimer = setTimeout(function { $('.preview-popup').addClass('hidden') }, 2000)	} });

// 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) });