User:The Master of Hedgehogs/Chocolate.js

// Chocolate, a utility user script // v1.1.2 Prerelease 3 (22 April 2024)

// Objects belonging to Chocolate are prefixed with "choc".

// variables const chocPath = "https://en.wikipedia.org/w/index.php?title=User:The_Master_Of_Hedgehogs/Chocolate"; const chocVersion = "1.1.2 Prerelease";

let chocEnabled = [ "Wiktionary", "Wikiquote", "Wikidata", "ExtraSandbox", "NoSiteSub", "NoCopyWarn", "LogoutConfirm", "WhatWiki", "ShowPrintFooter" ]; // will make cool Special:ChocolatePreferences page later

// functions function chocCapitalize(string) { return string.charAt(0).toUpperCase + string.slice(1); }

// load css importStylesheet("User:The Master of Hedgehogs/Chocolate.css");

// add icon and preferences link $("body").append(`				 ${chocVersion} `);

$("#pt-preferences").append(`					 (C) 		 `);

// Special:ChocolatePreferences if(mw.config.get("wgPageName") == "Special:ChocolatePreferences") { $("#firstHeading").text("Chocolate preferences"); $("#mw-content-text").text("Chocolate preferences are coming soon."); }

// link-related modules if (chocEnabled.includes("Wiktionary")) { $("#p-cactions > div > ul").append(`									 Wiktionary 						`); } if (chocEnabled.includes("Wikiquote")) { $("#p-cactions > div > ul").append(`									 Wikiquote 						`); } if (chocEnabled.includes("Wikidata")) { $("#p-cactions > div > ul").append(`									 Wikidata 						`); }

if (chocEnabled.includes("ExtraSandbox")) { $("#pt-sandbox").append(`					 (2) 		</a>	`); }

// "no" modules if (chocEnabled.includes("NoSiteSub")) { $("#siteSub").remove; } if (chocEnabled.includes("NoCopyWarn")) { $("#editpage-copywarn").remove; }

// other if (chocEnabled.includes("WhatWiki")) { const subdomain = window.location.host.split(".")[0]; const after = window.location.host.split(".")[1]; $(`			[${subdomain.toUpperCase} ${chocCapitalize(after)}]	`).appendTo('#firstHeading'); } if (chocEnabled.includes("LogoutConfirm")) {

$( document ).ready( => {	"use strict";	const LOA = document.getElementById( "pt-logout" )?.firstElementChild;	LOA?.replaceWith( LOA.cloneNode( true ) ); } ); // Fred Gandt wrote the code. I asked for permission, though, so don't worry!

} if(chocEnabled.includes("ShowPrintFooter")) { $(".printfooter").addClass("choc-printfooter"); }