From e34c6637f16769496f60cd344882401effca1db1 Mon Sep 17 00:00:00 2001 From: Daniel Dada Date: Mon, 23 Jun 2025 14:25:21 +0300 Subject: [PATCH] chore: remove content script and update manifest for service worker --- background.js | 10 ++++++++++ content.js => main.js | 0 manifest.json | 18 +++++++----------- 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 background.js rename content.js => main.js (100%) diff --git a/background.js b/background.js new file mode 100644 index 0000000..793b0af --- /dev/null +++ b/background.js @@ -0,0 +1,10 @@ +chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { + if (changeInfo.status === "complete" && /^https?:/.test(tab.url)) { + chrome.scripting.executeScript({ + target: { tabId }, + files: ["main.js"] + }).catch(err => { + console.warn("Injection failed:", err); + }); + } +}); \ No newline at end of file diff --git a/content.js b/main.js similarity index 100% rename from content.js rename to main.js diff --git a/manifest.json b/manifest.json index b39329a..f858b1f 100644 --- a/manifest.json +++ b/manifest.json @@ -5,23 +5,19 @@ "description": "Highlight text on web pages", "default_locale": "en", "permissions": [ + "scripting", "storage" ], + "host_permissions": [ + "" + ], "action": { "default_popup": "popup/popup.html", "default_icon": "icons/icon128.png" }, - "content_scripts": [ - { - "matches": [ - "" - ], - "js": [ - "content.js" - ], - "run_at": "document_idle" - } - ], + "background": { + "service_worker": "background.js" + }, "icons": { "48": "icons/icon48.png", "128": "icons/icon128.png"