User:BryghtShadow/global.js

'use strict';
 * (function {

console.log('w:ucp:User:BryghtShadow/global.js'); mw.loader.using([	   'mediawiki.util',	    'ext.fandom.ContentReview.legacyLoaders.js'	], function {		importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:ImportJSPage/code.js', ]		});	});	// 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); } });