-
Notifications
You must be signed in to change notification settings - Fork 0
/
substitute.js
33 lines (30 loc) · 1.01 KB
/
substitute.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
function replaceSchland (node) {
if (node.nodeName === "IMG" && node.classList.contains("Emoji")) {
if (node.src.endsWith("/1f1e9-1f1ea.png")) {
node.src = node.src.replace("/1f1e9-1f1ea.png", "/1f954.png");
}
} else if (node.nodeName === "SPAN" && node.classList.contains("Emoji")) {
if (node.style.backgroundImage.endsWith("/1f1e9-1f1ea.png\")")) {
node.style.backgroundImage = node.style.backgroundImage.replace("/1f1e9-1f1ea.png", "/1f954.png");
}
} else {
for (let i = 0; i < node.childNodes.length; i++) {
replaceSchland(node.childNodes[i]);
}
}
}
replaceSchland(document.body);
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
for (let i = 0; i < mutation.addedNodes.length; i++) {
const newNode = mutation.addedNodes[i];
replaceSchland(newNode);
}
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});