-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomNodeColoring.js
More file actions
100 lines (57 loc) · 2.78 KB
/
CustomNodeColoring.js
File metadata and controls
100 lines (57 loc) · 2.78 KB
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
91
92
93
94
95
96
97
98
99
100
// ==UserScript==
// @name Color Your Nodes
// @namespace Color Your Nodes
// @match https://neal.fun/infinite-craft/*
// @grant none
// @version 1.0
// @author -
// @description 5/11/2024, 10:22:10 PM
// ==/UserScript==
(function(){
LetterColors={ 'A': [0, 127, 255],'B':[139,69,19],'C':[220, 20, 60],'D':[240, 225, 48],
'E': [ 80, 200, 120], 'F': [217,2,125], 'G': [0,255,0], 'H': [223, 115, 255],
'I': [75,0,130], 'J': [ 0, 168, 107], 'K': [ 195, 176, 145], 'L': [220,208,255],
'M': [255,0,144], 'N': [0,0,128], 'O': [255, 165, 0], 'P': [160, 32, 240],
'Q': [ 81, 65, 79], 'R': [255,0,0], 'S': [250, 128, 114], 'T': [0,128,128],
'U': [4, 55, 242], 'V': [ 127, 0, 255], 'W': [255,255,255], 'X': [241, 180, 47],
'Y': [255,255,0], 'Z': [0, 20, 168]
};
function keyaction(k){
let keys=String.fromCharCode(k.charCode).toUpperCase();
let node=document.querySelector(".mouseOver");
if(node==null)
return;
node.style.borderColor="rgb("+LetterColors[keys[0]][0].toString()+","+LetterColors[keys[0]][1].toString()+","+LetterColors[keys[0]][2].toString()+")";
node.style.borderImage="";
}
function doStuffOnInstancesMutation(mutations) {
for (const mutation of mutations) {
if (mutation.addedNodes.length > 0) {
for (const node of mutation.addedNodes) {
if(node.id!="instance-0")
{
node.addEventListener("mouseover",(e)=>{
node.classList.add("mouseOver");
});
node.addEventListener("mouseout",(e)=>{
if( node.classList.contains("mouseOver"))
node.classList.remove("mouseOver");
}
);
}}}}}
function initChooseColorForNode()
{
const instanceObserver = new MutationObserver((mutations) => {
doStuffOnInstancesMutation(mutations);
});
instanceObserver.observe(document.getElementsByClassName("instances")[0], {
childList: true,
subtree : true,
});
document.addEventListener("keypress",(k)=>keyaction(k));
}
window.addEventListener('load', async () => {
initChooseColorForNode();
;
}, false);
})();