diff options
Diffstat (limited to 'src/scripts/optimize/index.ts')
| -rw-r--r-- | src/scripts/optimize/index.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/scripts/optimize/index.ts b/src/scripts/optimize/index.ts index 8b63c53..37ae12e 100644 --- a/src/scripts/optimize/index.ts +++ b/src/scripts/optimize/index.ts @@ -1,10 +1,12 @@ +import observeDOM from "@/utils/observe-dom"; + const replace: (any[] | undefined)[] = [ ["head > script:nth-child(34)", { src: "" }], ["head > script:nth-child(43)", { src: "" }] ]; let count = 0; -const observer = new MutationObserver(() => { +observeDOM(() => { for (let i = 0; i < replace.length; i++) { if (replace[i]) { const element = document.querySelector(replace[i]![0]) as HTMLElement | null; @@ -20,11 +22,11 @@ const observer = new MutationObserver(() => { replace[i] = undefined; count++; if (count >= replace.length) { - observer.disconnect(); - break; + return true; } } } } + + return false; }); -observer.observe(document, {childList: true, subtree: true}); |
