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"