Jump to content

User:Anpang/Chocolate.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Anpang (talk | contribs) at 01:54, 15 February 2022. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// MELTING CHOCOLATE BLOCK RELEASE 1.0.0 PATCH 4 - 15 FEB 2022 1:50 UTC

// PREFERENCES AREA START - EDIT THIS
// However, if you're loading up this using mw.loader, don't change it

// Enabled modules (Note: dropdown will always be enabled no matter what)
const enabled = ["websitedisplay", "uploadtocommons", "alarmclock", "nofrom", "allonblue", "nocopywarn", "5sandboxes",];

// Show watermark (off by default, turn the false into true if youre fine with the watermark)
const showwatermark = false;

// Other preferences
const preferences = {
	p:"No preferences yet. Sorry",
};

// PREFERENCES AREA END - DON'T EDIT ANYTHING BELOW THIS

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

// Watermark + nescessary variables/constants
if (showwatermark) {
  $("<div id=\"mw-mcb-topleft-watermark\" style=\"position:absolute\"><img src=\"/media/wikipedia/commons/b/b2/MCB_Topleft.png\" height=\"22px\"/> <span style=\"color:#994a00\">MCB</span></div>").prependTo('body');
}
const header = $("h1").text();

// Dropdown
$(`<nav id="mw-mcb-p-cactions" class="mw-portlet mw-portlet-cactions vector-menu-dropdown-noicon vector-menu vector-menu-dropdown" aria-labelledby="p-cactions-label" role="navigation" title="More options">
  <input type="checkbox" id="p-cactions-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-cactions" class="vector-menu-checkbox" aria-labelledby="p-cactions-label">
  <h3 id="mw-mcb-p-cactions-label" aria-label="" class="vector-menu-heading">
	<span class="vector-menu-heading-label">Options</span>
	  <span class="vector-menu-checkbox-expanded">expanded</span>
	  <span class="vector-menu-checkbox-collapsed">collapsed</span>
  </h3>
  <div class="vector-menu-content">
	<ul class="vector-menu-content-list"><li id="mw-mcb-ca-wikitionary" class="mw-list-item"><a href="https://en.wiktionary.org/wiki/${header}" title="Search this page up in the english wikitionary"><span>Wikitionary</span></a></li></ul>
	<ul class="vector-menu-content-list"><li id="mw-mcb-ca-newestpages" class="mw-list-item"><a href="/wiki/Special:RecentChanges?hidebots=1&hidepageedits=1&hidecategorization=1&hideWikibase=1&hidelog=1&limit=50&days=7&urlversion=2" title="Check out the newest pages"><span>Newest pages</span></a></li></ul>
	<ul class="vector-menu-content-list"><li id="mw-mcb-ca-colorpicker" class="mw-list-item" style="text-align:center"><input type="color" id="colorpicker" value="#0000ff" title="A color picker"></li></ul>
	<ul class="vector-menu-content-list"><li id="mw-mcb-ca-subpages" class="mw-list-item"><a href="/wiki/Special:PrefixIndex?prefix=${header}&stripprefix=1" title="Get a list of all subpages of this page"><span>Subpages</span></a></li></ul>
  </div>
</nav>`).insertBefore('#p-search');

// Start main code

if (enabled.includes("websitedisplay")) {
  const subdomain = window.location.host.split('.')[0];
  const subafters = window.location.host.split('.')[1];
  $("<span style=\"font-size:70%;color:#5c5c5c\"> [" + subdomain.toUpperCase() + " " + capitalizeFirstLetter(subafters) + "]</span>").appendTo('#firstHeading');
}

if (enabled.includes("uploadtocommons")) {
  $("<div class=\"vector-menu-content\"><ul class=\"vector-menu-content-list\" style=\"padding-top:0px\"><li id=\"n-upload\" class=\"mw-list-item\"><a href=\"https://commons.wikimedia.org/wiki/Special:UploadWizard\" title=\"Add images or other media for use on most MediaWiki wikis\"><span>Upload to commons</span></a></li></ul></div>").appendTo('.mw-portlet-interaction');
}

if (enabled.includes("5sandboxes")) {
  $(`<li id="pt-sandbox-alternatives-sandbox2" class="mw-list-item"><a href="/wiki/Special:MyPage/sandbox2" title="Your second sandbox"><span>2</span></a>
  <a href="/wiki/Special:MyPage/sandbox3" title="Your third sandbox"><span>3</span></a>
  <a href="/wiki/Special:MyPage/sandbox4" title="Your fourth sandbox"><span>4</span></a>
  <a href="/wiki/Special:MyPage/sandbox5" title="Your fifth sandbox"><span>5</span></a></li>`).insertBefore('#pt-preferences');
}

if (enabled.includes("nofrom")) {
  $("#siteSub").remove();
  // Deletes the annoying "From Wikipedia, the free encyclopedia" - everyone knows they're on wikipedia!
}

if (enabled.includes("allonblue")) {
  document.getElementById("wpPreviewWidget").setAttribute("class", "oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary oo-ui-buttonInputWidget");
  document.getElementById("wpDiffWidget").setAttribute("class", "oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary oo-ui-buttonInputWidget");
  document.getElementById("mw-editform-cancel").setAttribute("class", "oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary oo-ui-buttonInputWidget");
}

if (enabled.includes("nocopywarn")) {
  $("#editpage-copywarn").remove();
}

if (enabled.includes("alarmclock")) {
	const alarmclockfullsvg = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(41.960784%,55.294118%,63.137255%);fill-opacity:1;" d="M 12.929688 2.765625 L 12.929688 8.539062 C 12.929688 9.046875 12.511719 9.464844 12 9.464844 C 11.488281 9.464844 11.070312 9.046875 11.070312 8.539062 L 11.070312 2.765625 C 11.070312 2.253906 11.488281 1.835938 12 1.835938 C 12.511719 1.835938 12.929688 2.253906 12.929688 2.765625 Z M 17.230469 7.597656 C 17.59375 7.957031 18.179688 7.957031 18.542969 7.597656 L 20.914062 5.222656 C 21.277344 4.863281 21.277344 4.273438 20.914062 3.910156 C 20.550781 3.546875 19.964844 3.546875 19.601562 3.910156 L 17.230469 6.28125 C 16.867188 6.644531 16.867188 7.234375 17.230469 7.597656 M 6.769531 7.597656 C 7.132812 7.234375 7.132812 6.644531 6.769531 6.28125 L 4.398438 3.910156 C 4.035156 3.546875 3.449219 3.546875 3.085938 3.910156 C 2.722656 4.273438 2.722656 4.863281 3.085938 5.226562 L 5.457031 7.597656 C 5.820312 7.957031 6.40625 7.957031 6.769531 7.597656 M 18.910156 22.621094 C 19.273438 22.261719 19.273438 21.671875 18.910156 21.308594 L 14.828125 17.226562 C 14.46875 16.867188 13.875 16.867188 13.515625 17.226562 C 13.152344 17.589844 13.152344 18.179688 13.515625 18.542969 L 17.597656 22.621094 C 17.957031 22.984375 18.550781 22.984375 18.910156 22.621094 Z M 6.402344 22.621094 L 10.484375 18.542969 C 10.847656 18.179688 10.847656 17.589844 10.484375 17.226562 C 10.125 16.867188 9.53125 16.867188 9.171875 17.226562 L 5.089844 21.308594 C 4.726562 21.671875 4.726562 22.261719 5.089844 22.621094 C 5.449219 22.984375 6.042969 22.984375 6.402344 22.621094 Z M 6.402344 22.621094 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,71.372549%,21.176471%);fill-opacity:1;" d="M 16.609375 2.140625 C 18.300781 0.691406 20.855469 0.765625 22.457031 2.367188 C 24.0625 3.972656 24.136719 6.527344 22.679688 8.222656 C 22.546875 8.3125 22.375 8.320312 22.234375 8.242188 L 16.585938 2.589844 C 16.503906 2.449219 16.511719 2.273438 16.609375 2.140625 Z M 1.765625 8.238281 L 7.414062 2.589844 C 7.496094 2.453125 7.488281 2.277344 7.398438 2.148438 C 5.703125 0.691406 3.148438 0.761719 1.542969 2.367188 C -0.0625 3.972656 -0.136719 6.523438 1.316406 8.214844 C 1.449219 8.3125 1.625 8.320312 1.765625 8.238281 Z M 1.765625 8.238281 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,83.137255%,41.176471%);fill-opacity:1;" d="M 22.382812 5.085938 C 22.175781 5.085938 21.988281 4.945312 21.945312 4.734375 C 21.84375 4.28125 21.621094 3.863281 21.296875 3.527344 C 20.972656 3.191406 20.566406 2.949219 20.121094 2.828125 C 19.878906 2.765625 19.738281 2.515625 19.800781 2.277344 C 19.867188 2.035156 20.113281 1.894531 20.351562 1.957031 C 20.960938 2.121094 21.511719 2.445312 21.945312 2.902344 C 22.386719 3.359375 22.6875 3.925781 22.824219 4.539062 C 22.878906 4.78125 22.722656 5.023438 22.480469 5.078125 C 22.449219 5.082031 22.417969 5.085938 22.382812 5.085938 Z M 2.003906 4.707031 C 2.125 4.257812 2.363281 3.851562 2.699219 3.527344 C 3.039062 3.207031 3.457031 2.980469 3.910156 2.882812 C 4.152344 2.828125 4.304688 2.585938 4.25 2.34375 C 4.199219 2.101562 3.957031 1.949219 3.714844 2 C 3.101562 2.136719 2.535156 2.441406 2.078125 2.878906 C 1.621094 3.316406 1.296875 3.867188 1.132812 4.472656 C 1.097656 4.609375 1.125 4.753906 1.210938 4.863281 C 1.296875 4.972656 1.429688 5.039062 1.570312 5.039062 C 1.769531 5.039062 1.949219 4.90625 2.003906 4.707031 Z M 2.003906 4.707031 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(98.431373%,31.372549%,27.45098%);fill-opacity:1;" d="M 12 3.019531 C 6.515625 3.019531 2.070312 7.464844 2.070312 12.949219 C 2.070312 18.433594 6.515625 22.882812 12 22.882812 C 17.484375 22.882812 21.929688 18.433594 21.929688 12.949219 C 21.929688 7.464844 17.484375 3.019531 12 3.019531 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(97.647059%,97.647059%,97.254902%);fill-opacity:1;" d="M 3.925781 12.949219 C 3.925781 17.402344 7.546875 21.023438 12 21.023438 C 16.453125 21.023438 20.074219 17.402344 20.074219 12.949219 C 20.074219 8.496094 16.453125 4.875 12 4.875 C 7.546875 4.875 3.925781 8.496094 3.925781 12.949219 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(41.960784%,55.294118%,63.137255%);fill-opacity:1;" d="M 12 13.566406 L 17.773438 13.566406 C 18.058594 13.566406 18.292969 13.335938 18.292969 13.046875 C 18.292969 12.761719 18.058594 12.53125 17.773438 12.53125 L 12 12.53125 C 11.714844 12.53125 11.480469 12.761719 11.480469 13.046875 C 11.480469 13.335938 11.714844 13.566406 12 13.566406 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(41.960784%,55.294118%,63.137255%);fill-opacity:1;" d="M 12 13.566406 C 12.285156 13.566406 12.519531 13.335938 12.519531 13.046875 L 12.519531 7.398438 C 12.519531 7.113281 12.285156 6.878906 12 6.878906 C 11.714844 6.878906 11.480469 7.113281 11.480469 7.398438 L 11.480469 13.046875 C 11.480469 13.335938 11.714844 13.566406 12 13.566406 "/>
</g>
</svg>`;
	document.getElementById("alarmclock").innerHTML = alarmclockfullsvg;
	// Alarm clock svg from https://www.svgrepo.com/svg/399900/alarmclock
}