From d0d3ff8f1110f9d137a0a887bc41b83018e916cf Mon Sep 17 00:00:00 2001 From: nemanjam Date: Wed, 17 Apr 2024 14:00:33 +0200 Subject: [PATCH] fix Chrome manifest v3 --- docs/work-notes/todo2.md | 2 ++ source/Background/service-worker.ts | 7 +++++++ source/manifest-v3-chrome.json | 13 +++++-------- webpack.config.js | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 source/Background/service-worker.ts diff --git a/docs/work-notes/todo2.md b/docs/work-notes/todo2.md index b7688db..830dbd6 100644 --- a/docs/work-notes/todo2.md +++ b/docs/work-notes/todo2.md @@ -15,6 +15,8 @@ db wrapper add version label nested comments, check that only comments content is in viewport + fix chrome manifest errors + // ovde na pocetku nove sesije oznacava prethodnu kao procitanu const { threadId, updatedAt } = existingThread; const updatedComments = await updateCommentsSessionCreatedAtForThread( diff --git a/source/Background/service-worker.ts b/source/Background/service-worker.ts new file mode 100644 index 0000000..02d74cd --- /dev/null +++ b/source/Background/service-worker.ts @@ -0,0 +1,7 @@ +import 'emoji-log'; +import browser from 'webextension-polyfill'; + +// for Chrome manifest v3 +browser.runtime.onInstalled.addListener((): void => { + console.emoji('🦄', 'extension installed'); +}); diff --git a/source/manifest-v3-chrome.json b/source/manifest-v3-chrome.json index 1e3ba76..a46a416 100644 --- a/source/manifest-v3-chrome.json +++ b/source/manifest-v3-chrome.json @@ -13,7 +13,9 @@ "homepage_url": "https://github.com/nemanjam/reddit-unread-comments", "short_name": "Reddit Unread Comments", - "permissions": ["activeTab", "http://*.reddit.com/*", "https://*.reddit.com/*"], + "permissions": ["activeTab"], + + "host_permissions": ["http://*.reddit.com/*", "https://*.reddit.com/*"], "content_security_policy": { "extension_pages": "script-src 'self'; object-src 'self'" @@ -24,12 +26,6 @@ "name": "Nemanja Mitic" }, - "browser_specific_settings": { - "gecko": { - "id": "{754FB1AD-CC3B-4756-B6A0-7776F7CA9D17}" - } - }, - "__chrome__minimum_chrome_version": "88", "__opera__minimum_opera_version": "36", @@ -53,7 +49,8 @@ }, "background": { - "service_worker": "js/background.bundle.js" + "__firefox__scripts": ["js/background.bundle.js"], + "__chrome|opera|edge__service_worker": "js/bgServiceWorker.bundle.js" }, "content_scripts": [ diff --git a/webpack.config.js b/webpack.config.js index 2927f65..1cc65f0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -62,6 +62,7 @@ module.exports = { entry: { manifest: path.join(sourcePath, 'manifest.json'), background: path.join(sourcePath, 'Background', 'index.ts'), + bgServiceWorker: path.join(sourcePath, 'Background', 'service-worker.ts'), contentScript: path.join(sourcePath, 'ContentScript', 'index.ts'), popup: path.join(sourcePath, 'Popup', 'index.tsx'), options: path.join(sourcePath, 'Options', 'index.tsx'),