Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Chocolate, a utility user script// v1.1.2 Prerelease 3 (22 April 2024)// Objects belonging to Chocolate are prefixed with "choc".// variablesconstchocPath="https://en.wikipedia.org/w/index.php?title=User:The_Master_Of_Hedgehogs/Chocolate";constchocVersion="1.1.2 Prerelease";letchocEnabled=["Wiktionary","Wikiquote","Wikidata","ExtraSandbox","NoSiteSub","NoCopyWarn","LogoutConfirm","WhatWiki","ShowPrintFooter"];// will make cool Special:ChocolatePreferences page later// functionsfunctionchocCapitalize(string){returnstring.charAt(0).toUpperCase()+string.slice(1);}// load cssimportStylesheet("User:The Master of Hedgehogs/Chocolate.css");// add icon and preferences link$("body").append(` <div id="choc-icon-div"> <img id="choc-icon" src="https://upload.wikimedia.org/wikipedia/commons/1/1c/Twemoji_1f36b.svg" /> <span id="choc-icon-text">${chocVersion}</span> </div>`);$("#pt-preferences").append(` <a id="choc-prefslink" href="/wiki/Special:ChocolatePreferences" title="Chocolate preferences"> <span>(C)</span> </a>`);// Special:ChocolatePreferencesif(mw.config.get("wgPageName")=="Special:ChocolatePreferences"){$("#firstHeading").text("Chocolate preferences");$("#mw-content-text").text("Chocolate preferences are coming soon.");}// link-related modulesif(chocEnabled.includes("Wiktionary")){$("#p-cactions > div > ul").append(` <li id="choc-ca-wiktionary" class="mw-list-item"> <a href="https://en.wiktionary.org/wiki/${mw.config.get("wgPageName")}" title="Corresponding Wiktionary page"> <span>Wiktionary</span> </a> </li> `);}if(chocEnabled.includes("Wikiquote")){$("#p-cactions > div > ul").append(` <li id="choc-ca-wikiquote" class="mw-list-item"> <a href="https://en.wikiquote.org/wiki/${mw.config.get("wgPageName")}" title="Corresponding Wikiquote page"> <span>Wikiquote</span> </a> </li> `);}if(chocEnabled.includes("Wikidata")){$("#p-cactions > div > ul").append(` <li id="choc-ca-wikidata" class="mw-list-item"> <a href="https://wikidata.org/wiki/Special:Search/${mw.config.get("wgPageName")}" title="Corresponding Wikidata page"> <span>Wikidata</span> </a> </li> `);}if(chocEnabled.includes("ExtraSandbox")){$("#pt-sandbox").append(` <a id="choc-sandbox2" href="/wiki/User:${mw.config.get("wgUserName")}/sandbox2" title="Your extra sandbox"> <span>(2)</span> </a> `);}// "no" modulesif(chocEnabled.includes("NoSiteSub")){$("#siteSub").remove();}if(chocEnabled.includes("NoCopyWarn")){$("#editpage-copywarn").remove();}// otherif(chocEnabled.includes("WhatWiki")){constsubdomain=window.location.host.split(".")[0];constafter=window.location.host.split(".")[1];$(` <span id="choc-whatwiki"> [${subdomain.toUpperCase()}${chocCapitalize(after)}] </span> `).appendTo('#firstHeading');}if(chocEnabled.includes("LogoutConfirm")){$(document).ready(()=>{"use strict";constLOA=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");}