Greasy Fork is available in English.

Moomoo.io New cyan color

Adds a new cyan color to the color selection panel

  1. // ==UserScript==
  2. // @name Moomoo.io New cyan color
  3. // @author Murka
  4. // @description Adds a new cyan color to the color selection panel
  5. // @icon https://moomoo.io/img/favicon.png?v=1
  6. // @version 0.2
  7. // @match *://moomoo.io/*
  8. // @match *://*.moomoo.io/*
  9. // @run-at document-start
  10. // @grant none
  11. // @license MIT
  12. // @namespace https://greasyfork.org/users/919633
  13. // ==/UserScript==
  14. /* jshint esversion:6 */
  15.  
  16. /*
  17. Author: Murka
  18. Github: https://github.com/Murka007
  19. Discord: https://discord.gg/sG9cyfGPj5
  20. Greasyfork: https://greasyfork.org/en/users/919633
  21. MooMooForge: https://github.com/MooMooForge
  22. */
  23.  
  24. (function() {
  25. "use strict";
  26.  
  27. const log = console.log;
  28. const storage = {
  29. get(key) {
  30. const value = localStorage.getItem(key);
  31. return value === null ? null : value;
  32. },
  33. set(key, value) {
  34. localStorage.setItem(key, typeof value !== "string" ? JSON.stringify(value) : value);
  35. }
  36. };
  37.  
  38. // Unlock 100 resource bonus
  39. storage.set("moofoll", 1);
  40.  
  41. function createHook(target, prop, setter) {
  42. const symbol = Symbol(prop);
  43. Object.defineProperty(target, prop, {
  44. get() {
  45. return this[symbol];
  46. },
  47. set(value) {
  48. setter(this, symbol, value);
  49. },
  50. configurable: true
  51. })
  52. }
  53.  
  54. // Add cyan color to the skinColor array
  55. createHook(Object.prototype, "skinColors", function(that, symbol, value) {
  56. delete Object.prototype.skinColors;
  57. that.skinColors = [...value, "#91B2DB"];
  58. })
  59.  
  60. // When choosing a color, replace index with "toString", so server will cause some error that will make your color cyan
  61. createHook(window, "selectSkinColor", function(that, symbol, value) {
  62. delete window.selectSkinColor;
  63. window.selectSkinColor = new Proxy(value, {
  64. apply(target, _this, args) {
  65. const [ skin ] = args;
  66. target.call(_this, skin === 10 ? "toString" : skin);
  67.  
  68. storage.set("skinColor", skin);
  69. if (skin === 10) {
  70. const skins = document.querySelectorAll("#skinColorHolder > *");
  71. const last = skins[skins.length-1];
  72. last.classList.add("activeSkin");
  73. }
  74. }
  75. })
  76. })
  77.  
  78. // Select saved color on the load
  79. window.addEventListener("load", function() {
  80. const observer = new MutationObserver(mutations => {
  81. observer.disconnect();
  82. for (const mutation of mutations) {
  83. const index = storage.get("skinColor") || 0;
  84. mutation.addedNodes[index].click();
  85. }
  86. })
  87. observer.observe(document.querySelector("#skinColorHolder"), { childList: true, subtree: true });
  88. })
  89.  
  90. })();