User:BryghtShadow/global.js

// window.EditConflictAlertInit = true; importArticles( {	articles: [		// Regular scripts.		'u:dev:MediaWiki:HideEmptyTrackingCategories.js',		'u:dev:MediaWiki:ImportJSPage/code.js',		'u:dev:MediaWiki:MassCategorization/code.js',		'u:dev:MediaWiki:MassEdit/code.js',		'u:dev:MediaWiki:MassNullEdit/code.js',		'u:dev:MediaWiki:ModulesLinkToModules.js',		'u:dev:MediaWiki:RestoreRightRail.js',		'u:dev:MediaWiki:ThemeToggler.js',		'u:dev:MediaWiki:UserAccountAge/code2.js'	] } );

var cfg = mw.config.get( [	'wgAction',	'wgCanonicalSpecialPageName',	'wgContentLanguage',	'wgNamespaceNumber',	'wgUserLanguage',	'wgTitle' ] );

/** * Helper function to load system messages **/ function getMessages( a ) { return mw.loader.using( "mediawiki.api" ).then( function {		var e = new mw.Api,			t = cfg.wgContentLanguage;		return t !== cfg.wgUserLanguage			? e.getMessages( a, { amlang: t } )			: e.loadMessagesIfMissing( a ).then( function  { return a.reduce( function ( e, t ) {					return e[ t ] = mw.message( t ).plain, e				}, {} ) } )	} ) }

/** Add cargo link */ $(function {	/** Restore link to Cargo's pagevalues **/	var id = 't-cargopagevalueslink';	if ( !mw.config.get('wgCargoWeekDays') || mw.config.get('wgNamespaceNumber') === -1 || document.getElementById(id)) {		return;	}

function addLink { mw.loader.using(['mediawiki.util'], function {			mw.util.addPortletLink( 'p-tb', new URL(location.href).pathname + '?action=pagevalues', 'Page values', id //, [tooltip], [accesskey], [nextnode] )		})	}	console.log('p-tb', document.getElementById('p-tb')); if (document.getElementById('p-tb')) { addLink; } else { $("#WikiaRail").on('afterLoad.rail', function {			addLink		}); } });

// /* // * Add line numbers to `.mw-highlight-lines` where length exceeds 100 kB //  */ // mw.hook('wikipage.content').add(function ($content) { // 	$('.mw-highlight.mw-highlight-lines pre').each(function (_, pre) { // 		if ($('span', pre).length) return; // 		var text = $(pre).text.trim; // 		if (text.length <= 102400) return; // 		$(pre).empty.append(text.split('\n').map(function (line, i) { // 			var n = i + 1; // 			return $(' ', { id: 'L-' + n }).append([ // 				$('', { href: '#L-' + n }).append( // 					$(' ', { class: 'linenos', 'data-line': n }) // 				), // 				line + '\n' // 			]); // 		})); // 	}); // }); /** * Editform access keys. **/ mw.hook( "wikipage.editform" ).add( function ( $ef ) {	// mutation observer	function n( o ) {		var c = o.id ? function ( t ) {			var e = document.getElementById( o.id );			e && o.ok( e, t )		} : function ( t ) {			var e = document.getElementsByClassName( o.cl )[ 0 ];			e && o.ok( e, t )		},		t = new MutationObserver( function ( t, e ) { c( e ) } ).observe( o.p || document, { subtree: !!o.st || !o.p,			childList: 1 } );		return c, t	}	// add accesskey to CodeEditor	n( { p: $ef[ 0 ], cl: "wikiEditor-ui-text", st: 1, ok: function ( t, e ) { e && e.disconnect, // add accesskey to Ace Editor n( {				p: t,				cl: "ace_text-input",				ok: function ( t, e ) {					t.setAttribute( "accesskey", "," )				}			} ), // add accesskey when CodeMirror's syntax highlight is enabled n( {				p: t,				cl: "noime",				ok: function ( t, e ) {					t.setAttribute( "accesskey", "," )				}			} ) }	} ),	// add accesskey to Scribunto console.	828 === cfg.wgNamespaceNumber && n( { p: document.getElementById( "mw-scribunto-console" ), id: "mw-scribunto-input", ok: function ( t, e ) { e && e.disconnect, t.setAttribute( "accesskey", "/" ) }	} ) } );

/** * Add Special:TrackingCategories backlink to tracking categories. **/ mw.loader.using( "mediawiki.Title", function {	var e, r, t, a,		n = "page-header__page-subtitle",		g = new mw.Title( "TrackingCategories", -1 ).getUrl;	14 === cfg.wgNamespaceNumber &&	/view|history/.test( cfg.wgAction ) &&	!$( "." + n + ' a[href="' + g + '"]' ).length &&	( e = "broken-file-category|cite-tracking-category-cite-error|deprecated-self-close-category|duplicate-args-category|expansion-depth-exceeded-category|expensive-parserfunction-category|hidden-category-category|index-category|magiclink-tracking-isbn|math-tracking-category-error|math-tracking-category-render-error|node-count-exceeded-category|noindex-category|post-expand-template-argument-category|post-expand-template-inclusion-category|restricted-displaytitle-ignored|scribunto-common-error-category|scribunto-module-with-errors-category|syntaxhighlight-error-category|template-loop-category|timeline-tracking-category".split( "|" ), r = "trackingcategories", e.push( r ), getMessages( e ).then( function( e ) {			Object.values( e ).includes( cfg.wgTitle ) &&			( t = e[ r ], ( e = ( a = $( "." + n ) ).length ) || ( a = $( " ", { class: n } ), $( ".page-header__main" ).append( a ) ), a.prepend( [					"&lt; ",					$( "", { href: g,						title: t,						text: t					} ),					e && " | "				] ) )		} )	) } );

// Temp fix for media in classic categories. $( function {	'use strict';	if ( cfg.wgNamespaceNumber !== 14 || $( '.wikia-gallery-item .gallerytext' ).length > 0 ) {		return;	}

mw.loader.using( [ 'mediawiki.util', 'mediawiki.Title' ], function {		const re = /^(.+?) \((\d+[^]+)\)$/;		mw.util.addCSS( '.galleryfilename { display: block; } ' );		mw.util.addCSS( '.galleryfilename-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }' );		$( '.wikia-gallery-item' ).each( function ( _, item ) { var anchor = $( '.thumb .image', item ), m = re.exec( anchor.attr( 'title' ) ), name = m[1], size = m[2], filename = mw.Title.newFromFileName( name ), galleryText = $( ' ' ) .addClass( 'gallerytext' ), galleryFilename = $( '' ) .addClass( 'galleryfilename galleryfilename-truncate' ) .attr( 'href', anchor.attr( 'href' ) ) .attr( 'title', filename.getPrefixedText ) .text( name ); galleryText.append( [ galleryFilename, size ] ); $( item ).append( galleryText ); } );	} ); } ); //