User:Penguin-Pal/global.js

/*
 * FANDOM BOT WARNING: Starting with the next release Global User CSS & JS
 * will be loaded from community.fandom.com.
 * The contents of this page have been copied to community.fandom.com.
 * Further changes to this page will not affect the site.

(function(date) {	console.log("%c" + new Array(97).join("=") + "\n@@ [" + "%cglobal.js" + "%c] :: [" + date.split("/")[0] + " V %c " + date.split("/")[1] + " %c] :: w:c:community:Special:MyPage/global.js loaded\n" + new Array(97).join("="), "", "color: #c00; font-weight: bold; background: #ff0;", "", "color: #000; background: #0c0", ""); }("2020-08-03/2")); // yyyy-mm-dd/daily_version

/* imports - pre-import settings for scripts */

// catnav window.CatNav = { debug: true };

/* imports */ importArticles({	type: 'script',	articles: [		'u:dev:MediaWiki:WikiActivity/code.js',       'u:dev:MediaWiki:MultiUpload.js'/*,        'u:dev:MediaWiki:CatNav/code.js'*/	] });

/* quick go-to-wiki field. for people who don't type text into the browser's url field like apes like me */ (function {   var toolbar = document.querySelector("body > #WikiaBar .toolbar .tools"),        nodes = {},		c = document.createElement("style"); // mw.util.addCSS seems to not preload    // initiate nodes    nodes.li = document.createElement("li");    nodes.nav = document.createElement("nav");    nodes.button = document.createElement("div");    nodes.link = document.createElement("a");    nodes.input = document.createElement("input");    nodes.nav.id = "goto-wiki";    // attributes    nodes.link.setAttribute("target", "_blank");    nodes.input.type = "text";    nodes.input.placeholder = "Go to wiki";    // hierarchy    nodes.link.appendChild(nodes.input);    nodes.nav.appendChild(nodes.button);    nodes.nav.appendChild(nodes.link);    nodes.li.appendChild(nodes.nav);    // events    nodes.button.addEventListener("click", function { nodes.input.select; });   nodes.input.addEventListener("keydown", function(e) { var a = this.value; if (e.which == 13 && /[a-z0-9]+(?:\.[a-z0-9]+)?/i.test(a)) { nodes.link.setAttribute("href", "/wiki/w:c:" + a + ":Special:WikiActivity"); }   });    // insert    toolbar.appendChild(nodes.li);    // css	c.type = "text/css";	c.textContent = ('nav#goto-wiki {\n' + '\tposition: relative;\n' + '\tmargin-top: -2px;\n' + '}\n' + 'nav#goto-wiki div {\n' + '\tposition: absolute;\n' + '\ttop: 0;\n' + '\tleft: 0;\n' + '\twidth: 200px;\n' + '\theight: 18px;\n' + '\tcursor: pointer;\n' + '}\n' + 'nav#goto-wiki input {\n' + '\twidth: 196px;\n' + '\theight: 14px;\n' + '\tmargin: 0;\n' + '\tpadding: 1px;\n' + '\tline-height: 18px;\n' + '\tbackground: #ffffff !important;\n' + '\tborder: 1px solid #ccc;\n' + '\tfont-size: 12px;\n' + '}');	document.head.appendChild(c); });

/* force-save oasis/hydra skins, because for some reason fandom changes the layout more times an hour than an embarrassed chameleon */ $(function {	// if skin is fandom desktop (regex just in case they gonna use a different one)	if (/fandom/i.test(mw.config.get("skin"))) {		new mw.Api.get({ action: "query", meta: "tokens" }).done(function(a) { console.log("[skin fixer :: query token :: done]", a); var token = a.query.tokens.csrftoken, newSkin = mw.config.get("isGamepedia") ? "hydra" : "oasis"; new mw.Api.post({				action: "options",					change: "skin=" + newSkin,					token: token			}).done(function(a) {				console.log("[skin fixer :: save preferences :: done]", a);			}); });	} });