User:Kofirs2634/global.js

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

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

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

if (c.wgNamespaceNumber % 2 != 0 || c.wgNamespaceNumber == -1) 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);        $('.page-header__main').prepend($(' ').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: 'page-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');

$('.page-header__main').prepend(el.append(co)) } })

// First Edit Date $(function {	if (window.FirstEditDate) return;	window.FirstEditDate = true;	const c = mw.config.get(['wgScriptPath', 'profileUserId']);	if (!c.profileUserId) return;

function init { $.ajax({			method: 'get',			url: c.wgScriptPath + '/wikia.php',			data: {				controller: 'UserProfile',				method: 'getUserData',				format: 'json',				userId: c.profileUserId			}		}).done(function(r) {			var date;			if (r.userData.registration) date = r.userData.registration			else date = 'N/A'			$('.user-identity-stats')			.append($('', { id: 'wr', text: 'Первая правка: ' }) .append($(' ', { text: date })) );		}).fail(function(e) {			console.error('FED says an exception:', e)		}) }	var timer = setInterval(function {		if ($('#userProfileApp').length) {			clearInterval(timer);			init		}	}, 1000) })