From 34ad953c953a395ba3e51c8125034a6bb65b2a79 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Mon, 13 Feb 2023 22:49:42 +0530 Subject: Fixed not being able to import modules in scripts. --- src/scripts/optimize/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/scripts/optimize/index.ts') 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}); -- cgit v1.2.3