User:Himmalerin/global.js

$(function {	window.himmalerinGlobalJS = {		importJS: function importJS {			console.log('global js: start func importJS', 2);			mw.loader.load('https://ucp.fandom.com/wiki/User:Himmalerin/oasis.js?action=raw&ctype=text/javascript');			importArticles({ type: 'script', articles: [ // Convert the editor's title into a link //'u:dev:MediaWiki:VisualEditorTitleLink.js', 'u:dev:MediaWiki:WatchlistTab.js', ],			});			console.log('global js: end func importJS');		},

/**		 * !bang * Enable DuckDuckGo-like "bangs" * Originally written "KurwaAntics" on https://dev.fandom.com/wiki/!bang * Modified by User:Himmalerin to a) not use jQuery and b) support more bangs. */		bang: function bang { console.log('global js: start func bang'); document .querySelector('.wds-global-navigation__search-input') .addEventListener('keyup', function {					var txt = this.value,						m = txt.match(/^\!([a-z]+) /),						namespaces;

if (m) { namespaces = { t: 'Template', mw: 'MediaWiki', s: 'Special', h: 'Help', m: 'Module', f: 'File', u: 'User', ut: 'User talk', umw: 'Message wall', p: 'Project', c: 'Category', };

if (namespaces.hasOwnProperty(m[1])) { this.value = namespaces[m[1]] + ':' + txt.substr(m[1].length + 2); }					}				});

console.log('global js: end func bang'); },

/**		 * ExpandSearch * Have the search bar expanded regardless of screen size */		expandSearch: function expandSearch { console.log('global js: start func expandSearch'); var nav = document.getElementById('globalNavigation'), cb = function { if (!nav.classList.contains('wds-search-is-active')) { nav.classList.add('wds-search-is-active'); }				},				observer = new MutationObserver(cb);

observer.observe(nav, { attributes: true }); cb; console.log('global js: end func expandSearch'); },	};

window.himmalerinGlobalJS.importJS; window.himmalerinGlobalJS.bang; window.himmalerinGlobalJS.expandSearch; });