Skip to content

Commit 38ebaaf

Browse files
committed
core: ci: use manifest v3 for Chromium
- `injectImmediately` requires Chromium >= 102. - Do not set `web_accessible_resources.use_dynamic_url` to `true`, which prevents inter-module importing from a content script. ref: https://crbug.com/444772033 - Update builder script to support mv2 or mv3. - Update workflow script to better support development usage.
1 parent 27cb728 commit 38ebaaf

File tree

6 files changed

+388
-16
lines changed

6 files changed

+388
-16
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ jobs:
4545
exit 1
4646
fi
4747
48-
EXPECTED_LINE="## [$VERSION] - $(TZ="$TIMEZONE" date +%Y-%m-%d)"
49-
if ! grep -Fxq "$EXPECTED_LINE" CHANGELOG.md; then
50-
echo "❌ Missing expected changelog line: $EXPECTED_LINE"
51-
exit 1
48+
if [ '${{ github.event.inputs.environment }}' = 'production' ]; then
49+
EXPECTED_LINE="## [$VERSION] - $(TZ="$TIMEZONE" date +%Y-%m-%d)"
50+
if ! grep -Fxq "$EXPECTED_LINE" CHANGELOG.md; then
51+
echo "❌ Missing expected changelog line: $EXPECTED_LINE"
52+
exit 1
53+
fi
5254
fi
5355
5456
echo "version=$VERSION" >> $GITHUB_OUTPUT
@@ -59,6 +61,12 @@ jobs:
5961
echo "artifact_zip=webscrapbook-zip" >> $GITHUB_OUTPUT
6062
echo "artifact_xpi=webscrapbook-xpi" >> $GITHUB_OUTPUT
6163
64+
- name: Set Firefox extension ID in manifest.json
65+
if: vars.FIREFOX_EXTENSION_ID
66+
run: |
67+
jq '.browser_specific_settings.gecko.id = "${{ vars.FIREFOX_EXTENSION_ID }}"' src/manifest.firefox-mv2.json > manifest.tmp.json
68+
mv manifest.tmp.json src/manifest.firefox-mv2.json
69+
6270
- name: Set up Node.js
6371
uses: actions/setup-node@v4
6472
with:
@@ -74,6 +82,7 @@ jobs:
7482
run: npm run pack
7583

7684
- name: Create Git tag
85+
if: github.event.inputs.environment == 'production'
7786
run: |
7887
git tag --force ${{ steps.config.outputs.tag_name }}
7988
git push origin ${{ steps.config.outputs.tag_name }}

src/manifest.chromium.json

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "__MSG_ExtensionName__",
4+
"description": "__MSG_ExtensionDescription__",
5+
"version": "2.24.0",
6+
"author": "Danny Lin",
7+
"default_locale": "en",
8+
9+
"minimum_chrome_version": "102",
10+
11+
"homepage_url": "https://github.com/danny0838/webscrapbook",
12+
13+
"incognito": "split",
14+
15+
"icons": {
16+
"32": "resources/scrapbook-32.png",
17+
"128": "resources/scrapbook-128.png"
18+
},
19+
20+
"permissions": [
21+
"contextMenus",
22+
"downloads",
23+
"scripting",
24+
"sidePanel",
25+
"storage",
26+
"tabs",
27+
"unlimitedStorage",
28+
"webNavigation",
29+
"webRequest",
30+
"webRequestBlocking",
31+
"system.display"
32+
],
33+
34+
"host_permissions": [
35+
"http://*/*",
36+
"https://*/*",
37+
"file:///*"
38+
],
39+
40+
"background": {
41+
"service_worker": "core/background.mjs",
42+
"type": "module"
43+
},
44+
45+
"web_accessible_resources": [
46+
{
47+
"resources": [
48+
"*.map",
49+
"*.js",
50+
"*.mjs",
51+
"resources/*",
52+
"scrapbook/sitemap.html",
53+
"viewer/load.html"
54+
],
55+
"matches": [
56+
"<all_urls>"
57+
],
58+
"use_dynamic_url": false
59+
}
60+
],
61+
62+
"options_ui": {
63+
"open_in_tab": true,
64+
"page": "core/options.html"
65+
},
66+
67+
"action": {
68+
"default_icon": {
69+
"32": "resources/scrapbook-32.png",
70+
"128": "resources/scrapbook-128.png"
71+
},
72+
"default_title": "__MSG_ExtensionName__",
73+
"default_popup": "core/action.html"
74+
},
75+
76+
"side_panel": {
77+
"default_path": "scrapbook/sidebar.html"
78+
},
79+
80+
"commands": {
81+
"_execute_action": {},
82+
"openScrapBook": {
83+
"suggested_key": {
84+
"default": "Alt+K"
85+
},
86+
"description": "__MSG_OpenScrapBook__"
87+
},
88+
"openOptions": {
89+
"description": "__MSG_OpenOptions__"
90+
},
91+
"openViewer": {
92+
"suggested_key": {
93+
"default": "Alt+V"
94+
},
95+
"description": "__MSG_OpenViewer__..."
96+
},
97+
"openSearch": {
98+
"description": "__MSG_OpenSearch__..."
99+
},
100+
"searchCaptures": {
101+
"description": "__MSG_SearchCaptures__"
102+
},
103+
"captureTab": {
104+
"suggested_key": {
105+
"default": "Ctrl+Shift+K"
106+
},
107+
"description": "__MSG_CaptureTab__"
108+
},
109+
"captureTabSource": {
110+
"description": "__MSG_CaptureTabSource__"
111+
},
112+
"captureTabBookmark": {
113+
"description": "__MSG_CaptureTabBookmark__"
114+
},
115+
"captureTabAs": {
116+
"description": "__MSG_CaptureTabAs__..."
117+
},
118+
"batchCaptureLinks": {
119+
"description": "__MSG_BatchCaptureLinks__..."
120+
},
121+
"editTab": {
122+
"suggested_key": {
123+
"default": "Ctrl+Shift+E"
124+
},
125+
"description": "__MSG_EditTab__"
126+
}
127+
}
128+
}

src/manifest.firefox.json

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "__MSG_ExtensionName__",
4+
"description": "__MSG_ExtensionDescription__",
5+
"version": "2.24.0",
6+
"author": "Danny Lin",
7+
"default_locale": "en",
8+
9+
"browser_specific_settings": {
10+
"gecko": {
11+
12+
"strict_min_version": "109.0"
13+
},
14+
"gecko_android": {
15+
"strict_min_version": "113.0"
16+
}
17+
},
18+
19+
"homepage_url": "https://github.com/danny0838/webscrapbook",
20+
21+
"icons": {
22+
"32": "resources/scrapbook-32.png",
23+
"128": "resources/scrapbook-128.png"
24+
},
25+
26+
"permissions": [
27+
"contextMenus",
28+
"downloads",
29+
"scripting",
30+
"storage",
31+
"tabs",
32+
"unlimitedStorage",
33+
"webNavigation",
34+
"webRequest",
35+
"webRequestBlocking"
36+
],
37+
38+
"optional_permissions": [
39+
"geolocation"
40+
],
41+
42+
"host_permissions": [
43+
"http://*/*",
44+
"https://*/*"
45+
],
46+
47+
"background": {
48+
"page": "background.html"
49+
},
50+
51+
"web_accessible_resources": [
52+
{
53+
"resources": [
54+
"*.map",
55+
"*.js",
56+
"*.mjs",
57+
"resources/*",
58+
"scrapbook/sitemap.html",
59+
"viewer/load.html"
60+
],
61+
"matches": [
62+
"<all_urls>"
63+
]
64+
}
65+
],
66+
67+
"options_ui": {
68+
"open_in_tab": true,
69+
"page": "core/options.html"
70+
},
71+
72+
"action": {
73+
"default_icon": {
74+
"32": "resources/scrapbook-32.png",
75+
"128": "resources/scrapbook-128.png"
76+
},
77+
"default_title": "__MSG_ExtensionName__",
78+
"default_popup": "core/action.html"
79+
},
80+
81+
"sidebar_action": {
82+
"default_title": "__MSG_ExtensionName__",
83+
"default_panel": "scrapbook/sidebar.html",
84+
"default_icon": {
85+
"32": "resources/scrapbook-32.png",
86+
"128": "resources/scrapbook-128.png"
87+
},
88+
"open_at_install": false
89+
},
90+
91+
"commands": {
92+
"_execute_action": {},
93+
"_execute_sidebar_action": {},
94+
"openScrapBook": {
95+
"description": "__MSG_OpenScrapBook__"
96+
},
97+
"openOptions": {
98+
"description": "__MSG_OpenOptions__"
99+
},
100+
"openViewer": {
101+
"description": "__MSG_OpenViewer__..."
102+
},
103+
"openSearch": {
104+
"description": "__MSG_OpenSearch__..."
105+
},
106+
"searchCaptures": {
107+
"description": "__MSG_SearchCaptures__"
108+
},
109+
"captureTab": {
110+
"description": "__MSG_CaptureTab__"
111+
},
112+
"captureTabSource": {
113+
"description": "__MSG_CaptureTabSource__"
114+
},
115+
"captureTabBookmark": {
116+
"description": "__MSG_CaptureTabBookmark__"
117+
},
118+
"captureTabAs": {
119+
"description": "__MSG_CaptureTabAs__..."
120+
},
121+
"batchCaptureLinks": {
122+
"description": "__MSG_BatchCaptureLinks__..."
123+
},
124+
"editTab": {
125+
"description": "__MSG_EditTab__"
126+
}
127+
}
128+
}

test/manifest.chromium.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "WebScrapBook Test Suite",
4+
"description": "Test suite for WebScrapBook extension.",
5+
"version": "0.1.0",
6+
"author": "Danny Lin",
7+
8+
"minimum_chrome_version": "102",
9+
10+
"background": {
11+
"service_worker": "background.js",
12+
"type": "module"
13+
},
14+
15+
"content_scripts": [
16+
{
17+
"matches": [
18+
"http://localhost/capturex_*",
19+
"http://localhost/viewer_*"
20+
],
21+
"js": [
22+
"content.js"
23+
],
24+
"run_at": "document_start"
25+
}
26+
],
27+
28+
"action": {
29+
"default_title": "WebScrapBook Test Suite"
30+
},
31+
32+
"permissions": [
33+
"contextMenus",
34+
"storage"
35+
],
36+
37+
"host_permissions": [
38+
"http://*/*"
39+
]
40+
}

test/manifest.firefox.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "WebScrapBook Test Suite",
4+
"description": "Test suite for WebScrapBook extension.",
5+
"version": "0.1.0",
6+
"author": "Danny Lin",
7+
8+
"browser_specific_settings": {
9+
"gecko": {
10+
11+
"strict_min_version": "109.0"
12+
}
13+
},
14+
15+
"background": {
16+
"page": "background.html"
17+
},
18+
19+
"content_scripts": [
20+
{
21+
"matches": [
22+
"http://localhost/capturex_*",
23+
"http://localhost/viewer_*"
24+
],
25+
"js": [
26+
"content.js"
27+
],
28+
"run_at": "document_start"
29+
}
30+
],
31+
32+
"action": {
33+
"default_title": "WebScrapBook Test Suite"
34+
},
35+
36+
"permissions": [
37+
"contextMenus",
38+
"storage"
39+
],
40+
41+
"host_permissions": [
42+
"http://*/*"
43+
]
44+
}

0 commit comments

Comments
 (0)