-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
31 lines (23 loc) · 898 Bytes
/
Copy pathcontent.js
File metadata and controls
31 lines (23 loc) · 898 Bytes
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
console.log("RED/GREEN SPRITE OVERLAY LOADED");
function replaceSprite(img) {
if (!img.src.includes("play.pokemonshowdown.com/sprites/")) return;
if (!img.src.includes("/sprites/gen1/") && !img.src.includes("/sprites/gen1-back/")) return;
const original = new URL(img.src);
const localPath = "sprites" + original.pathname.split("/sprites")[1];
const localUrl = chrome.runtime.getURL(localPath);
if (img.src !== localUrl) {
img.src = localUrl;
}
const isBack = img.src.includes("/gen1-back/");
img.style.transform = isBack ? "scale(1.9)" : "scale(1)";
img.style.transformOrigin = "center center";
img.style.imageRendering = "pixelated";
}
function replaceAllSprites() {
document.querySelectorAll("img.pixelated").forEach(replaceSprite);
}
replaceAllSprites();
new MutationObserver(replaceAllSprites).observe(document.body, {
childList: true,
subtree: true
});