diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-02-13 22:49:42 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-02-13 22:49:42 +0530 |
| commit | 34ad953c953a395ba3e51c8125034a6bb65b2a79 (patch) | |
| tree | 253cc30047bb3963f387bd340d50938b3b727053 /src/scripts/optimize | |
| parent | aeeabaa0050ecb9e43b1a3fb309f314d92d3ca97 (diff) | |
| download | banglar-bhumi-utils-34ad953c953a395ba3e51c8125034a6bb65b2a79.tar.gz banglar-bhumi-utils-34ad953c953a395ba3e51c8125034a6bb65b2a79.zip | |
Fixed not being able to import modules in scripts.
Diffstat (limited to 'src/scripts/optimize')
| -rw-r--r-- | src/scripts/optimize/home-page.ts | 10 | ||||
| -rw-r--r-- | src/scripts/optimize/index.ts | 10 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/scripts/optimize/home-page.ts b/src/scripts/optimize/home-page.ts index 5ca4c2e..2affea7 100644 --- a/src/scripts/optimize/home-page.ts +++ b/src/scripts/optimize/home-page.ts @@ -1,10 +1,12 @@ +import observeDOM from "@/utils/observe-dom"; + const replace: (any[] | undefined)[] = [ ["#slider > img", { src: "" }], ["#slider > img.nivo-main-image", { 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}); 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}); |
