User:Aeywoo/global.js

// Aeywoo's Global JS v2, Courtesy of Caburum's Global JS v3 https://community.fandom.com/wiki/User:Caburum/global.js

// Placement configuration options mw.loader.using("mediawiki.util").then(function {	mw.hook("dev.placement").add(function(placement) { placement.script("MWPagesToolbarLink"); $(placement.element("tools"))[placement.type("prepend")](			$("").append( $("", {					text: "MW Pages",					href: mw.util.getUrl("Special:AllPages", { namespace: 8 })				})			)		);	}); });

window.dev = window.dev || {}; window.aeywoo = { // Declare static stuff, extended in the main JS	wg: mw.config.get([		"isGamepedia",		"profileUserId",		"skin",		"wgArticleId",		"wgCanonicalSpecialPageName",		"wgCityId",		"wgContentLanguage",		"wgNamespaceIds",		"wgNamespaceNumber",		"wgPageName",		"wgScriptPath",		"wgTitle",		"wgUserGroups",		"wgUserName"	]), init: function { // Runs main JS		if (mw.util.getParamValue("useglobaljs") || mw.util.getParamValue("useaeyjs")) return this.log("Did not execute global.js from Community Central, disabled"); this.main(this, window.mediaWiki, window.jQuery); },	log: function { // Formatted console.log console.log.apply(null, Array.prototype.concat("%c[AEYWOO]", "color:#FF7DF6; background-color:#111", Array.prototype.slice.call(arguments))); },	scripts: [] };

window.aeywoo.main = function(aey, mw, $) { if (aey.mainJSLoaded) return; // Already loaded aey.mainJSLoaded = true;

// Shortcuts aey.wg.isBot = /bot/i.test(aey.wg.wgUserName) || aey.wg.wgUserGroups.includes("bot") || mw.util.getParamValue("bot"); aey.wg.isAdmin = /sysop/.test(aey.wg.wgUserGroups.join("|")); aey.wg.isCMod = /sysop|content-moderator/.test(aey.wg.wgUserGroups.join("|")); aey.wg.isDMod = /sysop|threadmoderator/.test(aey.wg.wgUserGroups.join("|")); aey.wg.wgSpecial = aey.wg.wgCanonicalSpecialPageName;

// Script config $.extend(true, window, {		// 1. w:c:dev:GamepediaNav		GamepediaNav: {			replaceLinks: true		},		// 2. w:c:dev:MultiUpload		MultiUploadoption: {			defaultlicense: "Fairuse",			// defaultlicense: "From Wikimeda",			max: 80		},		// 3. w:c:dev:CustomizeAce		aceCustomSettings: {			wrap: true,			theme: "tomorrow_night",			tabSize: 4,			showInvisibles: false		},		// 4. w:c:dev:AutoCreateUserPages		AutoCreateUserPagesConfig: {			content: {				2: "",				3: "",				1202: false			},			summary: "Creating my user page."		},		// 5. w:c:dev:AnnouncementsIgnore		announcementsIgnore: {			option: "opt-out-all",			exceptWikiIds: [				177, // Community Wiki				7931, // Dev Wiki				627068, // The Simpsons Hit And Run Wiki				751296, // Steam Trading Cards Wiki				922669, // Unturned Bunker Wiki				1209784, // Unturned Mods Wiki				1217529, // The Ultimate Driving Wiki				1606034, // Car Mechanic Simulator Wiki 1752064, // Control Wiki 1995962, // Quantum Science Wiki 2294461, // Minecraft Wiki 2577005, // INFRA Wiki 2743058, // PowerWash Simulator Wiki 2873388, // Don't Escape Wiki 2897673, // The Nuclear Blaze Wiki ]		},		// 6. w:c:dev:GlobalNavButtons globalNavButtons: [] });

// w:c:dev:GlobalNavButtons aey.globalNavLink = function(title, url, args) { // Creates a GlobalNavButtons object for an external link args = { p: args.p || undefined, m: args.m || false, i: (args.i || {}).outerHTML || args.i || undefined };		return { text: title, url: url, isMain: args.m ? true : false, whoIsMain: args.m ? false : args.p, shortName: args.m ? args.m : title, icon: args.i		}; };

aey.globalNavPage = function(title, page, args) { // Creates a GlobalNavButtons object for an internal page return aey.globalNavLink(title, mw.util.getUrl(page) + (args.r ? "?" + args.r : ""), args); };

mw.hook("dev.wds").add(function(wds) {		window.globalNavButtons.push( // Wikis aey.globalNavPage("Wikis", "", {m: "wikis", i: wds.icon("wikis")}), aey.globalNavPage("SOAP Wiki", "w:c:soap", {p: "wikis"}), aey.globalNavPage("Developer Hub", "w:c:dev", {p: "wikis"}), aey.globalNavPage("Portability Hub", "w:c:portability", {p: "wikis"}), aey.globalNavPage("Templates Wiki", "w:c:templates", {p: "wikis"}), aey.globalNavPage("JustLeafy's Wiki", "w:c:justleafy", {p: "wikis"}), aey.globalNavPage("Adoption Requests", "w:c:Adoption:Requests", {p: "wikis"}), aey.globalNavPage("Community Central", "w:", {p: "wikis"}), aey.globalNavPage("Interlanguage link requests", "w:c:Project:Interlanguage_link_requests", {p: "wikis"}), aey.globalNavPage("UCP Internal Test Starter Wiki", "w:c:ucp-internal-test-starter", {p: "wikis"}), // Game Wikis aey.globalNavPage("Games", "", {m: "games", i: wds.icon("games")}), aey.globalNavPage("INFRA Wiki", "w:c:infra", {p: "games"}), aey.globalNavPage("Control Wiki", "w:c:control", {p: "games"}), aey.globalNavPage("Terra Nil Wiki", "w:c:terranil", {p: "games"}), aey.globalNavPage("Unturned Wiki", "w:c:unturned", {p: "games"}), aey.globalNavPage("The Don't Escape Wiki", "w:c:dont-escape", {p: "games"}), aey.globalNavPage("The Nuclear Blaze Wiki", "w:c:nuclear-blaze", {p: "games"}), aey.globalNavPage("Steam Trading Cards Wiki", "w:c:steamtradingcards", {p: "games"}), aey.globalNavPage("PowerWash Simulator Wiki", "w:c:powerwash-simulator", {p: "games"}), aey.globalNavPage("Ultimate Driving Universe Wiki", "w:c:ultimate-driving", {p: "games"}), aey.globalNavPage("Car Mechanic Simulator 2018 Wiki", "w:c:car-mechanic-simulator-2018", {p: "games"}), // Personal Global Links aey.globalNavPage("Global", "", {m: "global", i: '<path d="M12.0000002,1.99896738 C17.523704,1.99896738 22.0015507,6.47681407 22.0015507,12.0005179 C22.0015507,17.5242217 17.523704,22.0020684 12.0000002,22.0020684 C6.47629639,22.0020684 1.99844971,17.5242217 1.99844971,12.0005179 C1.99844971,6.47681407 6.47629639,1.99896738 12.0000002,1.99896738 Z M14.9389045,16.5002571 L9.06109593,16.5002571 C9.71313678,18.9143799 10.8464883,20.5020684 12.0000002,20.5020684 C13.1535121,20.5020684 14.2868636,18.9143799 14.9389045,16.5002571 Z M7.50830976,16.5008106 L4.78582644,16.5006803 C5.744167,18.0337454 7.17761035,19.2393418 8.87999355,19.9113065 C8.35771536,19.0914835 7.92672586,18.0651949 7.60972411,16.8958162 L7.50830976,16.5008106 L7.50830976,16.5008106 Z M19.214174,16.5006803 L16.4916907,16.5008106 C16.167923,17.8345819 15.700316,19.000392 15.1189501,19.9113639 C16.7159251,19.2813431 18.0755983,18.1823607 19.0289676,16.7842422 L19.214174,16.5006803 L19.214174,16.5006803 Z M7.09342418,9.9998686 L3.73581796,9.9998686 L3.73581796,9.9998686 L3.73106043,10.0170734 C3.57897914,10.6534279 3.49844971,11.3175685 3.49844971,12.0005179 C3.49844971,13.0566718 3.69103899,14.0678442 4.04301473,15.000832 L7.21617552,15.0004667 C7.07387589,14.0513637 6.99844971,13.0431468 6.99844971,12.0005179 C6.99844971,11.3165055 7.03091285,10.6473039 7.09342418,9.9998686 Z M15.3969276,9.99993255 L8.60307281,9.99993255 C8.53505119,10.640197 8.49844971,11.3099099 8.49844971,12.0005179 C8.49844971,13.0600224 8.5845969,14.070347 8.73818201,15.000607 L15.2618184,15.000607 C15.4154035,14.070347 15.5015507,13.0600224 15.5015507,12.0005179 C15.5015507,11.3099099 15.4649492,10.640197 15.3969276,9.99993255 Z M20.2646076,9.999033 L16.9065762,9.99988793 C16.9690876,10.6473039 17.0015507,11.3165055 17.0015507,12.0005179 C17.0015507,13.0431468 16.9261245,14.0513637 16.7838249,15.0004667 L19.9569857,15.000832 C20.3089614,14.0678442 20.5015507,13.0566718 20.5015507,12.0005179 C20.5015507,11.3111121 20.4194915,10.6408723 20.2646076,9.999033 Z M8.88105029,4.0896719 L8.85814489,4.09838857 C6.81083065,4.91309834 5.15481653,6.500408 4.25014894,8.50027116 L7.29826946,8.50063757 C7.61162388,6.74784533 8.15846945,5.22192073 8.88105029,4.0896719 Z M12.0000002,3.49896738 L11.8843481,3.50426666 C10.6189068,3.62002448 9.39642826,5.62198962 8.82871306,8.50021862 L15.1712874,8.50021862 C14.6051632,5.63005613 13.3879407,3.63125276 12.1262908,3.50528435 L12.0000002,3.49896738 Z M15.1200069,4.08972931 L15.2268438,4.26382329 C15.8960528,5.37628985 16.4041675,6.83617446 16.701731,8.50063757 L19.7498515,8.50027116 C18.8852005,6.58886886 17.3342021,5.05432991 15.4112068,4.21100469 L15.1200069,4.08972931 Z"> '}), aey.globalNavPage("Perferences", "Special:Preferences", {p: "global"}), aey.globalNavPage("Common CSS", "Special:MyPage/common.css", {p: "global"}), aey.globalNavPage("Common JS", "Special:MyPage/common.js", {p: "global"}), aey.globalNavPage("Global CSS", "w:Special:MyPage/global.css", {p: "global"}), aey.globalNavPage("Global JS", "w:Special:MyPage/global.js", {p: "global"}), aey.globalNavPage("Subpages", "Special:PrefixIndex/User:" + aey.wg.wgUserName + "/", {p: "global"}), aey.globalNavPage("Sandbox", "Special:MyPage/Sandbox", {p: "global"}), // Wiki CSS/JS Links aey.globalNavPage("CSS/JS", "", {m: "cssjs", i: ' '}), aey.globalNavPage("ImportJS", "MediaWiki:ImportJS", {p: "cssjs"}), aey.globalNavPage("Wikia JS", "MediaWiki:Wikia.js", {p: "cssjs"}), aey.globalNavPage("Wikia CSS", "MediaWiki:Wikia.css", {p: "cssjs"}), aey.globalNavPage("Common JS", "MediaWiki:Common.js", {p: "cssjs"}), aey.globalNavPage("Common CSS", "MediaWiki:Common.css", {p: "cssjs"}), aey.globalNavPage("FandomDesktop JS", "MediaWiki:Fandomdesktop.js", {p: "cssjs"}), aey.globalNavPage("FandomDesktop CSS", "MediaWiki:Fandomdesktop.css", {p: "cssjs"}), // Wiki File Links aey.globalNavPage("Files", "", {m: "files", i: wds.icon("images")}), aey.globalNavPage("Recent Changes", "Special:RecentChanges", {p: "files"}), aey.globalNavPage("New Pages", "Special:NewPages", {p: "files"}), aey.globalNavPage("New Files", "Special:NewFiles", {p: "files"}), aey.globalNavPage("Upload", "Special:Upload", {p: "files"}), // Other Links aey.globalNavPage("Special", "", {m: "special", i: '   '}), aey.globalNavLink("Zendesk Request", "https://support.fandom.com/hc/en-us/requests/new?ticket_form_id=360000931354", {p: "special"}), aey.globalNavPage("Wiki Navigation", "MediaWiki:Wiki-navigation", {p: "special"}), aey.globalNavPage("Special Pages", "Special:SpecialPages", {p: "special"}), aey.globalNavPage("List Users", "Special:ListUsers/sysop", {p: "special"}), aey.globalNavPage("Licenses", "MediaWiki:Licenses", {p: "special"}), // Extra Links aey.globalNavPage("Links", "", {m: "links"}), aey.globalNavLink("Steam Card Exchange", "https://www.steamcardexchange.net/index.php", {p: "links"}), aey.globalNavLink("Steam Trading Cards", "https://steam.tools/cards/", {p: "links"}), aey.globalNavLink("Autoprefixer CSS", "https://autoprefixer.github.io/", {p: "links"}), aey.globalNavLink("Completionist Me", "https://completionist.me/", {p: "links"}), aey.globalNavLink("Colour Picker", "https://www.google.com.au/search?q=Colour+Picker", {p: "links"}), aey.globalNavLink("W3Schools", "https://www.w3schools.com/", {p: "links"}), // Friends aey.globalNavPage("Frens", "", {m: "friends", i: wds.icon("users")}), aey.globalNavPage("Friendly Mountain12", "User:Friendly_Mountain12", {p: "friends"}), aey.globalNavPage("Saurmandal", "User:Saurmandal", {p: "friends"}), aey.globalNavPage("JustLeafy", "User:JustLeafy", {p: "friends"}), aey.globalNavPage("Sophiedp", "User:Sophiedp", {p: "friends"}), aey.globalNavPage("Dorumin", "User:Dorumin", {p: "friends"}), aey.globalNavPage("Philo04", "User:Philo04", {p: "friends"}), aey.globalNavPage("Dorito", "User:Joritochip", {p: "friends"}), aey.globalNavPage("Robyn", "User:Robyn_Grayson", {p: "friends"}) );	});	// This is basically only available to local wiki staff ranks if (aey.wg.isAdmin || aey.wg.isCMod || aey.wg.isDMod) { window.globalNavButtons.push(			aey.globalNavPage("Staff", "", {m: "staff"})		); }	if (aey.wg.isAdmin) { window.globalNavButtons.push(			aey.globalNavPage("Admin Dashboard", "Special:AdminDashboard", {p: "staff"}),			aey.globalNavPage("Announcements", aey.wg.wgScriptPath + "/announcements", {p: "staff"}),			aey.globalNavPage("Theme Designer", "Special:ThemeDesigner", {p: "staff"}),			aey.globalNavPage("Delete Reasons", "MediaWiki:Deletereason-dropdown", {p: "staff"}),			aey.globalNavPage("User Rights", "Special:UserRights", {p: "staff"}),			aey.globalNavPage("Block", "Special:Block", {p: "staff"})		); }

if (aey.wg.isAdmin || aey.wg.isCMod || aey.wg.isDMod) { window.globalNavButtons.push(			aey.globalNavPage("Message Deletion", "Special:SocialActivity", {p: "staff", r: "deleted=true&containerTypes=WALL"}),			aey.globalNavLink("Reported Posts", aey.wg.wgScriptPath + "/f/reported", {p: "staff"})		); }

if (aey.wg.wgNamespaceIds.gadget) { window.globalNavButtons.push(			aey.globalNavPage("Gadgets", "Special:Gadgets", {p: "special"})		); }

// Execute local JS only if main JS ran if (mw.util.getParamValue("uselocaljs")) { aey.log("Did not execute common.js, disabled"); } else { mw.hook("aeywoo.runLocalJS").fire(aey); }

// Scripts to import per source, dependent on user groups // 1 for always, 2 for bot, see below for more advanced options aey.scripts.push(		{			prefix: "u:dev:MediaWiki:",			scripts: {				"Q": 1,				"AjaxRC": 1,				"Stella": 1,				"DupeArgs": 1,				"CopyTitle": 1,				"Placement": 1,				"MultiUpload": 1,				"PurgeButton": 1,				"CustomizeAce": 1,				"GamepediaNav": 1,				"ThemeToggler": 1,				"UCXSearchBar": 1,				"FastFileDelete": 1,				"AjaxBatchDelete": 1,				"HistoryKey/code": 1,				"MassRename/code": 1,				"GlobalNavButtons": 1,				"ImportJSPage/code": 1,				"AnnouncementsIgnore": 1,				"AutoCreateUserPages": 1,				"DedicatedTalkButton": 1,				"FixWantedFiles/code": 1,				"ViewInContentLang/code": 1,				"MassCategorization/code": 1,				/* Disabled Section				"HydraRevived": 1,				"OasisRevived": 1,				"MassEdit/code": 1,				"ThemeSelector": 1,				"SyntaxHighlight": 1,				"DisableCode/code": 1,				"AnchoredRollback/code": 1,*/			}		}	);

// Load scripts based on criteria var articles = []; function processScript(script, d) { var g = []; if (Array.isArray(d)) { // array of groups g = d;		} else if (typeof d === "string") { // single group g = [d]; } else if (typeof d === "object" && d !== null) { // advanced config g = g.concat(d.groups || d.group || true); if ((d.skins || d.skin) && ![].concat(d.skins || d.skin).includes(aey.wg.skin)) return; if ((d.wikis || d.wiki) && ![].concat(d.wikis || d.wiki).includes(aey.wg.wgCityId)) return; if (d.ns && ![].concat(d.ns).includes(aey.wg.wgNamespaceNumber)) return; } else if (d === 2) { // bot g = [aey.wg.isBot]; } else if (Boolean(d)) { // truthy value g = [true]; } else return;

// If all other checks pass, then check groups if (g[0] === true || g.filter(function(group) { return aey.wg.wgUserGroups.includes(group) }).length > 0) { articles.push(script); }	}	aey.scripts.forEach(function(s) {		if (!s) return; // If falsy, do nothing		if (typeof s === "object") { // Group of scripts from a single source			$.each(s.scripts, function(script, d) { processScript(s.prefix + script + ".js", d); });		} else { // Singular script			processScript(s, true);		}	}); importArticles({		type: "script",		articles: articles	}); importScriptPage("User:KockaAdmiralac/LinkModifications.js", "kocka"); aey.log("Executed global.js from Community Central"); };

mw.loader.using("mediawiki.util", function {	$(window.aeywoo.init.bind(window.aeywoo)); });