Skip to content

Commit 2fa62d6

Browse files
authored
Avoid "Permission needed" bug on Firefox for now (refined-github#7485)
1 parent 7e61eb9 commit 2fa62d6

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ jobs:
5151
runs-on: ubuntu-latest
5252
steps:
5353
- uses: actions/download-artifact@v4
54+
55+
# Kiwi browser https://github.com/kiwibrowser/src.next/issues/1138
56+
- run: npm install dot-json@1 -g
57+
- run: npm run manifest artifact 3
58+
5459
- run: npx chrome-webstore-upload-cli@3
5560
working-directory: artifact
5661
env:
@@ -66,6 +71,11 @@ jobs:
6671
runs-on: ubuntu-latest
6772
steps:
6873
- uses: actions/download-artifact@v4
74+
75+
# Firefox https://github.com/refined-github/refined-github/issues/7477
76+
- run: npm install dot-json@1
77+
- run: npm run manifest artifact 2
78+
6979
- run: npx web-ext@8 sign --channel listed
7080
working-directory: artifact
7181
env:

build/manifest.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint-disable camelcase */
2+
import {existsSync, readFileSync, writeFileSync} from 'node:fs';
3+
import {join} from 'node:path';
4+
5+
const [extensionPath, manifestVersion] = process.argv.slice(2);
6+
7+
if (!extensionPath || !manifestVersion) {
8+
throw new Error('Please provide a path to the extension and a manifest version, like: npm run manifest distribution 2');
9+
}
10+
11+
const manifestPath = join(extensionPath, 'manifest.json');
12+
13+
if (!existsSync(manifestPath)) {
14+
throw new Error(`No manifest found in: ${extensionPath}`);
15+
}
16+
17+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
18+
19+
if (manifestVersion === '2') {
20+
// Avoid bad Firefox UX with manifest v3
21+
// TODO: Drop after https://bugzilla.mozilla.org/show_bug.cgi?id=1851083
22+
manifest.manifest_version = 2;
23+
manifest.web_accessible_resources = ['assets/resolve-conflicts.js'];
24+
delete manifest.background.service_worker;
25+
26+
manifest.permissions.push(...manifest.host_permissions);
27+
delete manifest.host_permissions;
28+
delete manifest.optional_host_permissions;
29+
30+
manifest.browser_action = manifest.action;
31+
delete manifest.action;
32+
} else {
33+
// Kiwi browser support
34+
// TODO: Drop after https://github.com/kiwibrowser/src.next/issues/1138
35+
delete manifest.background.scripts;
36+
}
37+
38+
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"build": "run-p build:* --continue-on-error",
77
"build:typescript": "tsc --noEmit",
88
"build:webpack": "npm run x:webpack -- --mode=production",
9+
"manifest": "node build/manifest.js",
910
"fix": "run-p \"lint:css -- --fix\" \"lint:js -- --fix\" fix:prettier \"vitest -- --update\" --continue-on-error",
1011
"fix:prettier": "prettier . --write",
1112
"lint": "run-p lint:* --continue-on-error",

0 commit comments

Comments
 (0)