From 71545bb08ed6d85a6256005fc31c5798c58f333a Mon Sep 17 00:00:00 2001 From: Jack Case Date: Thu, 6 Nov 2025 16:47:40 +0000 Subject: [PATCH] let's just not bother with imports for the content script --- manifest.json | 2 +- pages/action_popup.html | 4 +--- src/{hide-slop.ts => content-script.ts} | 26 +++++++++---------------- tsconfig.json | 3 ++- 4 files changed, 13 insertions(+), 22 deletions(-) rename src/{hide-slop.ts => content-script.ts} (90%) diff --git a/manifest.json b/manifest.json index edd481f..530366c 100644 --- a/manifest.json +++ b/manifest.json @@ -27,7 +27,7 @@ "content_scripts": [ { "matches": ["*://*.duckduckgo.com/*q=*"], - "js": ["scripts/hide-slop.js"], + "js": ["scripts/content-script.js"], "type":"module" } ] diff --git a/pages/action_popup.html b/pages/action_popup.html index 6405e96..d901cdc 100644 --- a/pages/action_popup.html +++ b/pages/action_popup.html @@ -16,7 +16,5 @@ -

You're logged in.

- - +

You're logged in.

\ No newline at end of file diff --git a/src/hide-slop.ts b/src/content-script.ts similarity index 90% rename from src/hide-slop.ts rename to src/content-script.ts index c990708..cdfc309 100644 --- a/src/hide-slop.ts +++ b/src/content-script.ts @@ -1,5 +1,3 @@ -let common: any - class SearchLink { node: Element @@ -78,7 +76,7 @@ function check_links(search_links: SearchLink[]) { return search_link.target }) - common.send_message_to_background({type: "check", urls: urls}) + browser.runtime.sendMessage({type: "check", urls: urls}) } async function backend_message_listener(message: any) { @@ -97,7 +95,6 @@ async function backend_message_listener(message: any) { link.result = message.result } break - } } @@ -156,17 +153,12 @@ async function onload_handler() { setup_result_observer() } -import("./common.js").then((module) => { - common = module - // listen for messages from the background script - browser.runtime.onMessage.addListener(backend_message_listener) - - // initialize state on document load - if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", onload_handler) - } else { - wait_for_results().then(onload_handler) - } -}) - +// listen for messages from the background script +browser.runtime.onMessage.addListener(backend_message_listener) +// initialize state on document load +if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", onload_handler) +} else { + wait_for_results().then(onload_handler) +} diff --git a/tsconfig.json b/tsconfig.json index 65a6d23..a7bd9eb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "sourceMap": true, "target": "esnext", "baseUrl": "src/", - "module": "esnext" + "module": "esnext", + "noFallthroughCasesInSwitch": true } } \ No newline at end of file