是否提供排除规则
ivysrono opened this issue · comments
Yingcai Feng commented
你的意思是对主规则进行禁用吗,我不是太理解,麻烦你谢谢描述一下
ivysrono commented
给你看一条为了兼容Decentraleyes而写的Redirector规则吧。
{
"description": "Google -> 科大 1",
"exampleUrl": "https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js",
"exampleResult": "https://ajax.proxy.ustclug.org/ajax/libs/jquery/3.0.0/jquery.min.js",
"error": null,
"includePattern": "^https?://(ajax|fonts)\\.googleapis\\.com/(.+)",
"excludePattern": "https://ajax.googleapis.com/ajax/libs/jquery/(1.2.3|1.2.6|1.3.0|1.3.1|1.3.2|1.4.0|1.4.1|1.4.2|1.4.3|1.4.4|1.5.0|1.5.1|1.5.2|1.6.0|1.6.1|1.6.2|1.6.3|1.6.4|1.7.0|1.7.1|1.7.2|1.8.0|1.8.1|1.8.2|1.8.3|1.9.0|1.9.1|1.10.0|1.10.1|1.10.2|1.11.0|1.11.1|1.11.2|1.11.3|1.12.0|1.12.1|1.12.2|1.12.3|1.12.4|2.0.0|2.0.1|2.0.2|2.0.3|2.1.0|2.1.1|2.1.3|2.1.4)/jquery.min.js",
"redirectUrl": "https://$1.proxy.ustclug.org/$2",
"patternType": "R",
"processMatches": "noProcessing",
"disabled": false,
"appliesTo": [
"main_frame",
"sub_frame",
"stylesheet",
"script",
"image",
"object",
"xmlhttprequest",
"other"
]
},
Yingcai Feng commented
appliesTo 这个是可实现的,但是好像不需要为 Decentraleyes 做兼容处理,不启用相应的规则就可以了
Yingcai Feng commented
exclude 也可以加,下个版本会把这两个参数都加进去
ivysrono commented
能否把标题也就是 description 也加入?便于维护规则时加入简单注释。
Yingcai Feng commented
v1.2.10 已实现
ivysrono commented
能否有多条排除规则?如下,我还想写jquery以外的排除规则。
{
"description": "Google -> 科大 1",
"exampleUrl": "https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js",
"exampleUrl": "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js",
"origin": "^https?://ajax\\.googleapis\\.com/",
"exclude": "https://ajax.googleapis.com/ajax/libs/jquery/(1.2.3|1.2.6|1.3.0|1.3.1|1.3.2|1.4.0|1.4.1|1.4.2|1.4.3|1.4.4|1.5.0|1.5.1|1.5.2|1.6.0|1.6.1|1.6.2|1.6.3|1.6.4|1.7.0|1.7.1|1.7.2|1.8.0|1.8.1|1.8.2|1.8.3|1.9.0|1.9.1|1.10.0|1.10.1|1.10.2|1.11.0|1.11.1|1.11.2|1.11.3|1.12.0|1.12.1|1.12.2|1.12.3|1.12.4|2.0.0|2.0.1|2.0.2|2.0.3|2.1.0|2.1.1|2.1.3|2.1.4)/jquery.min.js",
"target": "https://ajax.proxy.ustclug.org/",
"enable": true
}
Yingcai Feng commented
目前有两种方式
(1)直接在同一个 exclude 的正式表达式里面写
(2)写成两条规则,让 exclude 不相同
Yingcai Feng commented
基本搞明白了Decentraleyes 的映射处理 https://github.com/Synzvato/decentraleyes/blob/master/lib/mappings.js ,可以通过增加一个在线的配置文件来处理 exclude 然后等 Decentraleyes 来处理,把这个在线规则优先级别调高就行,缺点是随着 Decentraleyes 的升级来修改配置文件。既然可以通过Decentraleyes 来做,我就不做本地缓存了,我后续加一个这样的在线规则。
如果能让 Decentraleyes 优先于 URLRediretor 执行,则理论上就能实现你想要的效果,但目前我还没有找到方法做这样的事。
Yingcai Feng commented
已完成,参见 #10