-
-
Notifications
You must be signed in to change notification settings - Fork 172
Home
Welcome to the gooreplacer wiki!
在浏览器地址栏中输入以下链接,如果能转到 lug.ustc.edu.cn 或 cdn.rawgit.com 相应的资源即说明替换成功。
- https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js
- https://storage.googleapis.com/io13/gcs_import/index.html
- https://gerrit.googlesource.com
- https://www.gravatar.com
- https://apis.google.com/js/api.js
- https://apis.google.com/js/plusone.js
- https://platform.twitter.com/widgets.js
- https://fonts.googleapis.com/css?family=Open+Sans
- http://fonts.googleapis.com/css?family=Open+Sans
The webRequest API only exposes requests that the extension has permission to see, given its host permissions. Moreover, only the following schemes are accessible: http://, https://, ftp://, file://, ws:// (since Chrome 58), wss:// (since Chrome 58), or chrome-extension://.
Currently gooreplacer support 4 functions. Take one exported rules as example:
{
"createBy": "https://github.com/jiacai2050/gooreplacer",
"version": "2.0",
"createAt": "Sun Oct 29 2017 19:55:32 GMT+0800 (CST)",
"redirect-rules": [
{
"src": "ajax.googleapis.com",
"dst": "ajax.proxy.ustclug.org",
"kind": "wildcard",
"enable": true
}
],
"cancel-rules": [
{
"src": "facebook.com",
"kind": "wildcard",
"enable": true
}
],
"request-headers": [
{
"src": "google.com",
"kind": "wildcard",
"name": "user-agent",
"value": "gooreplacer",
"op": "modify",
"enable": true
}
],
"response-headers": [
{
"src": "google.com",
"kind": "wildcard",
"name": "Cookie",
"op": "cancel",
"enable": true
}
]
}
-
redirect-rulesused for redirects -
cancel-rulesused for blocks -
request-headersused for modify/cancel http request headers -
response-headersused for modify/cancel http response headers
In each rule,
-
srclimit which request it will work on, and it has two types: wildcard and regexp, which is defined inkindkey. -
dstonly required in redirects, means destination -
enableturn on/off -
oprequired inrequest-headersresponse-headers, has two enum value:cancelormodify -
name,valuerequired inrequest-headersresponse-headers, means header name(case-insensitive), header value
In redirects, you can use $1 $2 ... to backreference captured groups in case of regexp kind. For example:
{
"src": "https://search.yahoo.com/search\?p=([a-z]+)",
"dst": "https://www.google.com/search?q=$1",
"kind": "regexp",
"enable": true
}
Then https://search.yahoo.com/search?p=gooreplacer will redirect to https://www.google.com/search?q=gooreplacer
If your rules don't work as expected, use sandbox to test, it can tell what's missing.
-
In order to be compatiable with old versions,
redirect-ruleskey in JSON-rules file can be justrulesand have following format:"rules": { "ajax.googleapis.com": { "dstURL": "ajax.proxy.ustclug.org", "enable": true, "kind": "wildcard" } } -
According to Google Extension document,headers below can't be modified:
- Authorization
- Cache-Control
- Connection
- Content-Length
- Host
- If-Modified-Since
- If-None-Match
- If-Range
- Partial-Data
- Pragma
- Proxy-Authorization
- Proxy-Connection
- Transfer-Encoding