Skip to content

Commit ea67bce

Browse files
authored
feat: chrome response modifier
2 parents fb5c62d + a937829 commit ea67bce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2954
-4284
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Build and Test"
2+
description: "Build and Test"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Build Firefox v2
7+
shell: bash
8+
run: npm run build:firefox_v2
9+
- name: Build Firefox v3
10+
shell: bash
11+
run: npm run build:firefox_v3
12+
- name: Build Chrome v2
13+
shell: bash
14+
run: npm run build:chrome_v2
15+
- name: Build Chrome v3
16+
shell: bash
17+
run: npm run build:chrome_v3
18+
- name: Upload bundle
19+
uses: actions/upload-artifact@v4
20+
with:
21+
name: dist
22+
retention-days: 7
23+
path: |
24+
dist_chrome_v2
25+
dist_chrome_v3
26+
dist_firefox_v2
27+
dist_firefox_v3
28+
- name: Install Edge
29+
id: install-edge
30+
shell: bash
31+
run: |
32+
sudo apt-get remove -y microsoft-edge-stable
33+
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/microsoft.gpg
34+
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main"
35+
sudo apt-get update
36+
sudo apt-get install -y microsoft-edge-stable=138.0.3351.109-1
37+
microsoft-edge --version
38+
EDGE_PATH=$(which microsoft-edge)
39+
echo "edge-path=$EDGE_PATH" >> $GITHUB_OUTPUT
40+
- name: Test
41+
shell: bash
42+
env:
43+
EDGE_PATH: ${{ steps.install-edge.outputs.edge-path }}
44+
run: |
45+
npx puppeteer browsers install
46+
php -S 0.0.0.0:8899 -t $GITHUB_WORKSPACE/tests/simple-server > /dev/null 2>&1 &
47+
sleep 2
48+
npm run test:e2e

.github/workflows/dev.yml

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ on:
44
push:
55
branches:
66
- dev
7+
workflow_dispatch:
8+
inputs:
9+
platform:
10+
description: 'Platform(amo,cws,xpi,edge,crx)'
11+
required: true
12+
type: string
13+
version:
14+
description: 'Version'
15+
required: true
16+
type: string
717

818
concurrency:
919
group: ${{ github.workflow }}-${{ github.ref }}
@@ -41,16 +51,20 @@ jobs:
4151
build:
4252
needs: check_changes
4353
runs-on: ubuntu-24.04
44-
if: ${{ needs.check_changes.outputs.src_changed == 'true' }}
54+
if: ${{ needs.check_changes.outputs.src_changed == 'true' || github.event_name == 'workflow_dispatch' }}
4555
steps:
4656
- uses: actions/checkout@v4
57+
- name: Inject Env
58+
run: |
59+
echo "INPUT_PLATFORM=${{ github.event.inputs.platform }}" >> $GITHUB_ENV
60+
echo "INPUT_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
4761
- uses: pnpm/action-setup@v4
4862
with:
4963
version: 9
5064
- name: Setup Node.js
5165
uses: actions/setup-node@v4
5266
with:
53-
node-version: 18
67+
node-version: 20
5468
cache: 'pnpm'
5569
- name: Install dependencies
5670
run: pnpm i --frozen-lockfile
@@ -59,58 +73,22 @@ jobs:
5973
TOKEN: ${{ secrets.SNAPSHOT_TOKEN }}
6074
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6175
run: node ./scripts/get-snapshot-version.mjs
62-
- name: Build Firefox v2
63-
run: npm run build:firefox_v2
64-
- name: Build Firefox v3
65-
run: npm run build:firefox_v3
66-
- name: Build Chrome v2
67-
run: npm run build:chrome_v2
68-
- name: Build Chrome v3
69-
run: npm run build:chrome_v3
70-
- name: Upload bundle
71-
uses: actions/upload-artifact@v4
72-
with:
73-
name: dist
74-
retention-days: 7
75-
path: |
76-
dist_chrome_v2
77-
dist_chrome_v3
78-
dist_firefox_v2
79-
dist_firefox_v3
80-
- name: Install Edge
81-
id: install-edge
82-
run: |
83-
sudo apt-get remove -y microsoft-edge-stable
84-
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/microsoft.gpg
85-
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main"
86-
sudo apt-get update
87-
sudo apt-get install -y microsoft-edge-stable=138.0.3351.109-1
88-
microsoft-edge --version
89-
EDGE_PATH=$(which microsoft-edge)
90-
echo "edge-path=$EDGE_PATH" >> $GITHUB_OUTPUT
91-
- name: Test
92-
env:
93-
EDGE_PATH: ${{ steps.install-edge.outputs.edge-path }}
94-
run: |
95-
npx puppeteer browsers install
96-
php -S 0.0.0.0:8899 -t $GITHUB_WORKSPACE/tests/simple-server &
97-
sleep 3
98-
npm run test:e2e
76+
- name: Build And Test
77+
uses: ./.github/actions/build-and-test
9978
- name: Publish snapshot
10079
env:
10180
AMO_KEY: ${{ secrets.AMO_KEY }}
10281
AMO_SECRET: ${{ secrets.AMO_SECRET }}
10382
CRX_PRIV_KEY: ${{ secrets.CRX_PRIV_KEY }}
10483
PACK_PLATFORM: xpi,crx
84+
DEBUG: '*'
10585
run: npm run pack
10686
- name: Upload snapshot release
10787
uses: actions/upload-artifact@v4
10888
with:
10989
name: release
11090
retention-days: 7
111-
path: |
112-
temp/release
113-
!temp/release/*-id.txt
91+
path: temp/release
11492

11593
sync-locale:
11694
needs: check_changes
@@ -121,7 +99,7 @@ jobs:
12199
- name: Setup Node.js
122100
uses: actions/setup-node@v4
123101
with:
124-
node-version: 18
102+
node-version: 20
125103
- name: Sort
126104
run: node ./locale/sort-origin.js
127105
- name: Deploy
@@ -144,7 +122,7 @@ jobs:
144122
- name: Setup Node.js
145123
uses: actions/setup-node@v4
146124
with:
147-
node-version: 18
125+
node-version: 20
148126
- name: Install dependencies
149127
run: |
150128
cd $GITHUB_WORKSPACE/docs
@@ -158,7 +136,7 @@ jobs:
158136
uses: actions/upload-artifact@v4
159137
with:
160138
name: docs
161-
retention-days: 2
139+
retention-days: 1
162140
path: docs/doc_build
163141

164142
deploy-docs-cloudflare:

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Setup Node.js
3939
uses: actions/setup-node@v4
4040
with:
41-
node-version: 18
41+
node-version: 20
4242
- name: Install dependencies
4343
run: |
4444
cd $GITHUB_WORKSPACE/docs
@@ -52,7 +52,7 @@ jobs:
5252
uses: actions/upload-artifact@v4
5353
with:
5454
name: docs
55-
retention-days: 2
55+
retention-days: 1
5656
path: docs/doc_build
5757

5858
deploy-docs-cloudflare:

.github/workflows/release.yml

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,53 +24,22 @@ jobs:
2424
runs-on: ubuntu-24.04
2525
steps:
2626
- uses: actions/checkout@v4
27+
- name: Inject Env
28+
run: |
29+
echo "INPUT_PLATFORM=${{ github.event.inputs.platform }}" >> $GITHUB_ENV
30+
echo "INPUT_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
2731
- uses: pnpm/action-setup@v4
2832
with:
2933
version: 9
3034
- name: Setup Node.js
3135
uses: actions/setup-node@v4
3236
with:
33-
node-version: 18
37+
node-version: 20
3438
cache: 'pnpm'
3539
- name: Install dependencies
3640
run: pnpm i --frozen-lockfile
37-
- name: Build Firefox v2
38-
run: npm run build:firefox_v2
39-
- name: Build Firefox v3
40-
run: npm run build:firefox_v3
41-
- name: Build Chrome v2
42-
run: npm run build:chrome_v2
43-
- name: Build Chrome v3
44-
run: npm run build:chrome_v3
45-
- name: Upload bundle
46-
uses: actions/upload-artifact@v4
47-
with:
48-
name: dist
49-
retention-days: 7
50-
path: |
51-
dist_chrome_v2
52-
dist_chrome_v3
53-
dist_firefox_v2
54-
dist_firefox_v3
55-
- name: Install Edge
56-
id: install-edge
57-
run: |
58-
sudo apt-get remove -y microsoft-edge-stable
59-
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/microsoft.gpg
60-
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main"
61-
sudo apt-get update
62-
sudo apt-get install -y microsoft-edge-stable=138.0.3351.109-1
63-
microsoft-edge --version
64-
EDGE_PATH=$(which microsoft-edge)
65-
echo "edge-path=$EDGE_PATH" >> $GITHUB_OUTPUT
66-
- name: Test
67-
env:
68-
EDGE_PATH: ${{ steps.install-edge.outputs.edge-path }}
69-
run: |
70-
npx puppeteer browsers install
71-
php -S 0.0.0.0:8899 -t $GITHUB_WORKSPACE/tests/simple-server &
72-
sleep 3
73-
npm run test:e2e
41+
- name: Build And Test
42+
uses: ./.github/actions/build-and-test
7443
- name: Pack
7544
env:
7645
AMO_KEY: ${{ secrets.AMO_KEY }}
@@ -82,6 +51,7 @@ jobs:
8251
CWS_TOKEN: ${{ secrets.CWS_TOKEN }}
8352
MS_CLIENT_ID: ${{ secrets.MS_CLIENT_ID }}
8453
MS_API_KEY: ${{ secrets.MS_API_KEY }}
54+
DEBUG: '*'
8555
run: npm run pack
8656
- name: Upload release
8757
uses: actions/upload-artifact@v4

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ Header Editor
44

55
[![Release](https://img.shields.io/github/release/FirefoxBar/HeaderEditor.svg?label=Release)](https://github.com/FirefoxBar/HeaderEditor/releases)
66
[![Chrome Web Store](https://img.shields.io/chrome-web-store/users/eningockdidmgiojffjmkdblpjocbhgh?label=Chrome)](https://chrome.google.com/webstore/detail/header-editor/eningockdidmgiojffjmkdblpjocbhgh)
7-
[![Mozilla Addons](https://img.shields.io/amo/users/header-editor?label=Firefox)](https://addons.mozilla.org/en-US/firefox/addon/header-editor/)
7+
[![Mozilla Add-ons](https://img.shields.io/amo/users/header-editor?label=Firefox)](https://addons.mozilla.org/en-US/firefox/addon/header-editor/)
8+
[![Mozilla Add-ons](https://img.shields.io/amo/users/header-editor-lite?label=Firefox(Lite))](https://addons.mozilla.org/en-US/firefox/addon/header-editor-lite/)
89
[![license](https://img.shields.io/github/license/FirefoxBar/HeaderEditor.svg?label=License)](https://github.com/FirefoxBar/HeaderEditor/blob/master/LICENSE)
910
[![Discussions](https://img.shields.io/github/discussions/FirefoxBar/HeaderEditor?label=Discussions)](https://github.com/FirefoxBar/HeaderEditor/discussions)
1011
[![Build Status](https://github.com/FirefoxBar/HeaderEditor/actions/workflows/dev.yml/badge.svg)](https://github.com/FirefoxBar/HeaderEditor/actions/workflows/dev.yml)
1112

12-
An extension which can modify the request, include request headers, response headers, redirect requests, and cancel requests.
13+
An extension which can modify the request, include request headers, response headers, response body, redirect requests, and cancel requests.
1314

1415
It's 100% FREE, no ADs, no data collection.
1516

16-
For more documentations, Please visit [he.firefoxcn.net](https://he.firefoxcn.net)
17+
Visit [he.firefoxcn.net](https://he.firefoxcn.net) for more documentations.
1718

1819
## Get this extension
1920

20-
| Browser | Lite Version | Full Version |
21+
| Browser | Lite | Full |
2122
| --- | --- | --- |
22-
| ![Firefox Logo](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/75.0.1/firefox/firefox_16x16.png) Firefox | None | [Mozilla Add-on](https://addons.mozilla.org/en-US/firefox/addon/header-editor/) or our [self-distributed version](https://github.com/FirefoxBar/HeaderEditor/releases) |
23+
| ![Firefox Logo](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/75.0.1/firefox/firefox_16x16.png) Firefox | [Mozilla Add-ons](https://addons.mozilla.org/en-US/firefox/addon/header-editor-lite/) | [Mozilla Add-ons](https://addons.mozilla.org/en-US/firefox/addon/header-editor/) or our [self-distributed version](https://github.com/FirefoxBar/HeaderEditor/releases) |
2324
| ![Chrome Logo](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/75.0.1/chrome/chrome_16x16.png) Chrome | [Chrome Web Store](https://chrome.google.com/webstore/detail/header-editor/eningockdidmgiojffjmkdblpjocbhgh) | [Install full version](https://he.firefoxcn.net/en-US/guide/install-full-version) |
2425
| ![Edge Logo](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/75.0.1/edge/edge_16x16.png) Edge | None | [Edge Addons](https://microsoftedge.microsoft.com/addons/detail/header-editor/afopnekiinpekooejpchnkgfffaeceko) |
2526

27+
[Diff between Lite and Full Version](https://he.firefoxcn.net/en-US/guide/index.html)
28+
2629
## Permissions
2730

2831
Header Editor require those permissions:
@@ -33,6 +36,8 @@ Header Editor require those permissions:
3336

3437
* `storage`, `unlimitedStorage`: Storage rules and settings
3538

39+
* `debugger`: Modify response body in Chrome
40+
3641
* `unsafe-eval`: Execute custom function, code at [src/share/core/rule-utils.ts#L30](https://github.com/FirefoxBar/HeaderEditor/blob/dev/src/share/core/rule-utils.ts#L30) (may change in the future, you can search for the newest location by `new Function`)
3742

3843
## Contribution
@@ -47,13 +52,13 @@ English: Please submit a issue or pull request to file `locale/original/messages
4752

4853
Other language: Please translate them on [Transifex](https://app.transifex.com/sytec/header-editor/)
4954

50-
Please note that some languages (such as zh-Hans) will not be translated on transifex because the browser does not support them, click [here](https://developer.chrome.com/docs/webstore/i18n/#choosing-locales-to-support) to view full list
55+
Please note that some languages (such as zh-Hans) will not be translated on transifex because the browser does not support them, [view full list](https://developer.chrome.com/docs/webstore/i18n/#choosing-locales-to-support).
5156

5257
## How to build
5358

5459
### Build
5560

56-
* Install node (18+) and pnpm.
61+
* Install Node.js 20.x and pnpm 9.x.
5762
* Clone this project, or download the source code and extract it.
5863
* Run `pnpm i --frozen-lockfile`.
5964
* Run build command
@@ -75,7 +80,7 @@ Please note that some languages (such as zh-Hans) will not be translated on tran
7580

7681
Copyright © 2017-2025 [FirefoxBar Team](https://team.firefoxcn.net)
7782

78-
Open source licensed under [GPLv2](LICENSE).
83+
This project is licensed under the ​**GNU GPL v2.0 or later**.
7984

8085
## Technical Sponsorship
8186

docs/docs/en-US/guide/FAQ.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22
title: FAQ
33
---
44

5+
## "Header Editor" started debugging this browser
6+
7+
On Chrome, you'll see this prompt when the response body modification feature is enabled. If you don't want to see this prompt, you can:
8+
* Disable "Modify Response Body" in "Options".
9+
* Add the `--silent-debugger-extension-api` parameter when running Chrome.
10+
11+
## All rules are ineffective
12+
13+
In rare cases, some rules may fail to initialize due to syntax errors, resulting in all rules being ineffective.
14+
15+
In this case, you can find the specific rule and modify or disable it using the following methods:
16+
17+
Chrome:
18+
* Open `chrome://extensions/?id=eningockdidmgiojffjmkdblpjocbhgh`
19+
* Enable "Developer Mode" in the upper right corner
20+
* Click "Service Worker" under "Inspect View"
21+
* Find the error message and check the ID, corresponding rule, and error message.
22+
![img](https://img11.360buyimg.com/ddimg/jfs/t1/333577/33/836/91910/68a4ab26F2b85cd64/8d6cd3da3b9af51a.jpg)
23+
24+
Firefox:
25+
* Open `about:debugging`
26+
* Find "Header Editor" and click the "Inspect" button on the right.
27+
* Find the corresponding rule and error message.
28+
![img](https://img13.360buyimg.com/ddimg/jfs/t1/289605/39/18012/32092/68a4ae2cFa61f9a6a/9be7525f36abe945.jpg)
29+
530
## Why is "header name" reduced to lowercase?
631

732
[RFC 2616](https://tools.ietf.org/html/rfc2616.html#section-4.2) says:

docs/docs/en-US/guide/cloud-backup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ As I know, Chrome has limits on the number of operations per unit of time. It me
2929
### Firefox
3030

3131
* It seems that Firefox Sync is executed regularly, however if you want to force the cloud export you've to launch Firefox Sync manually.
32-
![](https://user-images.githubusercontent.com/886325/41821498-e081fe7e-77e1-11e8-81de-03a09d826cb9.png)
32+
![](https://img12.360buyimg.com/ddimg/jfs/t1/331038/40/854/2134/68a4ab75Fcd087439/c89009381abc82ea.jpg)
3333
* A new installation may cause cloud storage data to be blanked.
3434
* See [browser.storage API](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage) for more technical details.

docs/docs/en-US/guide/custom-function.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function(val, detail) { // does not include this line
2222

2323
For example:
2424

25-
![image](https://user-images.githubusercontent.com/5326684/54876966-6bd6c480-4e53-11e9-8e9d-6c950f8b5cd2.png)
25+
![image](https://img13.360buyimg.com/ddimg/jfs/t1/302163/31/25689/8426/68a4ab87Fffa8fbd6/4581fc50eaa1b2dc.jpg)
2626

2727
The custom function passes the arguments `val` and `detail`, where `detail` is the new parameter in version 2.3.0, see the description below. The return type varies depending on the rule type.
2828

docs/docs/en-US/guide/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Please choose a different installation method depending on your browser:
88

99
| | Browser | Lite Version | Full Version |
1010
| --- | --- | --- | --- |
11-
| ![Firefox Logo](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/75.0.1/firefox/firefox_16x16.png) | Firefox | None | [Mozilla Add-on](https://addons.mozilla.org/en-US/firefox/addon/header-editor/) or our [self-distributed version](https://github.com/FirefoxBar/HeaderEditor/releases) |
11+
| ![Firefox Logo](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/75.0.1/firefox/firefox_16x16.png) | Firefox | [Mozilla Add-ons](https://addons.mozilla.org/en-US/firefox/addon/header-editor-lite/) | [Mozilla Add-ons](https://addons.mozilla.org/en-US/firefox/addon/header-editor/) or our [self-distributed version](https://github.com/FirefoxBar/HeaderEditor/releases) |
1212
| ![Chrome Logo](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/75.0.1/chrome/chrome_16x16.png) | Chrome | [Chrome Web Store](https://chrome.google.com/webstore/detail/header-editor/eningockdidmgiojffjmkdblpjocbhgh) | [Install full version](./install-full-version) |
1313
| ![Edge Logo](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/75.0.1/edge/edge_16x16.png) | Edge | None | [Edge Addons](https://microsoftedge.microsoft.com/addons/detail/header-editor/afopnekiinpekooejpchnkgfffaeceko) |
1414

0 commit comments

Comments
 (0)