├── src ├── options │ ├── rule-import-input.css │ ├── constants.js │ ├── rule-tester.css │ ├── loading-dots.css │ ├── alert-popup.css │ ├── loading-dots.js │ ├── alert-popup.js │ ├── modal-dialog.css │ ├── type-input.js │ ├── rule-list.css │ ├── modal-dialog.js │ ├── common.css │ ├── changelog-dialog.js │ ├── rule-tester.js │ ├── options.css │ ├── rule-import-input.js │ ├── rule-list.js │ └── rule-input.css ├── background.html ├── main │ ├── rules │ │ ├── base.js │ │ ├── block.js │ │ ├── secure.js │ │ ├── whitelist.js │ │ └── filter.js │ ├── control.js │ ├── matchers.js │ └── api.js ├── install.js ├── util │ ├── uuid.js │ ├── badges.css │ ├── ui-helpers.js │ ├── i18n.js │ ├── tab.js │ ├── import-export.js │ ├── records.js │ ├── toc.js │ ├── notifier.js │ └── regexp.js ├── migrate.js ├── popup │ ├── browser-action.html │ ├── browser-action.css │ └── browser-action.js └── background.js ├── .github ├── issue_template.md └── workflows │ ├── release.yml │ └── main.yml ├── .gitmodules ├── .gitignore ├── icons ├── ionicons │ ├── add-outline.svg │ ├── bookmark-outline.svg │ ├── code-download-outline.svg │ ├── open-outline.svg │ ├── close-circle-outline.svg │ ├── book-outline.svg │ ├── download-outline.svg │ ├── shuffle-outline.svg │ ├── trash-bin.svg │ ├── warning-outline.svg │ ├── trash-bin-outline.svg │ ├── list-outline.svg │ ├── options-outline.svg │ └── LICENSE ├── icon.svg ├── icon-block.svg ├── icon-disabled.svg ├── icon-filter.svg ├── icon-redirect.svg ├── icon-secure.svg ├── icon-whitelist.svg └── firefox │ └── copy.svg ├── rules ├── privacy-duckduckgo.json ├── privacy-block-beacon-and-ping.json ├── privacy-qwant-lite.json ├── other-skip-image-downsamplers.json ├── privacy-here.json ├── privacy-linkedin.json ├── privacy-bing.json ├── privacy-youtube.json ├── privacy-facebook.json ├── privacy-common-params.json ├── privacy-amazon.json └── privacy-common-redirectors.json ├── _locales ├── README.rst ├── zh_CN │ └── manual.wiki └── es │ └── messages.json ├── test ├── tld.test.js ├── predefined-rules.test.js ├── patterns.test.js ├── include-exclude.test.js ├── encodeDecode.test.js ├── request-filters.test.js ├── tld-wildcard-matcher.test.js └── redirect.test.js ├── lib ├── tldts │ └── LICENSE └── lit │ └── LICENSE ├── manifest.json ├── README.rst ├── package.json └── CHANGELOG.md /src/options/rule-import-input.css: -------------------------------------------------------------------------------- 1 | * + * { 2 | margin: initial; 3 | } 4 | 5 | #delete { 6 | margin-left: 0.3em; 7 | } 8 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | ### Expected behavior 2 | 3 | ### Actual behavior 4 | 5 | ### Steps to reproduce the problem 6 | * 7 | * 8 | * -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/util/tags-input"] 2 | path = src/util/tags-input 3 | url = https://github.com/tumpio/tags-input.git 4 | branch = request-control 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | web-ext-artifacts/ 3 | manual.html 4 | node_modules 5 | .nyc_output/ 6 | coverage/ 7 | coverage.lcov 8 | 9 | lib/tldts/*.js 10 | lib/lit/lit.css 11 | -------------------------------------------------------------------------------- /icons/ionicons/add-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/background.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /icons/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/icon-block.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/icon-disabled.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/icon-filter.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/icon-redirect.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/icon-secure.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/icon-whitelist.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/firefox/copy.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/ionicons/bookmark-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/ionicons/code-download-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/ionicons/open-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/options/constants.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | export const OPTION_SHOW_COUNTER = "option_show_counter"; 6 | export const OPTION_CHANGE_ICON = "option_change_icon"; 7 | -------------------------------------------------------------------------------- /src/main/rules/base.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | export class ControlRule { 6 | constructor({ uuid, tag }) { 7 | this.uuid = uuid; 8 | this.tag = tag; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /icons/ionicons/close-circle-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/ionicons/book-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/install.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | function handleInstalled(details) { 6 | if (details.reason === "install") { 7 | browser.runtime.openOptionsPage(); 8 | } 9 | } 10 | 11 | browser.runtime.onInstalled.addListener(handleInstalled); 12 | -------------------------------------------------------------------------------- /icons/ionicons/download-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/util/uuid.js: -------------------------------------------------------------------------------- 1 | export function uuid() { 2 | const hex = []; 3 | 4 | for (let i = 0; i < 256; i++) { 5 | hex[i] = (i < 16 ? "0" : "") + i.toString(16); 6 | } 7 | 8 | const r = crypto.getRandomValues(new Uint8Array(16)); 9 | 10 | r[6] = (r[6] & 0x0F) | 0x40; 11 | r[8] = (r[8] & 0x3F) | 0x80; 12 | 13 | const h = (...n) => n.map((i) => hex[r[i]]).join(""); 14 | 15 | return `${h(0, 1, 2, 3)}-${h(4, 5)}-${h(6, 7)}-${h(8, 9)}-${h(10, 11, 12, 13, 14, 15)}`; 16 | } 17 | -------------------------------------------------------------------------------- /icons/ionicons/shuffle-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/ionicons/trash-bin.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rules/privacy-duckduckgo.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "uuid": "c7ca4ba4-1a16-4b98-b645-62d22ae582ee", 4 | "pattern": { 5 | "scheme": "*", 6 | "host": [ 7 | "duckduckgo.com" 8 | ], 9 | "path": [ 10 | "l/?*" 11 | ] 12 | }, 13 | "types": [ 14 | "main_frame", 15 | "sub_frame" 16 | ], 17 | "action": "filter", 18 | "active": true, 19 | "tag": "privacy-duckduckgo" 20 | } 21 | ] -------------------------------------------------------------------------------- /icons/ionicons/warning-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/ionicons/trash-bin-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rules/privacy-block-beacon-and-ping.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "title": "Block Beacon and Ping requests", 4 | "description": "Blocks Beacon and Ping requests. The Beacon API is often used for logging user activity and sending analytics data to the server.", 5 | "tag": "block-beacon-ping", 6 | "uuid": "32db1f93-f99d-4c45-8485-e5c7beec5a69", 7 | "pattern": { 8 | "allUrls": true 9 | }, 10 | "action": "block", 11 | "active": true, 12 | "types": [ 13 | "beacon", 14 | "ping" 15 | ] 16 | } 17 | ] -------------------------------------------------------------------------------- /rules/privacy-qwant-lite.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "title": "Skip Qwant Lite redirect", 4 | "description": "Skip Qwant Lite redirect in search results", 5 | "uuid": "62b1a6c1-76ea-43c1-9d4d-dde55d5855e9", 6 | "pattern": { 7 | "scheme": "*", 8 | "host": [ 9 | "lite.qwant.com" 10 | ], 11 | "path": [ 12 | "redirect/*" 13 | ] 14 | }, 15 | "types": [ 16 | "main_frame" 17 | ], 18 | "action": "redirect", 19 | "active": true, 20 | "redirectUrl": "{pathname/\\/redirect\\/[A-Za-z0-9]+==\\//|decodeBase64|decodeURIComponent}" 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /src/main/rules/block.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | import { ControlRule } from "./base.js"; 6 | 7 | export const BLOCKING_RESPONSE = { cancel: true }; 8 | 9 | export class BlockRule extends ControlRule { 10 | resolve(request) { 11 | this.constructor.notify(this, request); 12 | return BLOCKING_RESPONSE; 13 | } 14 | } 15 | 16 | BlockRule.icon = "/icons/icon-block.svg"; 17 | BlockRule.action = "block"; 18 | -------------------------------------------------------------------------------- /src/main/rules/secure.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | import { ControlRule } from "./base.js"; 6 | 7 | export const SECURE_RESPONSE = { upgradeToSecure: true }; 8 | 9 | export class SecureRule extends ControlRule { 10 | resolve(request) { 11 | this.constructor.notify(this, request); 12 | return SECURE_RESPONSE; 13 | } 14 | } 15 | 16 | SecureRule.icon = "/icons/icon-secure.svg"; 17 | SecureRule.action = "secure"; 18 | -------------------------------------------------------------------------------- /icons/ionicons/list-outline.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_locales/README.rst: -------------------------------------------------------------------------------- 1 | Translating Request Control 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | To begin translation copy **en** folder and its content to a new 5 | directory and name it after the new locale. 6 | 7 | **Note:** Separator for regional variant in directory name must be 8 | written with underscore, e.g. "en_US". 9 | 10 | Locale's directory content: 11 | 12 | - messages.json file - Includes all extension's localised strings including 13 | extension's name and description. 14 | - manual.wiki - Is the localised manual written in `MediaWikihttp 和 https。
16 |
17 | {|
18 | | http
19 | | 匹配 http 协议的请求。
20 | |-
21 | | https
22 | | 匹配 https 协议的请求。
23 | |-
24 | | http/https
25 | | 同时匹配 http 和 https 协议的请求。
26 | |}
27 |
28 | ==== 主机 ====
29 |
30 | 主机匹配可以通过下列方式匹配请求的 URL 中的主机(host)。
31 |
32 | {|
33 | | www.example.com
34 | | 匹配完整主机。
35 | |
36 | |-
37 | | *.example.com
38 | | 匹配指定的主机以及它的所有子域名。
39 | | 将会匹配 example.com 的所有子域名,例如 '''www'''.example.com 和 '''good'''.example.com
40 | |-
41 | | www.example.*
42 | | 匹配符合顶级域名列表的指定主机。 (可以配合子域名匹配)
43 | | 需将所需的顶级域名写入到顶级域名列表框(例如 ''com''、''org'')。
44 | |-
45 | | *
46 | | 匹配任何主机。
47 | |
48 | |}
49 |
50 | ==== 路径 ====
51 |
52 | 路径匹配可以是通配符 "*" 和所有 URL 路径中允许的字符的任意组合。通配符 "*" 能够匹配路径的任意部分,且可以出现多次。
53 |
54 | 下面是一些使用路径匹配的示例。
55 |
56 | {|
57 | | *
58 | | 匹配任意路径。
59 | |-
60 | | path/a/b/
61 | | 匹配特定路径 "path/a/b/"。
62 | |-
63 | | *b*
64 | | 匹配所有包含 "b" 的路径,只要路径中出现就匹配。
65 | |-
66 | |
67 | | 匹配空路径。
68 | |}
69 |
70 | === 类型 ===
71 |
72 | 类型代表请求的资源种类。可以匹配一或多种类型,也可以匹配任意类型。下面列出了所有可能的类型。
73 |
74 | {|
75 | ! 类型
76 | ! 细节
77 | |-
78 | | 文档
79 | | 代表浏览器标签页中的顶级 DOM 文档。(main frame)
80 | |-
81 | | 子文档
82 | | 代表附属于其他文档的 DOM 文档(sub frame)
83 | |-
84 | | 样式表
85 | | 代表样式表(.css 文件)。
86 | |-
87 | | 脚本
88 | | 代表可执行脚本(例如 JavaScript)。
89 | |-
90 | | 图像
91 | | 代表图像(例如 <img> 元素载入的内容)。
92 | |-
93 | | 对象
94 | | 代表对象(<object> 和 <embed> 元素的内容)。
95 | |-
96 | | 插件
97 | | 代表由插件发起的请求。(object_subrequest)
98 | |-
99 | | XMLHttpRequest
100 | | 代表 XMLHttpRequest 请求。
101 | |-
102 | | XSLT
103 | | 代表可扩展样式表转换语言(英文:Extensible Stylesheet Language Transformations,缩写为 XSLT)文档。
104 | |-
105 | | Ping
106 | | 代表因点击带有 ping 属性的 <a> 元素时发出的请求。只有 about:config 中 browser.send_pings 属性被启用时才会发出(默认为禁用)。
107 | |-
108 | | Beacon
109 | | 代表信标([https://developer.mozilla.org/en-US/docs/Web/API/Beacon_API Beacon])请求。
110 | |-
111 | | XML DTD
112 | | 代表被 XML 文档载入的 DTD 文件。
113 | |-
114 | | Font
115 | | 代表通过 CSS @font-face 规则引入的字体。
116 | |-
117 | | Media
118 | | 代表视频或音频。
119 | |-
120 | | WebSocket
121 | | 代表 [https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API WebSocket] 请求。
122 | |-
123 | | CSP Report
124 | | 代表内容安全策略([https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP Content Security Policy])报告。
125 | |-
126 | | Imageset
127 | | 代表加载带 srcset 属性的 <img> 或 <picture> 元素的内容的请求。
128 | |-
129 | | Web Manifest
130 | | 代表加载 Web manifest 的请求。
131 | |-
132 | | Other
133 | | 代表未被归类为上述任何类型的请求。
134 | |}
135 |
136 | === 动作 ===
137 |
138 | ; [[File:/icons/icon-filter.svg|16px]] 过滤
139 | : 跳过 URL 重定向,并/或移除 URL 查询参数。
140 | ; [[File:/icons/icon-redirect.svg|16px]] 重定向
141 | : 将请求重定向至手动配置的目标 URL。
142 | ; [[File:/icons/icon-secure.svg|16px]] 加密
143 | : 将不安全的 HTTP 请求升级为 HTTPS 请求。
144 | ; [[File:/icons/icon-block.svg|16px]] 拦截
145 | : 在请求被发出之前取消请求。
146 | ; [[File:/icons/icon-whitelist.svg|16px]] 白名单
147 | : 白名单并可选地在日志中记录请求。
148 |
149 | == 其他 URL 匹配方式 ==
150 |
151 | 以下匹配器扩展了 [https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/RequestFilter WebRequest API] 的匹配功能。
152 |
153 | ==== 包括和排除 ====
154 |
155 | 通过支持通配符 "?" 和 "*"(其中 "?" 匹配任何单个字符,而 "*" 匹配零或多个字符)的字符串匹配,来过滤匹配的请求。也可通过在匹配模式前后加 "/" 字符来使用正则表达式。
156 |
157 | 包括和排除不区分大小写,而[[#主机|主机]]和[[#路径|路径]]区分大小写。
158 |
159 | 以下是使用包括和排除模式匹配的示例:
160 |
161 | {|
162 | | login
163 | | 匹配所有包括 "login" 的 URL。
164 | |-
165 | | log?n
166 | | 匹配包括例如 "login" 或者 "logon" 等等的 URL。
167 | |-
168 | | a*b
169 | | 匹配先后出现 "a" 和 "b" 的 URL。
170 | |-
171 | | /[?&]a=\d+(&|$)/
172 | | 匹配包含参数 "a" 的 URL,该参数的值为数字。
173 | |}
174 |
175 | === Match by origin ===
176 |
177 | 按照跨域情况过滤匹配的规则。
178 |
179 | {|
180 | | Any
181 | | 匹配任意跨域情况的请求。
182 | |-
183 | | Same domain
184 | | 匹配同域名的请求。
185 | |-
186 | | Same origin
187 | | 匹配同源的请求。按照[https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy 同源策略]判定。
188 | |-
189 | | Third party domain
190 | | 匹配第三方域名的请求。
191 | |-
192 | | Third party origin
193 | | 匹配第三方源的请求。
194 | |}
195 |
196 | == Rule priorities ==
197 |
198 | # 白名单规则
199 | # 拦截规则
200 | # 加密规则
201 | # 重定向规则
202 | # 过滤规则
203 |
204 | == 去除 URL 参数 ==
205 |
206 | 过滤规则支持去除 URL 参数。可以在要去除的 URL 参数的名称中使用通配符 "*" 和 "?",或者正则表达式。
207 |
208 | 下面是去除 URL 参数的示例。
209 |
210 | {|
211 | | utm_source
212 | | 去除 "utm_source" 参数。
213 | |-
214 | | utm_*
215 | | 去除所有以 "utm_" 开头的参数。
216 | |-
217 | | /[0-9]+/
218 | | 去除所有参数名称仅由数字构成的参数。
219 | |}
220 |
221 | === 反转要去除的请求参数选项 ===
222 |
223 | 仅保留参数列表中所定义的参数,移除所有其他参数。
224 |
225 | === 移除全部请求参数选项 ===
226 |
227 | 从匹配的请求中移除所有 URL 查询参数。
228 |
229 | == 使用模式捕获重定向 ==
230 |
231 | 重定向规则支持将请求重定向至一个从原始请求 URL 修改而来的 URL。可以使用参数展开来使用和更改目标 URL 的某些组成部分(命名参数);也可以使用重定向指令,更改目标 URL 的某些组成部分(命名参数),比如只更改原始请求 URL 的端口。
232 |
233 | 这两种方法可以结合使用。将首先解析并应用重定向指令,再轮到参数扩展。
234 |
235 | 可以在重定向指令中使用参数展开。
236 |
237 | === 参数展开 ===
238 |
239 | {parameter}
240 | 访问原始请求 URL 中的某个命名参数。本节末尾列出了可用的命名参数。
241 |
242 | 参数展开支持以下字符串操作语法:
243 |
244 | ==== 替换子字符串 ====
245 |
246 | {parameter/pattern/replacement}
247 |
248 | 将首个匹配 pattern 的子字符串替换为 replacement。
249 |
250 | {parameter//pattern/replacement}
251 |
252 | 将所有匹配 pattern 的子字符串替换为 replacement。
253 |
254 | 匹配模式 pattern 使用正则表达式编写。replacement 中支持使用一些特殊替换,包括引用捕获组(capture group),下面的表格描述了支持的特殊替换。
255 |
256 | {|
257 | | $n
258 | | 插入第 n 个捕获组,从 1 开始计数。
259 | |-
260 | | $`
261 | | 插入被匹配到的子字符串之前的部分。
262 | |-
263 | | $'
264 | | 插入被匹配到的子字符串之后的部分。
265 | |-
266 | | $&
267 | | 插入被匹配到的子字符串。
268 | |-
269 | | $$
270 | | 插入一个 "$" 字符。
271 | |}
272 |
273 | ==== 提取子字符串 ====
274 |
275 | {parameter:offset:length}
276 |
277 | 提取扩展参数的一个部分。偏移量 offset 确定起始位置,从 0 开始计数;如果为负值,则从字符串结尾开始算起。
278 |
279 | ==== 解码和编码 ====
280 |
281 | {parameter|encodingRule}
282 |
283 | 对匹配模式的展开值进行解码或编码操作。
284 |
285 | {|
286 | | encodeURI
287 | | 将值编码为 URI。不编码以下字符:":"、"/"、";",和 "?"。
288 | |-
289 | | decodeURI
290 | | 将值作为 URI 解码。
291 | |-
292 | | encodeURIComponent
293 | | 将值编码为 URI 组件。会编码所有 URI 保留字符。
294 | |-
295 | | decodeURIComponent
296 | | 将值作为 URI 组件解码。
297 | |-
298 | | encodeBase64
299 | | 将值编码为 Base64 字符串。
300 | |-
301 | | decodeBase64
302 | | 将值作为 Base64 字符串解码。
303 | |}
304 |
305 | ==== 合并参数展开操作 ====
306 |
307 | {parameter(manipulation1)|(manipulation2)...|(manipulationN)}
308 | 可以使用管道符 "|" 链式调用多个字符串操作规则。输出结果是被依次操作过的参数值。
309 |
310 | ==== 示例 ====
311 |
312 | {|
313 | | https://{hostname}/new/path
314 | | 复用原始请求中的主机名。
315 | |-
316 | | https://{hostname/([a-z]{2}).*/$1}/new/path
317 | | 提取原始请求中的主机名的一部分并复用。
318 | |-
319 | | https://{hostname::-3|/.co/.com}/new/path
320 | | 去除原始请求中的主机名中的最后 3 个字符,再将其中的第一个 ".co" 替换为 ".com",再复用。
321 | |-
322 | | {search.url|decodeURIComponent}
323 | | 捕获原始请求的查询参数中的 "url" 参数,并将其解码,作为重定向目标。
324 | |}
325 |
326 | === 重定向指令 ===
327 |
328 | [parameter=value]329 | 330 | 替换原始请求的特定组成部分。本节末尾列出了可用的命名 URL 参数(named URL parameters)。 331 | 332 |
[parameter={parameter}]
333 |
334 | 可以通过上述参数扩展语法对重定向指令的值进行参数化(parametrize)。
335 |
336 | ==== 示例 ====
337 |
338 | {|
339 | | [port=8080]
340 | | 将原始请求的端口重定向至 8080。
341 | |-
342 | | [port=8080][hostname=localhost]
343 | | 将原始请求的主机重定向至 localhost:8080。
344 | |-
345 | | [port=8080][hostname=localhost][hash={pathname}]
346 | | 将原始请求的主机重定向至 localhost:8080,并将哈希(hash,#)更改为原始请求的主机名。
347 | |}
348 |
349 | === 命名参数列表 ===
350 |
351 | 下表列出了支持的参数名称以及输出示例。
352 |
353 | 作为输入的示例地址:
354 |
355 | https://www.example.com:8080/some/path?query=value#hash356 | {| 357 | ! 名称 358 | ! 输出 359 | |- 360 | | protocol 361 | |
https:
362 | |-
363 | | hostname
364 | | www.example.com
365 | |-
366 | | port
367 | | :8080
368 | |-
369 | | pathname
370 | | /some/path
371 | |-
372 | | search
373 | | ?query=value
374 | |-
375 | | search.query
376 | | value
377 | |-
378 | | hash
379 | | #hash
380 | |-
381 | | host
382 | | www.example.com:8080
383 | |-
384 | | origin
385 | | https://www.example.com:8080
386 | |-
387 | | href
388 | | https://www.example.com:8080/some/path?query=value#hash
389 | |}
390 |
391 | 此手册页面基于以下 MDN 维基文档中的资料编写,以 [http://creativecommons.org/licenses/by-sa/2.5/ CC-BY-SA 2.5] 协议授权。
392 |
393 | # [https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Match_patterns Match patterns] by [https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Match_patterns$history Mozilla Contributors] is licensed under [http://creativecommons.org/licenses/by-sa/2.5/ CC-BY-SA 2.5].
394 | # [https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/ResourceType webRequest.ResourceType] by [https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/ResourceType$history Mozilla Contributors] is licensed under [http://creativecommons.org/licenses/by-sa/2.5/ CC-BY-SA 2.5].
395 | # [https://developer.mozilla.org/en-US/docs/Web/API/URL URL] by [https://developer.mozilla.org/en-US/docs/Web/API/URL$history Mozilla Contributors] is licensed under [http://creativecommons.org/licenses/by-sa/2.5/ CC-BY-SA 2.5].
396 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6 |
7 | ## [Unreleased]
8 | - Add option to remove toolbar icon counter. #129
9 | - Add support for matching hostnames without suffix (TLD wildcard). #126
10 | - Add private browsing matcher to ignore or only use in private browsing.
11 |
12 | ## [1.15.5] - Jul. 7, 2020
13 | - Fix rule creation after 1.15.3. #131
14 |
15 | ## [1.15.4] - Jul. 3, 2020
16 | - Fix required validation after 1.15.3. #131
17 |
18 | ## [1.15.3] - Jul. 3, 2020
19 | - Fix Redirect rule not being applied when multiple rules were matching a single request. #111
20 | - Fix rule tester with multiple redirect rules.
21 | - Remove backspace deleting added parameters. #128
22 |
23 | ## [1.15.2] - Mar. 28, 2020
24 | - Fix Filter rule not being applied when multiple filter rules were matching a single request. #111
25 |
26 | ## [1.15.1] - Mar. 13, 2020
27 | - Fix popup height when placed to overflow menu. #111
28 | - Fix rule tester regexp escaping. #113
29 | - Fix selected rules exporting.
30 |
31 | ## [1.15.0] - Mar. 11, 2020
32 | - Add Secure action to upgrade HTTP requests to HTTPS.
33 | - Add new default rules: FBCLID stripping rule and FB redirection service rule. #110 by @AreYouLoco
34 | - Fix text color when default color is changed. #112 by @Zocker1999NET
35 | - Fix filter/redirect actions to be applied and logged separately.
36 | - Remove Downloads API dependency for rule export.
37 | - Update icons and badge color.
38 |
39 | ## [1.14.0] - Sep 8, 2019
40 | - Add option to redirect document (update tab) from other requests types. #103
41 | - Fix invalid regexp pattern breaking all other rules. #107
42 | - Keep last record when redirect/filter rule is followed by a server redirection.
43 |
44 | ## [1.13.3] - Aug 22, 2019
45 | - Fix hosts/paths input field overflow issue with long list of values (2nd fix). #104
46 | - Fix updating of input fields for merged rules after import.
47 | - Accept text files on import.
48 |
49 | ## [1.13.2] - Aug 19, 2019
50 | - Fix comma not accepeted in includes/excludes input fields. #105
51 | - Fix hosts/paths input field overflow issue with long list of values. #104
52 |
53 | ## [1.13.1] - Aug 10, 2019
54 | - Fix subdocument redirect regression issue #103
55 | - Fix bad localization key.
56 |
57 | ## [1.13.0] - Aug 5, 2019
58 | - Change query parameter trimming in Filter Rule to not apply to the extracted redirect URL. #99
59 | - Add replace all substring support for Redirect Rule. #101
60 |
61 | ## [1.12.4] - June 29, 2019
62 | - Add workaround for Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1557300. #100
63 | - Other improvements to options (rule delete button, create button / new rule validation fix, type badge)
64 |
65 | ## [1.12.3] - May 12, 2019
66 | - Update style and manual.
67 | - Fix rule edit link in popup.
68 |
69 | ## [1.12.2] - April 28, 2019
70 | - Order rules alphabetically. #90
71 |
72 | ## [1.12.1] - April 27, 2019
73 | - Update style for more compact layout.
74 |
75 | ## [1.12.0] - April 22, 2019
76 | - Add Android support and update layout and style for mobile browsers. #88
77 | - Add speculative request type. #81
78 | - Add support for matching requests by origin. #36
79 | - Close modals on Escape-key. #91
80 | - Fix action buttons disabled issue. #96
81 | - Fix white list rule testing no feedback issue. #92
82 | - Fix percent sign issue with redirect rules. #95
83 |
84 | ## [1.11.1] - September 6, 2018
85 | - Add strict min version requirement for Firefox 60.
86 | - Remove debug console logging #80.
87 |
88 | ## [1.11.0] - August 17, 2018
89 | - Add support for skipping redirection url filtering within same domain. #29
90 |
91 | ## [1.10.1] - August 4, 2018
92 | - Fix excludes/includes with Any URL. #77
93 |
94 | ## [1.10.0] - July 29, 2018
95 | - Add keywords to decode and encode captured patterns for redirect rule #6
96 | - Add includes and excludes pattern support #16 #24 #35
97 | - Add option to control whitelist logging #59
98 | - Add query parameter expansion support for redirect rule #72
99 | - Change to trim unwanted query parameters before inline url parsing #72
100 | - Update active and disabled icons #70
101 | - Fix parsing of redirect instructions with inline brackets #73
102 |
103 | ## [1.9.4] - May 26, 2018
104 | - Fix rule import after 1.9.3 changes.
105 | - Fix showing number of selected rules for new rules.
106 |
107 | ## [1.9.3] - May 24, 2018
108 | - Add alphabetizing patterns. #57
109 | - Add Select / select none input #63
110 | - Add showing number of selected rules #64
111 | - Add UUID for rules. Rules with same UUID will be overwritten when importing rules.
112 | - Fix Rule Tester to escape '?' in path. #65
113 | - Fix redirecting by manipulating 'hostname'. #69
114 |
115 | ## [1.9.2] - May 15, 2018
116 | - Add disabled state icon.
117 | - Fix resolving match patterns with multiple paths and TLDs. #66
118 |
119 | ## [1.9.1] - May 13, 2018
120 | - Fix toolbar icon updating.
121 | - Fix adding two-character long generic domains. #56
122 | - Fix adding comma to trim parameters. #58
123 |
124 | ## [1.9.0] - May 9, 2018
125 | - Add rule tester for testing selected rules against test URL.
126 | - Add support for rule tagging in panel.
127 | - Add rule edit links in panel.
128 | - Add disable/enable button in panel.
129 | - Change Redirect instructions to supports parameter expansion in value.
130 | - Update options style and panel layout.
131 | - Locale: ES Spanish, thanks to @strel at Github!
132 |
133 | ## [1.8.6] - Nov. 26, 2017
134 | - Fix Redirect to static url.
135 | - Fix combining parameter expansion with redirect instructions.
136 | - Add unit tests.
137 |
138 | ## [1.8.5] - Nov. 25, 2017
139 | - Fix query parameter trimming. #50
140 | - Fix icons not showing in rules view.
141 |
142 | ## [1.8.4] - Nov. 18, 2017
143 | - Fix build.
144 |
145 | ## [1.8.3] - Nov. 17, 2017
146 | - Fix regex repetition quantifier not supported in pattern captures. #45 #47
147 | - Fix query parameters trimming on non-standard urls. #48 #40
148 |
149 | ## [1.8.2] - August 6, 2017
150 | - Fix Filter rule to always decode redirection URL.
151 | - Add version in about page.
152 |
153 | ## [1.8.1] - July 22, 2017
154 | - Fix save rule on title/description change.
155 | - Fix any-url host input required validation.
156 | - Add description for default rules.
157 | - Load default rules from file ("/options/default-rules.json").
158 | - Strip paramsTrim pattern from exported rules.
159 |
160 | ## [1.8.0] - July 19, 2017
161 | - Rules are now auto saved on change.
162 | - Rule name and description are editable.
163 | - Add invert URL parameter trim option.
164 | - Add about page.
165 | - Other changes to rule options display.
166 |
167 | ## [1.7.1] - July 1, 2017
168 | - Fix whitelist/block rule request markers.
169 | - Fix migrate script for Firefox versions before 55.
170 |
171 | ## [1.7.0] - June 29, 2017
172 | - Add rules export and import. #8
173 | - Add toolbar button to list details of applied rules on current tab. #19
174 | - Add tabs to options view.
175 | - Fix trim parameter inconsistency: support literal string params and regexp params. #17
176 | - Fix pageAction details bug with block rules. #19
177 | - Fix filter rule redirection url filtering. #20
178 | - Remove url status icon. #19
179 |
180 | ## [1.6.1] - June 21, 2017
181 | - Add i18n support
182 | - Add request details in page action popup
183 | - Fix query parameters trim with valueless params
184 |
185 | ## [1.6.0] - June 13, 2017
186 | - Add support for multiple rule matching for single request.
187 | - Add support for adding multiple hosts and paths for rules.
188 | - Remove 'Include subdomains' checkbox.
189 | - Improve rules options view.
190 |
191 | ## [1.5.0] - June 1, 2017
192 | - URL parameter filtering is now Filter rule specific.
193 | - Redirection cleaning can now be turned off in Filter rule.
194 | - Added wildcard "*" support for url parameter trimming.
195 |
196 | ## [1.4.3] - May 27, 2017
197 | - Fix url parameter filtering for global rules.
198 | - Fix redirection url parsing from query string.
199 | - Fix default google filter rule, include main frame requests.
200 | - Fix filter action handler to only do tab navigation on sub_frame requests.
201 |
202 | ## [1.4.2] - May 7, 2017
203 | - Fix to escape forward slash in replace regex pattern.
204 | - Add toggle rule edit on double click.
205 |
206 | ## [1.4.1] - April 12, 2017
207 | - Change the default type for new rules to be the document type.
208 | - Change any url and any type buttons to be the rightmost on rule panel.
209 | - Fix more than one parameter expansions failing in redirection address.
210 | - Fix undefined rule title when saving a new rule without changing its action.
211 |
212 | ## [1.4.0] - April 10, 2017
213 | - Add support for pattern capturing (parameter expansion) to redirect based on the original request.
214 | - Add support for parameter instructions to redirect based on the original request.
215 | - Change help page to open in a new page.
216 | - Update help and add attributions to the MDN documents.
217 | - Fix missing title for options page.
218 |
219 | ## [1.3.0] - March 27, 2017
220 | - Add whitelist rules support.
221 | - Add