From a30b28d40e5bacdbbbcad3c9de8f1fe3e083119c Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Tue, 14 Feb 2023 09:46:34 +0530 Subject: Added ability to load static assets from extension's assets. --- src/scripts/optimize/index.ts | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'src/scripts/optimize/index.ts') diff --git a/src/scripts/optimize/index.ts b/src/scripts/optimize/index.ts index 37ae12e..70cbac3 100644 --- a/src/scripts/optimize/index.ts +++ b/src/scripts/optimize/index.ts @@ -1,32 +1,7 @@ -import observeDOM from "@/utils/observe-dom"; +import { replaceAttributes } from "@/utils/replace-attributes"; -const replace: (any[] | undefined)[] = [ - ["head > script:nth-child(34)", { src: "" }], - ["head > script:nth-child(43)", { src: "" }] -]; -let count = 0; - -observeDOM(() => { - for (let i = 0; i < replace.length; i++) { - if (replace[i]) { - const element = document.querySelector(replace[i]![0]) as HTMLElement | null; - if (element) { - const attributes = replace[i]![1]; - if (attributes.innerHTML) { - element.innerHTML = attributes.innerHTML; - } - delete attributes.innerHTML; - for (const attribute in attributes) { - element.setAttribute(attribute, attributes[attribute]); - } - replace[i] = undefined; - count++; - if (count >= replace.length) { - return true; - } - } - } - } - - return false; -}); +replaceAttributes([ + ["head > script:nth-child(34)", { src: null }], + ["head > script:nth-child(36)", { src: null, innerHTML: "$.prototype.nivoSlider = () => {};" }], + ["head > script:nth-child(43)", { src: null }] +]); -- cgit v1.2.3