From 00b7c1559d368131d6f5adf7e790ece89e54b2ed Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Thu, 10 Oct 2024 13:49:00 +0800 Subject: [PATCH] Update Manifest for compatibility with Firefox See https://stackoverflow.com/a/78088358 --- manifest.json | 7 ++++++- package.json | 4 ++-- scripts/patch-manifest.js | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 scripts/patch-manifest.js diff --git a/manifest.json b/manifest.json index 7ca68d7..7d694a1 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "__MSG_extensionName__", - "version": "0.5.0", + "version": "0.5.1", "description": "__MSG_extensionDescription__", "icons": { "48": "icons/48.png", @@ -26,5 +26,10 @@ "default_icon": "icons/96.png", "default_title": "__MSG_extensionName__", "default_popup": "src/popup/index.html" + }, + "browser_specific_settings": { + "gecko": { + "id": "inject-jyutping@jyutping.org" + } } } diff --git a/package.json b/package.json index a2e6e9d..22de72e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "inject-jyutping", - "version": "0.5.0", + "version": "0.5.1", "description": "A browser extension that adds Cantonese pronunciation (Jyutping) on Chinese characters", "type": "module", "scripts": { @@ -9,7 +9,7 @@ "start": "parcel watch manifest.json --config @parcel/config-webextension --host localhost", "prebuild": "npm run lint && npm run clear", "build": "parcel build manifest.json --config @parcel/config-webextension --no-source-maps --no-cache", - "postbuild": "node scripts/replace-surrogates.js", + "postbuild": "node scripts/replace-surrogates.js && node scripts/patch-manifest.js", "lint": "tsc -p tsconfig.json" }, "dependencies": { diff --git a/scripts/patch-manifest.js b/scripts/patch-manifest.js new file mode 100644 index 0000000..a1d5885 --- /dev/null +++ b/scripts/patch-manifest.js @@ -0,0 +1,7 @@ +import { readFile, writeFile } from 'fs/promises'; + +const path = './dist/manifest.json'; +const manifest = JSON.parse(await readFile(path, 'utf-8')); +manifest.background.scripts = [manifest.background.service_worker]; +manifest.background.persistent = true; +await writeFile(path, JSON.stringify(manifest));