User:BryghtShadow/global.js

window.PortableListUsers = { avatars: false, editcount: '5', landing: 'content-moderator', storage: true, time: 'utc' }; var articles = [ // Scripts for doing Vanguard work. 'u:community:MediaWiki:Van-RedirectCategories.js', 'u:dev:MediaWiki:PortableListUsers.js', 'u:dev:MediaWiki:ShowWROnToolbar.js', 'u:dev:MediaWiki:VanguardTools.js', // Regular scripts. 'u:dev:MediaWiki:ImportJSPage/code.js', 'u:dev:MediaWiki:ThemeToggler.js', ]; if (document.querySelector('.is-gamepedia')) { mw.loader.getScript('https://dev.fandom.com/wiki/MediaWiki:ArticlesAsResources.js?action=raw&ctype=text/javascript').then(function {		importArticles({ type: 'script', articles: articles, });	}); } else { importArticles({		type: 'script',		articles: articles,	}); } // https://discord.com/channels/563020189604773888/824996318853595146/851520351464718396 $(function {   if (mw.config.get('skin') !== 'fandomdesktop') return;    var theme = mw.util.getParamValue('usetheme');    if (['light','dark'].indexOf(theme) === -1) return;    $.get(mw.util.wikiScript('wikia')+'?controller=ThemeApi&method=themeVariables&variant='+theme+'&cb='+(new Date.getTime)).done(function(data){ var $s = $('#pcjThemeSwitch')[0] || $(' ').attr('id','pcjThemeSwitch').appendTo('body'); $($s).text(data); $('body').removeClass('theme-fandomdesktop-light theme-fandomdesktop-dark').addClass('theme-fandomdesktop-'+theme); }); });

$(function {	'use strict';

// https://stackoverflow.com/a/38882022 function waitForAddedNode(params) { new MutationObserver(function(mutations) {			var el = document.getElementById(params.id);			if (el) {				this.disconnect;				params.done(el);			}		}).observe(params.parent || document, {			subtree: !!params.recursive,			childList: true,		}); }	function addCodeEditorAccessKey($editform) { const $textbox = $('#wpTextbox1'); const accesskey = $textbox.attr('accesskey'); const targetNode = $editform[0]; const config = { subtree: true, attributeOldValue: true, };		const observer = new MutationObserver(function(mutations) {			mutations.forEach(function(mutation) { if (mutation.type === 'attributes' && mutation.attributeName==="class") { const target = mutation.target; if (target.id === 'wikiEditor-ui-toolbar') { const codeEditorEnabled = target.classList.contains('codeEditor-ui-toolbar'); if (codeEditorEnabled) { $('.ace_text-input').attr('accesskey', accesskey); $textbox.removeAttr('accesskey'); } else { $textbox.attr('accesskey', accesskey); }					}				}			});		});		observer.observe(targetNode, config); }	mw.hook('wikipage.editform').add(addCodeEditorAccessKey);

function addScribuntoAccessKey { // Jump to Scribunto console waitForAddedNode({			id: 'mw-scribunto-input',			parent: document.querySelector('#mw-scribunto-console'),			recursive: false,			done: function(el) {				console.log(el);				el.setAttribute('accesskey', '/');			}		}); }	if (mw.config.get('wgNamespaceNumber') === 828) { mw.hook('wikipage.editform').add(addScribuntoAccessKey); } });

$(function {	// Fix duplicate accesskey for Edit.	const editButton = $('.page-side-edit').first[0];	if (typeof editButton === 'undefined') return;	const accesskey = editButton.getAttribute('accesskey');	const $accesskey = $('[accesskey="'+accesskey+'"]');	if ($accesskey.length === 1) return;	$accesskey.each(function(_, btn) { if (btn === editButton) return; btn.removeAttribute('id'); btn.removeAttribute('accesskey'); }); });