From 6e5e790e9054ffe680f1268bf465fadeb3407bca Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 10 Jun 2023 02:51:00 -0400 Subject: [PATCH] Support manifest v3 --- manifest/chrome-manifest-extra.json | 104 ++++++++++++++++++++++++++-- manifest/manifest-v2-extra.json | 78 +++++++++++++++++++++ manifest/manifest.json | 78 +-------------------- package-lock.json | 14 ++-- package.json | 2 +- src/background.ts | 2 +- src/utils/cssInjector.ts | 2 +- src/video.ts | 2 +- webpack/webpack.manifest.js | 3 + 9 files changed, 191 insertions(+), 94 deletions(-) create mode 100644 manifest/manifest-v2-extra.json diff --git a/manifest/chrome-manifest-extra.json b/manifest/chrome-manifest-extra.json index 8fe52df..a632d12 100644 --- a/manifest/chrome-manifest-extra.json +++ b/manifest/chrome-manifest-extra.json @@ -1,8 +1,98 @@ { - "optional_permissions": [ - "declarativeContent" - ], - "background": { - "persistent": false - } -} + "optional_permissions": [ + "declarativeContent" + ], + "content_scripts": [ + { + "world": "MAIN", + "js": [ + "./js/document.js" + ], + "matches": [ + "https://*.youtube.com/*", + "https://www.youtube-nocookie.com/embed/*" + ], + "all_frames": true, + "run_at": "document_start" + } + ], + "web_accessible_resources": [{ + "resources": [ + "icons/refresh.svg", + "icons/logo.svg", + "js/document.js", + "js/options.js", + "js/popup.js", + "popup.css", + "shared.css", + "help.html", + "help.css", + "icons/logo-16.png", + "icons/logo-32.png", + "icons/logo-64.png", + "icons/logo-128.png", + "icons/logo-256.png" + ], + "matches": [""] + }], + "permissions": [ + "scripting" + ], + "host_permissions": [ + "https://sponsor.ajay.app/*", + "https://dearrow-thumb.ajay.app/*", + "https://*.youtube.com/*", + "https://www.youtube-nocookie.com/embed/*" + ], + "action": { + "default_title": "DeArrow", + "default_popup": "popup.html", + "default_icon": { + "16": "icons/logo-16.png", + "32": "icons/logo-32.png", + "64": "icons/logo-64.png", + "128": "icons/logo-128.png" + }, + "theme_icons": [ + { + "light": "icons/logo-16.png", + "dark": "icons/logo-16.png", + "size": 16 + }, + { + "light": "icons/logo-32.png", + "dark": "icons/logo-32.png", + "size": 32 + }, + { + "light": "icons/logo-64.png", + "dark": "icons/logo-64.png", + "size": 64 + }, + { + "light": "icons/logo-128.png", + "dark": "icons/logo-128.png", + "size": 128 + }, + { + "light": "icons/logo-256.png", + "dark": "icons/logo-256.png", + "size": 256 + }, + { + "light": "icons/logo-512.png", + "dark": "icons/logo-512.png", + "size": 512 + }, + { + "light": "icons/logo-1024.png", + "dark": "icons/logo-1024.png", + "size": 1024 + } + ] + }, + "background": { + "service_worker": "./js/background.js" + }, + "manifest_version": 3 +} \ No newline at end of file diff --git a/manifest/manifest-v2-extra.json b/manifest/manifest-v2-extra.json new file mode 100644 index 0000000..42f80fb --- /dev/null +++ b/manifest/manifest-v2-extra.json @@ -0,0 +1,78 @@ +{ + "web_accessible_resources": [ + "icons/refresh.svg", + "icons/logo.svg", + "js/document.js", + "js/options.js", + "js/popup.js", + "popup.css", + "shared.css", + "help.html", + "help.css", + "icons/logo-16.png", + "icons/logo-32.png", + "icons/logo-64.png", + "icons/logo-128.png", + "icons/logo-256.png" + ], + "permissions": [ + "https://sponsor.ajay.app/*", + "https://dearrow-thumb.ajay.app/*" + ], + "optional_permissions": [ + "*://*/*" + ], + "browser_action": { + "default_title": "DeArrow", + "default_popup": "popup.html", + "default_icon": { + "16": "icons/logo-16.png", + "32": "icons/logo-32.png", + "64": "icons/logo-64.png", + "128": "icons/logo-128.png" + }, + "theme_icons": [ + { + "light": "icons/logo-16.png", + "dark": "icons/logo-16.png", + "size": 16 + }, + { + "light": "icons/logo-32.png", + "dark": "icons/logo-32.png", + "size": 32 + }, + { + "light": "icons/logo-64.png", + "dark": "icons/logo-64.png", + "size": 64 + }, + { + "light": "icons/logo-128.png", + "dark": "icons/logo-128.png", + "size": 128 + }, + { + "light": "icons/logo-256.png", + "dark": "icons/logo-256.png", + "size": 256 + }, + { + "light": "icons/logo-512.png", + "dark": "icons/logo-512.png", + "size": 512 + }, + { + "light": "icons/logo-1024.png", + "dark": "icons/logo-1024.png", + "size": 1024 + } + ] + }, + "background": { + "scripts":[ + "./js/background.js" + ] + }, + "manifest_version": 2 +} \ No newline at end of file diff --git a/manifest/manifest.json b/manifest/manifest.json index 4fd8a08..a05c17b 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_deArrowFullName__", "short_name": "DeArrow", - "version": "1.0.3", + "version": "1.0.4", "default_locale": "en", "description": "__MSG_deArrowDescription__", "homepage_url": "https://sponsor.ajay.app", @@ -20,83 +20,10 @@ "shared.css" ] }], - "web_accessible_resources": [ - "icons/refresh.svg", - "icons/logo.svg", - "js/document.js", - "js/options.js", - "js/popup.js", - "popup.css", - "shared.css", - "help.html", - "help.css", - "icons/logo-16.png", - "icons/logo-32.png", - "icons/logo-64.png", - "icons/logo-128.png", - "icons/logo-256.png" - ], "permissions": [ "storage", - "https://sponsor.ajay.app/*", - "https://dearrow-thumb.ajay.app/*", "unlimitedStorage" ], - "optional_permissions": [ - "*://*/*" - ], - "browser_action": { - "default_title": "DeArrow", - "default_popup": "popup.html", - "default_icon": { - "16": "icons/logo-16.png", - "32": "icons/logo-32.png", - "64": "icons/logo-64.png", - "128": "icons/logo-128.png" - }, - "theme_icons": [ - { - "light": "icons/logo-16.png", - "dark": "icons/logo-16.png", - "size": 16 - }, - { - "light": "icons/logo-32.png", - "dark": "icons/logo-32.png", - "size": 32 - }, - { - "light": "icons/logo-64.png", - "dark": "icons/logo-64.png", - "size": 64 - }, - { - "light": "icons/logo-128.png", - "dark": "icons/logo-128.png", - "size": 128 - }, - { - "light": "icons/logo-256.png", - "dark": "icons/logo-256.png", - "size": 256 - }, - { - "light": "icons/logo-512.png", - "dark": "icons/logo-512.png", - "size": 512 - }, - { - "light": "icons/logo-1024.png", - "dark": "icons/logo-1024.png", - "size": 1024 - } - ] - }, - "background": { - "scripts":[ - "./js/background.js" - ] - }, "icons": { "16": "icons/logo-16.png", "32": "icons/logo-32.png", @@ -109,6 +36,5 @@ "options_ui": { "page": "options/options.html", "open_in_tab": true - }, - "manifest_version": 2 + } } diff --git a/package-lock.json b/package-lock.json index 6a44f67..c34933a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ ], "license": "LGPL-3.0-or-later", "dependencies": { - "@ajayyy/maze-utils": "1.1.33", + "@ajayyy/maze-utils": "1.1.34", "react": "^18.2.0", "react-dom": "^18.2.0", "seedrandom": "^3.0.5" @@ -69,9 +69,9 @@ } }, "node_modules/@ajayyy/maze-utils": { - "version": "1.1.33", - "resolved": "https://registry.npmjs.org/@ajayyy/maze-utils/-/maze-utils-1.1.33.tgz", - "integrity": "sha512-vadAoJlQ1f5QKeAY4SElHDpFm65/MzytG8j3Ebt+vYP0by0GuVX9JokShGyO72rS6zJnHTBsglKagOOtOV81pg==", + "version": "1.1.34", + "resolved": "https://registry.npmjs.org/@ajayyy/maze-utils/-/maze-utils-1.1.34.tgz", + "integrity": "sha512-Tpun9zmYML1FqdjMGOr+Fsyhd2T9NjQZ2oIp6vio0teZvVc3VvA1vONn4wMa8tRcNI7yK6r9H1AZcnfXs/5FRw==", "funding": [ { "type": "individual", @@ -11632,9 +11632,9 @@ }, "dependencies": { "@ajayyy/maze-utils": { - "version": "1.1.33", - "resolved": "https://registry.npmjs.org/@ajayyy/maze-utils/-/maze-utils-1.1.33.tgz", - "integrity": "sha512-vadAoJlQ1f5QKeAY4SElHDpFm65/MzytG8j3Ebt+vYP0by0GuVX9JokShGyO72rS6zJnHTBsglKagOOtOV81pg==" + "version": "1.1.34", + "resolved": "https://registry.npmjs.org/@ajayyy/maze-utils/-/maze-utils-1.1.34.tgz", + "integrity": "sha512-Tpun9zmYML1FqdjMGOr+Fsyhd2T9NjQZ2oIp6vio0teZvVc3VvA1vONn4wMa8tRcNI7yK6r9H1AZcnfXs/5FRw==" }, "@ampproject/remapping": { "version": "2.2.0", diff --git a/package.json b/package.json index a934dcb..d544fad 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "background.js", "dependencies": { - "@ajayyy/maze-utils": "1.1.33", + "@ajayyy/maze-utils": "1.1.34", "react": "^18.2.0", "react-dom": "^18.2.0", "seedrandom": "^3.0.5" diff --git a/src/background.ts b/src/background.ts index a4c7ca4..77e4d8c 100644 --- a/src/background.ts +++ b/src/background.ts @@ -60,7 +60,7 @@ chrome.runtime.onInstalled.addListener(() => { } // Open up the install page - setTimeout(() => void chrome.tabs.create({url: chrome.extension.getURL("/help.html")}), 100); + setTimeout(() => void chrome.tabs.create({url: chrome.runtime.getURL("/help.html")}), 100); } }, 1500); }); diff --git a/src/utils/cssInjector.ts b/src/utils/cssInjector.ts index 086a869..95648a0 100644 --- a/src/utils/cssInjector.ts +++ b/src/utils/cssInjector.ts @@ -26,7 +26,7 @@ export function addCssToPage() { const fileref = document.createElement("link"); fileref.rel = "stylesheet"; fileref.type = "text/css"; - fileref.href = chrome.extension.getURL(file); + fileref.href = chrome.runtime.getURL(file); head.appendChild(fileref); } diff --git a/src/video.ts b/src/video.ts index e5fe1df..529f477 100644 --- a/src/video.ts +++ b/src/video.ts @@ -82,6 +82,6 @@ export function setupCBVideoModule(): void { resetValues, windowListenerHandler, newVideosLoaded, - documentScript + documentScript: chrome.runtime.getManifest().manifest_version === 2 ? documentScript : undefined }, () => Config); } \ No newline at end of file diff --git a/webpack/webpack.manifest.js b/webpack/webpack.manifest.js index 3e30ffc..731b92c 100644 --- a/webpack/webpack.manifest.js +++ b/webpack/webpack.manifest.js @@ -12,6 +12,7 @@ const chromeManifestExtra = require("../manifest/chrome-manifest-extra.json"); const safariManifestExtra = require("../manifest/safari-manifest-extra.json"); const betaManifestExtra = require("../manifest/beta-manifest-extra.json"); const firefoxBetaManifestExtra = require("../manifest/firefox-beta-manifest-extra.json"); +const manifestV2ManifestExtra = require("../manifest/manifest-v2-extra.json"); // schema for options object const schema = { @@ -42,12 +43,14 @@ class BuildManifest { // Add missing manifest elements if (this.options.browser.toLowerCase() === "firefox") { + mergeObjects(manifest, manifestV2ManifestExtra); mergeObjects(manifest, firefoxManifestExtra); } else if (this.options.browser.toLowerCase() === "chrome" || this.options.browser.toLowerCase() === "chromium" || this.options.browser.toLowerCase() === "edge") { mergeObjects(manifest, chromeManifestExtra); } else if (this.options.browser.toLowerCase() === "safari") { + mergeObjects(manifest, manifestV2ManifestExtra); mergeObjects(manifest, safariManifestExtra); }