Skip to content

Commit

Permalink
新增 扩展程序选项雏形、格式化代码、新增高阶定制玩法辅助工具、新增自动化测试脚本 (justjavac#100)
Browse files Browse the repository at this point in the history
* 重新启用对firefox 的支持和衍生新仓库

* 新增 高阶定制玩法 辅助工具 新增 扩展程序选项 使用 prettier 格式化代码

* change options_ui

* test update-auth.sh

* save update-domain.sh changed

* save change

* fix error

* fix error

* add public static library

* fix error

* 修改打包程序,打包时去除无用文件

* fix test/READM.md test

* change v2 version

* change auto deploy.yaml setup

* change release-archive.sh

* 扩展选项:添加规则功能暂时屏蔽
  • Loading branch information
jingjingxyk authored Aug 3, 2022
1 parent bf8e2e8 commit d384a81
Show file tree
Hide file tree
Showing 51 changed files with 1,746 additions and 599 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Zip Extension
run: npm run build
run: npm run release
- name: Browser Plugin Publish
uses: PlasmoHQ/bpp@v2
with:
artifact: "extension.zip"
artifact: "dist/extension-v2.zip"
keys: ${{ secrets.SUBMIT_KEYS }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ extension/_metadata/
extension/test/extension-v3-test/
extension/test/chromium-tools/
package-lock.json
extension/tools/venv/
extension/tools/chrome-linux.zip
extension/tools/chrome-linux/
extension/test/nohup.out
dist
97 changes: 56 additions & 41 deletions CHANGELOG-0.10.x.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,78 @@
# CHANGELOG

## [测试用例](/extension/test/README.md)
## [一个完整的 测试环境例子 ](https://github.com/jingjingxyk/extension-v3-test)

## [一个完整的 测试环境例子 可用于查看优秀的源码 ](https://github.com/jingjingxyk/extension-v3-test)

## CHANGELOG for 0.10.7 [2022-07-31 12:43:40 +0800]

> 1. 新增 `developers.google.com` - 替换为 `developers.google.cn`
> 2. 整理规则,合并规则文件,并且重命名名称
> 3. 新增 高阶定制玩法 辅助工具
> 4. 新增 扩展程序选项 WebUI 可视化自定义规则雏形
> 5. 使用 prettier 格式化代码
> 6. 添加自动化测试脚本
## CHANGELOG for 0.10.6
> 1. 重新启用对firefox 的支持, 启用的扩展位于 `extension-v2` 目录
> 2. 移除目录 `extension/test/extension-v3-test`
> 3. 移除的目录衍生新仓库 [extension-v3-test](https://github.com/jingjingxyk/extension-v3-test)

> 1. 重新启用对 firefox 的支持, 启用的扩展位于 `extension-v2` 目录
> 2. 移除目录 `extension/test/extension-v3-test`
> 3. 衍生新仓库 [extension-v3-test](https://github.com/jingjingxyk/extension-v3-test)
## CHANGELOG for 0.10.5
>1. 新增 `cdn.jsdelivr.net` - 替换为 `fastly.jsdelivr.net`
>2. 新增 `cdnjs.cloudflare.com` - 替换为 `cdnjs.loli.net` 默认未启用
>3. 新增 公共 CDN 静态资源库 极客族公共加速服务 `https://cdn.geekzu.org/cached.html`
>4. 新增 公共 CDN 静态资源库 七牛静态库 `http://staticfile.org/`
>5. 新增 通过国内镜像 克隆本项目源代码

> 1. 新增 `cdn.jsdelivr.net` - 替换为 `fastly.jsdelivr.net`
> 2. 新增 `cdnjs.cloudflare.com` - 替换为 `cdnjs.loli.net` 默认未启用
> 3. 新增 公共 CDN 静态资源库 极客族公共加速服务 `https://cdn.geekzu.org/cached.html`
> 4. 新增 公共 CDN 静态资源库 七牛静态库 `http://staticfile.org/`
> 5. 新增 通过国内镜像 克隆本项目源代码
## CHANGELOG for 0.10.4

### 变更
>1. 修复 `www.google.com/recaptcha/` 无法显示问题; 通过新增 `extension/rules/rules_redirect_1_extra.json`实现
>2. test 环境 修改: `extension/test/extension-v3-test/README.md` 描述
>3. 格式化文件: `extension/rules/rules_redirect_1.json`
>4. 修复 `https://pub.dev/` 无法地址重定向;通过移除`pub.dev`的响应头`content-security-policy`实现
>5. test 用例 新增 `extension/test/README.md` 测试用例记录

> 1. 修复 `www.google.com/recaptcha/` 无法显示问题; 通过新增 `extension/rules/rules_redirect_1_extra.json`实现
> 2. test 环境 修改: `extension/test/extension-v3-test/README.md` 描述
> 3. 格式化文件: `extension/rules/rules_redirect_1.json`
> 4. 修复 `https://pub.dev/` 无法地址重定向;通过移除`pub.dev`的响应头`content-security-policy`实现
> 5. test 用例 新增 `extension/test/README.md` 测试用例记录
## CHANGELOG for 0.10.3

### 变更
>1. 新增 公共 CDN 静态资源库 中科大 `rules/README.md`
>2. 修改屏蔽 `content-security-policy`功能,新增4个屏蔽选项 ` ["cross-origin-embedder-policy", "cross-origin-opener-policy", "cross-origin-opener-policy-report-only","cross-origin-embedder-policy-report-only"]`
>3. 新增 移除`CSP`的请求地址 `githubusercontent.com`
>4. 新增 `cdnjs.cloudflare.com` 替换规则 `rules-cdnjs-cloudflare-com-redirect.json`,默认未启用
>5. test 环境 修改功能: github.com 地址替换后 PAJX 报错, 添加解决方案 `extension/test/extension-v3-test/js/content-scripts/github.js`
>6. test 环境 新增功能: 自定义规则第一版雏形 `extension/test/extension-v3-test/index.html`

> 1. 新增 公共 CDN 静态资源库 中科大 `rules/README.md`
> 2. 修改屏蔽 `content-security-policy`功能,新增 4 个屏蔽选项 ` ["cross-origin-embedder-policy", "cross-origin-opener-policy", "cross-origin-opener-policy-report-only","cross-origin-embedder-policy-report-only"]`
> 3. 新增 移除`CSP`的请求地址 `githubusercontent.com`
> 4. 新增 `cdnjs.cloudflare.com` 替换规则 `rules-cdnjs-cloudflare-com-redirect.json`,默认未启用
> 5. test 环境 修改功能: github.com 地址替换后 PAJX 报错, 添加解决方案 `extension/test/extension-v3-test/js/content-scripts/github.js`
> 6. test 环境 新增功能: 自定义规则第一版雏形 `extension/test/extension-v3-test/index.html`
## CHANGELOG for 0.10.2

## CHANGELOG for 0.10.2
### 变更
>1. test 环境 新增功能: service-worker `sw.js` 小工具,解决因域名地址替换导致出现的问题;比如 github PJAX 错误
>2. test 环境 新增功能: service-worker `sw.js` 小工具中 `extension/test/extension-v3-test/js/tools/self-define-browser-editor.js` 浏览器当作记事本使用
>3. test 环境 新增功能: service-worker `sw.js` 小工具中 `extension/test/extension-v3-test/js/tools/myscript-tools.js` 开启"上帝"模式,可编辑网页
>4. test 环境 新增功能: service-worker `sw.js` 小工具中 `extension/test/extension-v3-test/js/tools/myscript-tools.js` 查看网页引入的所有域名
>5. 新增 `code.query.com` jquery 地址替换
>6. 解决 0.10.1 版本中 `第9 , 10条不能共用问题`
>7. 删除 0.10.1 版本中 高级玩法 `excludedInitiatorDomains`错误配置 位于 `rules/rules_advance_redirect_2.json : "excludedInitiatorDomains":[] `
>8. maxcdn.bootstrapcdn.com 替换为 lib.baomitu.com

> 1. test 环境 新增功能: service-worker `sw.js` 小工具,解决因域名地址替换导致出现的问题;比如 github PJAX 错误
> 2. test 环境 新增功能: service-worker `sw.js` 小工具中 `extension/test/extension-v3-test/js/tools/self-define-browser-editor.js` 浏览器当作记事本使用
> 3. test 环境 新增功能: service-worker `sw.js` 小工具中 `extension/test/extension-v3-test/js/tools/myscript-tools.js` 开启"上帝"模式,可编辑网页
> 4. test 环境 新增功能: service-worker `sw.js` 小工具中 `extension/test/extension-v3-test/js/tools/myscript-tools.js` 查看网页引入的所有域名
> 5. 新增 `code.query.com` jquery 地址替换
> 6. 解决 0.10.1 版本中 `第9 , 10条不能共用问题`
> 7. 删除 0.10.1 版本中 高级玩法 `excludedInitiatorDomains`错误配置 位于 `rules/rules_advance_redirect_2.json : "excludedInitiatorDomains":[] `
> 8. maxcdn.bootstrapcdn.com 替换为 lib.baomitu.com
## CHANGELOG for 0.10.1 新增适配 chromium manifest v3 版本

## CHANGELOG for 0.10.1 新增适配 chromium manifest v3版本
### 变更

>1. `manifest.json -> manifest-v2.json` (已复制保存)
>2. `background.js` 不再使用了
>3. `manifest.json: manifest_version -> 3`
>4. 新增 `chromium manifest v3 declarativeNetRequest rules `
>5. 新增 `v3 redirect url rule (rules/rules_redirect_1.json)`
>6. 新增 `v3 remove response header rule` 可以移除CSP选项 ` (rules/rules_remove_header_1.json)`
>7. 新增 `v3 append request header rule` 可向请求头添加内容 `(rules/rules_append_header_1.json)`
>8. 新增 `v3 block request header rule` 锁请求 `(rules/rules_block_1.json)`
>9. 新增 v3 固定替换地址 rule `(rules/rules_advance_redirect_1.json)`
>10. 新增 v3 动态替换地址 rule ` (rules/rules_advance_redirect_2.json)`
>11. 上述第9-10条不能同时使用,会产生冲突
> 1. `manifest.json -> manifest-v2.json` (已复制保存)
> 2. `background.js` 不再使用了
> 3. `manifest.json: manifest_version -> 3`
> 4. 新增 `chromium manifest v3 declarativeNetRequest rules `
> 5. 新增 `v3 redirect url rule (rules/rules_redirect_1.json)`
> 6. 新增 `v3 remove response header rule` 可以移除 CSP 选项 ` (rules/rules_remove_header_1.json)`
> 7. 新增 `v3 append request header rule` 可向请求头添加内容 `(rules/rules_append_header_1.json)`
> 8. 新增 `v3 block request header rule` 锁请求 `(rules/rules_block_1.json)`
> 9. 新增 v3 固定替换地址 rule `(rules/rules_advance_redirect_1.json)`
> 10. 新增 v3 动态替换地址 rule ` (rules/rules_advance_redirect_2.json)`
> 11. 上述第 9-10 条不能同时使用,会产生冲突
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
1. `secure.gravatar.com` - gravatar 头像,替换为 `gravatar.loli.net`
1. `maxcdn.bootstrapcdn.com/bootstrap` - bootstrap 框架使用的 CDN,替换为 `lib.baomitu.com/twitter-bootstrap/`
1. `code.jquery.com/jquery-(version)(suffix)` - jquery 框架使用的 CDN,替换为 `lib.baomitu.com/jquery/$verson/$suffix`
1. `cdnjs.cloudflare.com` - 替换为 `cdnjs.loli.net` 默认未启用, 需要请自行打开
1. `cdnjs.cloudflare.com` - 替换为 `cdnjs.loli.net` 默认未启用, 需要请自行打开
1. `cdn.jsdelivr.net` - 替换为 `fastly.jsdelivr.net`
1. `developers.google.com` - 替换为 `developers.google.cn`

## 功能变更记录[`CHANGELOG-0.10.x`](CHANGELOG-0.10.x.md)

Expand Down Expand Up @@ -79,14 +80,14 @@ Chrome 安装方法(Google 被墙了上不去):
> 4. 选择 Load unpacked extension... 然后定位到刚才解压的文件夹里面的 extension 目录,确定
> 5. 这就安装好了,去掉 Developer Mode 勾选。
### 手动安装 (来自国内镜像) 克隆源代码以后, 步骤如上: :point_up_2: :point_up_2: :point_up_2:

### 手动安装 (来自国内镜像) 克隆源代码以后, 步骤如上: :point_up_2: :point_up_2: :point_up_2:
```shell
```shell
# 克隆源代码
git clone -b master https://gitee.com/mirrors/replacegooglecdn.git --depth=1 --progress
git clone -b master https://gitee.com/mirrors/replacegooglecdn.git --depth=1 --progress

# 更新源代码

git -C replacegooglecdn pull --depth=1 --progress --rebase=true

``````
```
2 changes: 1 addition & 1 deletion extension-v2/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# 启用同时支持 chromium 和 firefox
# 启用同时支持 chromium 和 firefox
3 changes: 2 additions & 1 deletion extension-v2/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ chrome.webRequest.onBeforeRequest.addListener(
return {redirectUrl: use_nginx_proxy(details,suffix_domain)};
*/

let url = details.url.replace("http://", "https://");
url = url.replace("ajax.googleapis.com", "ajax.loli.net");
url = url.replace("fonts.googleapis.com", "fonts.loli.net");
Expand All @@ -244,6 +243,7 @@ chrome.webRequest.onBeforeRequest.addListener(
//"cdn.jsdelivr.net/npm/bootstrap@$1/dist/$2"
"lib.baomitu.com/twitter-bootstrap/$1/$2"
);
url = url.replace("developers.google.com", "developers.google.cn");
return { redirectUrl: url };
},
{
Expand All @@ -257,6 +257,7 @@ chrome.webRequest.onBeforeRequest.addListener(
"*://www.gravatar.com/*",
"*://maxcdn.bootstrapcdn.com/bootstrap/*",
"*://cdn.jsdelivr.net/*",
"*://developers.google.com/*",
// ...test_urls // 测试用例
],
},
Expand Down
2 changes: 1 addition & 1 deletion extension-v2/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Replace Google CDN",
"version": "0.9.0",
"version": "0.10.7",
"manifest_version": 2,
"icons": {
"128": "icons/128.png"
Expand Down
4 changes: 1 addition & 3 deletions extension/js/background.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
chrome.runtime.onInstalled.addListener((details) => {

});
chrome.runtime.onInstalled.addListener((details) => {});
109 changes: 52 additions & 57 deletions extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,52 @@
{
"name": "Replace Google CDN",
"version": "0.10.5",
"manifest_version": 3,
"icons": {
"128": "icons/128.png"
},
"description": "将 Google CDN 替换为国内镜像",
"background": {
"service_worker": "js/background.js",
"type": "module"
},
"permissions": [
"declarativeNetRequest",
"declarativeNetRequestWithHostAccess",
"declarativeNetRequestFeedback"
],
"host_permissions": [
"<all_urls>"
],
"declarative_net_request" : {
"rule_resources" : [
{
"id": "ruleset_redirect_1",
"enabled": true,
"path": "rules/rules_redirect_1.json"
},
{
"id": "ruleset_redirect_1_extra",
"enabled": true,
"path": "rules/rules_redirect_1_extra.json"
},
{
"id": "ruleset_jquery_redirect_1",
"enabled": true,
"path": "rules/rules-code-jquery-redirect.json"
},
{
"id": "ruleset_remove_header_1",
"enabled": true,
"path": "rules/rules_remove_header_1.json"
},
{
"id": "ruleset_domain_replace_1",
"enabled": false,
"path": "rules/rules-domain-replace.json"
},
{
"id": "ruleset_cdn-jsdelivr-net_replace",
"enabled": true,
"path": "rules/rules-cdn-jsdelivr-net-redirect.json"
}
]
},
"author": "https://github.com/justjavac",
"homepage_url": "https://github.com/justjavac/ReplaceGoogleCDN"
}
{
"name": "Replace Google CDN",
"version": "0.10.7",
"manifest_version": 3,
"icons": {
"128": "icons/128.png"
},
"description": "将 Google CDN 替换为国内镜像",
"background": {
"service_worker": "js/background.js",
"type": "module"
},
"permissions": [
"declarativeNetRequest",
"declarativeNetRequestWithHostAccess",
"declarativeNetRequestFeedback"
],
"host_permissions": ["<all_urls>"],
"declarative_net_request": {
"rule_resources": [
{
"id": "ruleset_redirect_main",
"enabled": true,
"path": "rules/rules_redirect_main.json"
},
{
"id": "ruleset_redirect_main_extra",
"enabled": true,
"path": "rules/rules_redirect_main_extra.json"
},
{
"id": "ruleset_remove_content_security_policy_header",
"enabled": true,
"path": "rules/rules_remove_content_security_policy_header.json"
},
{
"id": "ruleset_domain_replace",
"enabled": false,
"path": "rules/rules_domain_replace.json"
}
]
},
"content_security_policy": {
"extension_pages": "default-src 'self';script-src 'self' 'wasm-unsafe-eval' ;object-src 'self'; style-src 'self' 'unsafe-inline';"
},
"options_ui": {
"page": "options_ui/index.html",
"open_in_tab": true
},
"author": "https://github.com/justjavac",
"homepage_url": "https://github.com/justjavac/ReplaceGoogleCDN"
}
15 changes: 15 additions & 0 deletions extension/options_ui/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
body {
background-color: #f8f8f8;
}

input {
min-width: 400px;
}
li {
font-size: 16px;
}

textarea {
min-width: 200px;
min-height: 200px;
}
37 changes: 37 additions & 0 deletions extension/options_ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Title</title>
<link href="/options_ui/css/app.css" type="text/css" rel="stylesheet" />
</head>
<body>
<h1>扩展选项</h1>

<h2>添加自定义规则</h2>
<div class="wrap">
<div class="container">
<div class="old-rule-list"></div>
<section class="box">
<!--
<input
name="rule"
type="text"
placeholder="添加规则功能未完善(不可用),希望有同志可以完善以下"
/>
-->
<button type="submit">提交规则</button>
</section>
</div>
</div>
<h2>已启用的规则列表:</h2>
<ul class="rule_set_list">
<li></li>
</ul>
<h2>规则详情:</h2>
<div>
<textarea cols="200" rows="40" id="rule-content-container"></textarea>
</div>
<script src="/options_ui/js/app.js"></script>
</body>
</html>
Loading

0 comments on commit d384a81

Please sign in to comment.