From 32549ad7108072378b08c55f41b9e7a7a9cf94a3 Mon Sep 17 00:00:00 2001 From: dessant Date: Sat, 22 Jun 2024 20:07:28 +0300 Subject: [PATCH] feat: upgrade to Manifest V3 in Edge and Opera --- gulpfile.js | 2 +- src/assets/manifest/edge.json | 33 +++++++++++++++++++++------------ src/assets/manifest/opera.json | 33 +++++++++++++++++++++------------ webpack.config.js | 2 +- 4 files changed, 44 insertions(+), 26 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8ae04df..68a05c9 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -24,7 +24,7 @@ const isProduction = process.env.NODE_ENV === 'production'; const enableContributions = (process.env.ENABLE_CONTRIBUTIONS || 'true') === 'true'; -const mv3 = ['chrome'].includes(targetEnv); +const mv3 = ['chrome', 'edge', 'opera'].includes(targetEnv); const distDir = path.join(__dirname, 'dist', targetEnv); diff --git a/src/assets/manifest/edge.json b/src/assets/manifest/edge.json index 2ce577d..fb72f8a 100755 --- a/src/assets/manifest/edge.json +++ b/src/assets/manifest/edge.json @@ -1,5 +1,5 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "__MSG_extensionName__", "description": "__MSG_extensionDescription__", "version": "0.1.0", @@ -18,13 +18,17 @@ "activeTab", "notifications", "webRequest", - "webRequestBlocking", - "" + "declarativeNetRequest", + "scripting" ], "optional_permissions": ["clipboardRead"], - "content_security_policy": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src * data: blob:; connect-src * blob:; object-src 'none';", + "host_permissions": [""], + + "content_security_policy": { + "extension_pages": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src * data: blob:; connect-src * blob:; object-src 'none';" + }, "icons": { "16": "src/assets/icons/app/icon-16.png", @@ -38,7 +42,7 @@ "128": "src/assets/icons/app/icon-128.png" }, - "browser_action": { + "action": { "default_icon": { "16": "src/assets/icons/app/icon-16.png", "19": "src/assets/icons/app/icon-19.png", @@ -54,12 +58,11 @@ "options_ui": { "page": "src/options/index.html", - "chrome_style": false, "open_in_tab": true }, "background": { - "page": "src/background/index.html" + "service_worker": "src/background/script.js" }, "content_scripts": [ @@ -72,11 +75,17 @@ ], "web_accessible_resources": [ - "src/content/style.css", - "src/select/pointer.css", - "src/select/index.html", - "src/capture/index.html", - "src/confirm/index.html" + { + "resources": [ + "src/content/style.css", + "src/select/pointer.css", + "src/select/index.html", + "src/capture/index.html", + "src/confirm/index.html" + ], + "matches": ["http://*/*", "https://*/*", "file:///*"], + "use_dynamic_url": true + } ], "incognito": "split" diff --git a/src/assets/manifest/opera.json b/src/assets/manifest/opera.json index 7f89276..80f30e9 100755 --- a/src/assets/manifest/opera.json +++ b/src/assets/manifest/opera.json @@ -1,5 +1,5 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "__MSG_extensionName__", "description": "__MSG_extensionDescription__", "version": "0.1.0", @@ -18,13 +18,17 @@ "activeTab", "notifications", "webRequest", - "webRequestBlocking", - "" + "declarativeNetRequest", + "scripting" ], "optional_permissions": ["clipboardRead"], - "content_security_policy": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src * data: blob:; connect-src * blob:; object-src 'none';", + "host_permissions": [""], + + "content_security_policy": { + "extension_pages": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src * data: blob:; connect-src * blob:; object-src 'none';" + }, "icons": { "16": "src/assets/icons/app/icon-16.png", @@ -38,7 +42,7 @@ "128": "src/assets/icons/app/icon-128.png" }, - "browser_action": { + "action": { "default_icon": { "16": "src/assets/icons/app/icon-16.png", "19": "src/assets/icons/app/icon-19.png", @@ -54,12 +58,11 @@ "options_ui": { "page": "src/options/index.html", - "chrome_style": false, "open_in_tab": true }, "background": { - "page": "src/background/index.html" + "service_worker": "src/background/script.js" }, "content_scripts": [ @@ -72,11 +75,17 @@ ], "web_accessible_resources": [ - "src/content/style.css", - "src/select/pointer.css", - "src/select/index.html", - "src/capture/index.html", - "src/confirm/index.html" + { + "resources": [ + "src/content/style.css", + "src/select/pointer.css", + "src/select/index.html", + "src/capture/index.html", + "src/confirm/index.html" + ], + "matches": ["http://*/*", "https://*/*", "file:///*"], + "use_dynamic_url": true + } ], "incognito": "split" diff --git a/webpack.config.js b/webpack.config.js index cdc673a..0310b49 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -14,7 +14,7 @@ const isProduction = process.env.NODE_ENV === 'production'; const enableContributions = (process.env.ENABLE_CONTRIBUTIONS || 'true') === 'true'; -const mv3 = ['chrome'].includes(targetEnv); +const mv3 = ['chrome', 'edge', 'opera'].includes(targetEnv); const provideExtApi = !['firefox', 'safari'].includes(targetEnv);