User:Williek11/global.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:Rollback/code.js',        'u:dev:MediaWiki:AnchoredRollback/code.js',        'u:dev:MediaWiki:UsefulDropdown/code.js',		'u:dev:MediaWiki:RemoveTracking.js',		'u:dev:MediaWiki:MassProtect/code.js',		'u:dev:MediaWiki:AjaxBatchDelete.js',		'u:dev:MediaWiki:MassRollback.js',        'u:dev:MediaWiki:DisplayTimer/code.js',    ] });

if (location.search.includes("action=edit")) { window.onbeforeunload = function{ return '' }; }

// navbar adjustments

const callWhenNodes = function{ const mainContainer = $(".main-container")[0]; const resizableContainer = $(".resizable-container")[0]; if (mainContainer === undefined || resizableContainer === undefined) {setTimeout(callWhenNodes, 60); return;} const sideContainer = document.createElement("div"); const dualContainer = document.createElement("div"); sideContainer.className = "side-container"; dualContainer.className = "dual-container"; dualContainer.appendChild(sideContainer); dualContainer.appendChild(resizableContainer); mainContainer.insertBefore(dualContainer, $(".global-footer")[0]); };

const callWhenApi = function{ if (mw.Api === undefined || $(".main-container")[0] === undefined) {setTimeout(callWhenApi, 60); return} new mw.Api.get({		action: 'query',		format: 'json',		list: 'backlinks',		bltitle: mw.config.get("wgPageName"),	}).done(function(data) {		var arr = [];		var backlinks = data.query.backlinks;		window.whatlinkshere = [];		for (var i = 0, l = backlinks.length; i < l; i++) {			window.whatlinkshere.push(backlinks[i].title);		}		$(".tools")[0].appendChild((function{			var li = document.createElement("li");			li.textContent = "What links here: "+whatlinkshere.length;			li.title = whatlinkshere.join(", ");			return li;		}));	}); /* THEME SWITCH $(".wiki-tools__theme-switch")[1].addEventListener("click", function {		new mw.Api.get({action:"query", meta:"tokens"}).done(function(e){ var change; if ($("body")[0].classList.contains("theme-fandomdesktop-dark")) { change = 'theme=light'; } else { change = 'theme=dark'; }			new mw.Api.post({		       action: 'options',		        format: 'json',		        change: change,		        token: e.query.tokens.csrftoken		    }).done(function(e){		    	if (e.options === "success") {		    		location.reload;		    	} else {		    		console.error(e);		    	}		    }); });	}); */

};

const callWhenNode = (function{	const node = $("#my-tools-menu")[0];	if (node === undefined) {setTimeout(callWhenNode, 60);return;}	const li = document.createElement("li");	const a = document.createElement("a");	a.href = location.search === "" ? location + "?useuserjs=0&useusercss=0" : location + "&useuserjs=0&useusercss=0";	a.textContent = "Remove Customization";	li.appendChild(a);	node.appendChild(li); });

callWhenNodes; callWhenApi; callWhenNode;