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