Skip to content

jingjingxyk/extension-v3-test

Repository files navigation

chromium extension v3

衍生于 https://github.com/justjavac/ReplaceGoogleCDN.git

ReplaceGoogleCDN 演示例子规则文件 位于本项目的 rules 目录

加载本扩展默认提供提供查看 chromium 、webrtc 源码功能

  1. chromium
  2. source.chromium
  3. summerofcode.withgoogle
  4. Google 开放源代码
  5. webrtc
  6. webrtc source code

准备代理服务,下载 chromium 源码

# vi https-switch-to-http-proxy.sh


socat -d -d   TCP4-LISTEN:8016,reuseaddr,fork ssl:http-proxy.xiaoshuogeng.com:8017,verify=1,snihost=http-proxy.xiaoshuogeng.com,commonname=http-proxy.xiaoshuogeng.com,openssl-min-proto-version=TLS1.3,openssl-max-proto-version=TLS1.3



# 备注: 服务端就是一个 nginx 仅此而已
# socat 需要支持TLSv1.3 

# 使用代理
export http_proxy=http://127.0.0.1:8016
export https_proxy=http://127.0.0.1:8016
export no_proxy="127.0.0.1,localhost"
 
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --depth=1 --progress

一:manifest.json declarative_net_reques 高级配置示例

{
  "declarative_net_request": {
    "rule_resources": [
      {
        "id": "remove-header",
        "enabled": true,
        "path": "rules/rules_remove_header_1.json"
      },
      {
        "id": "ruleset_redirect_1",
        "enabled": true,
        "path": "rules/rules_advance_redirect_1.json"
      },
      {
        "id": "ruleset_redirect_2",
        "enabled": true,
        "path": "rules/rules_advance_redirect_1.json"
      },
      {
        "id": "block",
        "enabled": true,
        "path": "rules/rules_block_1.json"
      }
    ]
  }
}

二:匹配指定域名

github.com -> github-com.proxy.domain.com

真实测试地址: https://github.com/ -> https://github-com.proxy.xiaoshuogeng.com/

  1. 尝试 github.com
{
  "id": "ruleset_advance_redirect_1",
  "enabled": true,
  "path": "rules/rules_advance_redirect_1.json"
}

三:动态匹配域名:

www.chromium.org -> https://2_www_xn--3px_chromium_xn--3px_org.proxy.domain.com

真实测试地址 https://chromium.googlesource.com/chromium/tools/depot_tools.git -> https://2_chromium_xn--3px_googlesource_xn--3px_com.proxy.xiaoshuogeng.com/chromium/tools/depot_tools.git

  1. 尝试 chromium
  2. 尝试 open source software 出色的开源软件
  3. 尝试 google opensource all projects
{
  "id": "ruleset_advance_redirect_2",
  "enabled": true,
  "path": "rules/rules_advance_redirect_1.json"
}

四:阻止指定域名 (拦截请求)

{
  "id": "ruleset_block_header_1",
  "enabled": true,
  "path": "rules/rules_block_1.json"
}

五:manifest host_permissions 例子

{
    "host_permissions": [ //指定地址写法
         "*://ajax.googleapis.com/*",
         "*://fonts.googleapis.com/*",
         "*://themes.googleusercontent.com/*",
         "*://fonts.gstatic.com/*",
         "*://ssl.gstatic.com/*",
         "*://www.gstatic.com/*",
         "*://secure.gravatar.com/*",
         "*://maxcdn.bootstrapcdn.com/*",
    ],
    "host_permissions": [ //所有地址写法,最省事
         "*://*.google.com/*",
        "*://*/*",
        "<all_urls>"
    ]
}

六:本地启动 web server

sh  startup-local-test-web-server.sh

七: 参考文档

  1. manifest-format
  2. manifest-format
  3. WebExtensions API
  4. webextensions-examples
  5. extensions declare_permissions
  6. extensions webRequest
  7. extensions chrome.tabs api
  8. extensions proxy
  9. contextMenus
  10. declarativeNetRequest ResourceType
  11. trusted_types_on_webui
  12. content_scripts
  13. scripting executeScript
  14. Content-Security-Policy/trusted-types
  15. gerrit
  16. chromium
  17. chromium source code
  18. chromium.googlesource
  19. chromium project
  20. Browse or Search Chromium Code
  21. opensource.google all projects
  22. declarativeNetRequest 的 ManifestV3 示例
  23. Proxy_Auto-Configuration_PAC_file
  24. use fetch
  25. chromium use proxy
  26. depot_tools
  27. puppeteer
  28. puppeteer example
  29. chrome-devtools-protocol
  30. pyppeteer
  31. webrtc/samples
  32. ReplaceGoogleCDN
  33. ReplaceGoogleCDN test example
  34. ReplaceGoogleCDN 依赖 公共 CDN 静态资源库
  35. 中文域名 punycode标准编码
  36. latest chromium
  37. latest firefox
  38. 正则表达式 - 元字符
  39. HTTP请求方法对照表
  40. Array.from()
  41. Promise.all()
  42. Array() 构造器
  43. MutationObserver 监视对 DOM 树更改
  44. 内容安全策略(CSP)
  45. 汉字 Unicode 编码范围
  46. 汉字字符集编码查询
  47. GoogleChrome/samples

八: 启动 chromium

# download chromium
  sh download-latest-chromium.sh
# run chromium
  sh chromium.sh

九: build codelab

# use proxy build
export PROXY_URL=http://127.0.0.1:8015
sh  build-prepare-codelab.sh

十: 域名

域名串不允许有除“-”以外的标点符号,包括空格。 可以夹杂中文和英文。 可以输入全角英文字母,全角字母不区分大小写。

About

ReplaceGoogleCDN 衍生测试项目

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published