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/home-page.ts | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) (limited to 'src/scripts/optimize/home-page.ts') diff --git a/src/scripts/optimize/home-page.ts b/src/scripts/optimize/home-page.ts index 2affea7..4c1f21f 100644 --- a/src/scripts/optimize/home-page.ts +++ b/src/scripts/optimize/home-page.ts @@ -1,32 +1,7 @@ -import observeDOM from "@/utils/observe-dom"; +import { replaceAttributes } from "@/utils/replace-attributes"; -const replace: (any[] | undefined)[] = [ - ["#slider > img", { src: "" }], - ["#slider > img.nivo-main-image", { src: "" }] -]; -let count = 0; +const bannerImageUrl = chrome.runtime.getURL("assets/banner.jpg"); -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([ + ["#form_MainMenuPage > div > div:nth-child(13)", { innerHTML: `` }] +]); -- cgit v1.2.3