├── .gitignore
├── .jshintrc
├── README.0.1.3.md
├── README.md
├── README_en.md
├── _locales
├── en
│ └── messages.json
└── zh
│ └── messages.json
├── background
├── default.js
├── index.js
└── upgrade.js
├── common
├── info.js
├── punycode.min.js
└── utils.js
├── manifest.json
├── options
├── controller.js
├── filter.js
├── icon.svg
├── index.css
├── index.html
├── index.js
└── lib
│ ├── angular.min.js
│ └── zepto.min.js
├── owl-redirector.crx
├── owl.png
├── owl.psd
├── zip.sh
└── 默认规则_备份文件.bac
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | owl-redirector
3 | owl-redirector.zip
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | // 2 空格缩进
3 | "indent": 2,
4 | "smarttabs": true,
5 |
6 | // 变量在使用前必须先声明
7 | "latedef": "nofunc",
8 | "undef": true,
9 | // "unused": true,
10 |
11 | // 行尾不要有空格
12 | "trailing": true,
13 |
14 | // 在行尾使用逗号,而非行首
15 | "laxcomma": false,
16 |
17 | // 语句块必须使用大括号包裹
18 | "curly": true,
19 |
20 | // 判断相等使用 ===,接受 `== null`
21 | "eqeqeq": true,
22 | "eqnull": true,
23 |
24 | // 不限制是否使用分号
25 | "asi": true,
26 |
27 | // 支持 `if (foo = bar) {}` 这样的写法
28 | "boss": true,
29 |
30 | // 支持 `options || (options = {})` 这样的写法
31 | "expr": true,
32 |
33 | // 同时支持 `hash['key']` 和 `hash.key`
34 | "sub": true,
35 |
36 | "evil": true,
37 | // 直接忽略 `parseInt()` 相关的警告
38 | // Refer to http://jslinterrors.com/missing-radix-parameter/
39 | "-W065": true,
40 | "browser": true,
41 | "node": true,
42 | "predef": [
43 | "chrome", "angular", "$", "console"
44 | ],
45 | "lastsemic": true,
46 | "nonbsp": true,
47 | "multistr": true
48 | }
49 |
--------------------------------------------------------------------------------
/README.0.1.3.md:
--------------------------------------------------------------------------------
1 | OWL
2 | ===
3 | Chrome 重定向工具
4 |
5 | [英文版即将翻译中](https://github.com/meowtec/Owl-redirector/blob/master/README_en.md)(作者英文渣)
6 | ### 安装
7 | - 如果你可以翻墙,建议直接访问 [Chrome Webstore](https://chrome.google.com/webstore/detail/beknllkoddklgoflifhgkhkkibgkpdch)
8 | - 如果你翻不了墙,可以下载 [owl-redirector.crx](https://github.com/meowtec/Owl-redirector/blob/master/owl-redirector.crx?raw=true),然后打开`扩展程序`页面,把`.crx`文件拖进去。
9 | - 如果前两种方法无效,请直接下载这个项目文件,再以开发者模式加载,网上很多教程,此处略。
10 |
11 | ### 使用
12 | #### 主界面
13 | 
14 |
15 | - 右上角是全局开关,启用状态为蓝色,禁用状态为灰色。
16 | - 左侧是规则列表,目前只有一条规则。如果规则被禁用,它的颜色会变淡。
17 | - 下面的三个图标分别是删除、编辑和禁用按钮。
18 |
19 | #### 编辑界面
20 | 
21 |
22 | - 第一个输入框输入替换前的 url 或者正则。右边的图标`[.*]`决定你输入的应该是一个普通 url (普通模式)还是一条正则表达式(正则模式),默认情况下应该输入普通的 url,此时图标是未选中的。
23 | - 普通模式下,只有当链接完全匹配时,url才会被重定向(或阻止)。
24 | - 正则模式下,如果浏览器访问的链接可以匹配你的正则,会被重定向。
25 |
26 | >
27 | - 由于链接中`.`等特殊字符比较多,银耳系统提供了 `url` 转正则的功能。即普通模式下输入一条 url,然后点`[.*]`切换到正则模式,此 url 会自动被转化为正则表达式。
28 | - 正则不需要加前后的斜杠。
29 |
30 | - 下面的大输入框中输入替换后的链接,右边有三个按钮,分别是 `普通链接`,`文本内容`,`函数`
31 | 1. `普通链接`:请求会被自动重定向到此链接。
32 | 2. `文本内容`:程序将这段文本编码为 dataURL,然后将请求重定向到 此 dataURL。适合需要修改外链`css`/`js`(含jsonp)的情况。由于 `ajax` 的跨域特性,此方式并不能修改 ajax 请求返回内容。
33 | 3. `函数`:在这里填入一个函数,函数参数为替换前的 url,函数返回值为替换后的 url。如果需要阻止请求,需要返回 `false`。
34 |
35 | ### 实例
36 | ##### jquery.min.js 去 `min`
37 | 我们以 `jQuery` 官网为例,为了节省流量,jQuery 官网使用的是压缩后的 `jQuery.min.js` 文件,我们添加一条规则,把`jquery.min.js`重定向到`jquery.js`:
38 | url:
39 | ```
40 | http://ajax.lug.ustc.edu.cn/ajax/libs/jquery/1.11.2/jquery.min.js
41 | ```
42 | replacer(url):
43 | ```
44 | http://ajax.lug.ustc.edu.cn/ajax/libs/jquery/1.11.2/jquery.js
45 | ```
46 |
47 | ##### fc.5sing 跳转
48 | 有一次我在网上找到一个翻唱链接,`http://fc.5sing.com/5936546.html`(这只是我临时找的,之前要找的早丢了),点进去发现访问不了。
49 |
50 | 原来是 5sing 被酷狗收购了,新的链接地址应该是 `http://5sing.kugou.com/fc/5936546.html`。
51 |
52 | 于是我添加了一条规则,让所有`fc.5sing.com`域名下的链接均能正常跳转到`5sing.kugou.com`域名。
53 |
54 | regexp:
55 | ```
56 | ^http:\/\/fc\.5sing\.com\/(\d+)\.html.*$
57 | ```
58 | replacer(函数):
59 | ```
60 | function (url){
61 | var matchResult = url.match(/^http:\/\/fc\.5sing\.com\/(\d+)\.html.*$/)
62 | return 'http://5sing.kugou.com/fc/' + matchResult[1] + '.html'
63 | }
64 | ```
65 | 
66 |
67 |
68 | #### google web fonts 替换为 ustc.edu.cn
69 |
70 | regexp:
71 | ```
72 | ^https?:\/\/(((ajax|fonts)\.googleapis\.com)|(themes\.googleusercontent\.com)|(fonts\.gstatic\.com))
73 | ```
74 | replacer(函数):
75 | ```
76 | function (url){
77 | return url.replace('googleapis.com', 'lug.ustc.edu.cn')
78 | .replace('themes.googleusercontent.com', 'google-themes.lug.ustc.edu.cn')
79 | .replace('fonts.gstatic.com', 'fonts-gstatic.lug.ustc.edu.cn')
80 | }
81 | ```
82 |
83 |
84 |
85 | #### 干掉谷歌统计:
86 |
87 | url:
88 | ```
89 | http://www.google-analytics.com/analytics.js
90 | ```
91 | replacer(url):置空
92 |
93 |
94 | ### 内置方法
95 | - download()
96 |
97 | 你可以在 replacer 函数中调用 download 方法,对资源进行下载操作,下面的实例表示在`music.qq.com`试听音乐时自动下载音频文件:
98 |
99 |
100 | regexp:
101 | ```
102 | ^http:\/\/cc\.stream\.qqmusic\.qq\.com\/.*\.m4a.*$
103 | ```
104 | replacer(函数):
105 | ```
106 | function (url){
107 | // 如果函数返回值为 undefined 则不会重定向
108 | download(url)
109 | }
110 | ```
111 |
112 | ### 导出和导入
113 | 设置页面有`导出`和`导入`两个按钮,分别可以讲当前设置导出为`.bac`格式的文本文件,以及从`.bac`文件导入备份的设置。
114 |
115 | #### 项目路径下有一个`示例备份`,里面包含本文档中的例子,你可以删掉或者关闭不需要的。
116 |
117 | **请不要随便导入未知文件,切记**
118 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | OWL
2 | ===
3 | Chrome 重定向工具
4 |
5 | ### 安装
6 | - 如果你可以翻墙,建议直接访问 [Chrome Webstore](https://chrome.google.com/webstore/detail/beknllkoddklgoflifhgkhkkibgkpdch)
7 | - 如果你翻不了墙,可以下载 [owl-redirector.crx](https://github.com/meowtec/Owl-redirector/blob/master/owl-redirector.crx?raw=true),然后打开`扩展程序`页面,把`.crx`文件拖进去。
8 | - 如果前两种方法无效,请直接下载这个项目文件,然后以开发者模式加载,网上很多教程,此处略。
9 |
10 | ### 内置规则
11 | 扩展重新内置了几条规则,他们的功能包括:
12 | - 屏蔽 Google 分析、CNZZ 等。由于众所周知的原因,Google 分析会造成网页加载很慢。
13 | - Google 字体等 cdn 自动重定向到国内镜像。
14 | - Google 搜索结果直接跳转到第三方网页,加快速度。
15 |
16 | 也你可以根据你自己的需求任意添加。
17 |
18 | ### 使用方法
19 | [Issue8: 如何添加规则?](https://github.com/meowtec/Owl-redirector/issues/8)
20 |
21 | ### 使用图解
22 | #### 主界面
23 | 
24 |
25 | - 右上角是全局开关,启用状态为蓝色,禁用状态为灰色。
26 | - 左侧是规则列表,目前只有一条规则。如果规则被禁用,它的颜色会变淡。
27 | - 下面的三个图标分别是删除、编辑和禁用按钮。
28 |
29 | #### 编辑界面
30 | 
31 |
32 | - 第一个输入框,输入你需要 redirect 或者阻止的 url,如果你需要屏蔽一组特定格式的 url,可以输入正则或者 URL Match。
33 | - 右侧的`[.*]`按钮可以把你输入的字符串转化为恒等的正则表达式,url 中通常有很多特殊字符,使用这个按钮可以快速转义它们。
34 | - 第二个输入框中输入的内容以右侧 CheckBox 选中的模式为准,三种模式分别是 `普通链接`,`文本内容`,`函数`:
35 | 1. `普通链接`:请求会被自动重定向到此链接。
36 | 2. `文本内容`:程序将这段文本编码为 dataURL,然后将请求重定向到此 dataURL。适合需要修改外链`css`/`js`(含jsonp)的情况。由于 `ajax` 的跨域特性,此方式并不能修改 ajax 请求返回内容。
37 | 3. `函数`:在这里填入一个函数,函数参数为替换前的 url,函数返回值为替换后的 url。如果需要阻止请求,需要返回 `false`。
38 |
39 | #### 函数返回值
40 | - 如果返回普通字符串,程序认为它是一个链接,则请求被重定向到这个链接;
41 | - 如果返回 false,请求会被阻止;
42 | - 如果返回 undefined/null,或者返回原 url,直接请求。
43 |
44 | 关于如何添加规则,也可以看 [Issue #8](https://github.com/meowtec/Owl-redirector/issues/8)。
45 |
46 | ### 实例
47 |
48 | ##### jquery.min.js 去 `min`
49 | 我们以 `jQuery` 官网为例,为了节省流量,jQuery 官网使用的是压缩后的 `jQuery.min.js` 文件,我们添加一条规则,把`jquery.min.js`重定向到`jquery.js`:
50 | url:
51 | ```
52 | http://ajax.lug.ustc.edu.cn/ajax/libs/jquery/1.11.2/jquery.min.js
53 | ```
54 | replacer(url):
55 | ```
56 | http://ajax.lug.ustc.edu.cn/ajax/libs/jquery/1.11.2/jquery.js
57 | ```
58 |
59 | ##### fc.5sing 跳转
60 | 5sing 被酷狗收购后,域名由 `5sing.com` 变成 `5sing.kugou.com`, 但是跳转没做好,于是 `http://fc.5sing.com/5936546.html` 无法正确跳转到 `http://5sing.kugou.com/fc/5936546.html`。
61 |
62 | 于是我添加了一条规则,让所有`fc.5sing.com`域名下的链接均能正常跳转到`5sing.kugou.com`域名。
63 |
64 | url:
65 | ```
66 | http://fc.5sing.com/*
67 | ```
68 | replacer(函数):
69 | ```
70 | url => {
71 | var matchResult = url.match(/^http:\/\/fc\.5sing\.com\/(\d+)\.html.*$/)
72 | return 'http://5sing.kugou.com/fc/' + matchResult[1] + '.html'
73 | }
74 | ```
75 |
76 | #### google web fonts 替换为 ustc.edu.cn
77 | url:
78 | ```
79 | /^https?:\/\/(((ajax|fonts)\.googleapis\.com)|(themes\.googleusercontent\.com)|(fonts\.gstatic\.com))/
80 | ```
81 | replacer(函数):
82 | ```
83 | url => url.replace('googleapis.com', 'lug.ustc.edu.cn')
84 | .replace('themes.googleusercontent.com', 'google-themes.lug.ustc.edu.cn')
85 | .replace('fonts.gstatic.com', 'fonts-gstatic.lug.ustc.edu.cn')
86 | ```
87 |
88 | #### 干掉谷歌统计:
89 |
90 | url:
91 | ```
92 | http://www.google-analytics.com/analytics.js
93 | ```
94 | replacer(url): 置空
95 |
96 |
97 | ### 内置方法
98 | - download()
99 |
100 | 你可以在 replacer 函数中调用 download 方法,对资源进行下载操作,下面的实例表示在`music.qq.com`试听音乐时自动下载音频文件:
101 |
102 |
103 | url:
104 | ```
105 | http://*.stream.qqmusic.qq.com/*.m4a*
106 | ```
107 | replacer(函数):
108 | ```
109 | url => download(url)
110 | // 或者只需要一个 download
111 | download
112 | ```
113 |
114 | ### 导出和导入
115 | 设置页面有`导出`和`导入`两个按钮,分别可以将当前设置导出为`.bac`格式的文本文件、从`.bac`文件导入备份的设置。
116 |
117 | **!!! 请不要随便导入未知文件,切记 !!!**
118 |
119 | ## 意见反馈
120 | 如果发现 Bug,或者对产品有其他建议,可以[新建 Issue](https://github.com/meowtec/Owl-redirector/issues/new)。
121 |
--------------------------------------------------------------------------------
/README_en.md:
--------------------------------------------------------------------------------
1 | OWL
2 | ===
3 | Chrome 重定向工具
4 |
5 | ### 安装
6 | - 如果你可以翻墙,建议直接访问 [Chrome Webstore](https://chrome.google.com/webstore/detail/beknllkoddklgoflifhgkhkkibgkpdch)
7 | - 如果你翻不了墙,可以下载 [owl-redirector.crx](https://github.com/meowtec/Owl-redirector/blob/master/owl-redirector.crx?raw=true),然后打开`扩展程序`页面,把`.crx`文件拖进去。
8 | - 如果前两种方法无效,请直接下载这个项目文件,再以开发者模式加载,网上很多教程,此处略。
9 |
10 | ### 使用
11 | #### 主界面
12 | 
13 |
14 | - 右上角是全局开关,启用状态为蓝色,禁用状态为灰色。
15 | - 左侧是规则列表,目前只有一条规则。如果规则被禁用,它的颜色会变淡。
16 | - 下面的三个图标分别是删除、编辑和禁用按钮。
17 |
18 | #### 编辑界面
19 | 
20 |
21 | - 第一个输入框输入替换前的 url 或者正则。右边的图标`[.*]`决定你输入的应该是一个普通 url (普通模式)还是一条正则表达式(正则模式),默认情况下应该输入普通的 url,此时图标是未选中的。
22 | - 普通模式下,只有当链接完全匹配时,url才会被重定向(或阻止)。
23 | - 正则模式下,如果浏览器访问的链接可以匹配你的正则,会被重定向。
24 |
25 | >
26 | - 由于链接中`.`等特殊字符比较多,银耳系统提供了 `url` 转正则的功能。即普通模式下输入一条 url,然后点`[.*]`切换到正则模式,此 url 会自动被转化为正则表达式。
27 | - 正则不需要加前后的斜杠。
28 |
29 | - 下面的大输入框中输入替换后的链接,右边有三个按钮,分别是 `普通链接`,`文本内容`,`函数`
30 | 1. `普通链接`:请求会被自动重定向到此链接。
31 | 2. `文本内容`:程序将这段文本编码为 dataURL,然后将请求重定向到 此 dataURL。适合需要修改外链`css`/`js`(含jsonp)的情况。由于 `ajax` 的跨域特性,此方式并不能修改 ajax 请求返回内容。
32 | 3. `函数`:在这里填入一个函数,函数参数为替换前的 url,函数返回值为替换后的 url。如果需要阻止请求,需要返回 `false`。
33 |
34 | ### 实例
35 | ##### jquery.min.js 去 `min`
36 | 我们以 `jQuery` 官网为例,为了节省流量,jQuery 官网使用的是压缩后的 `jQuery.min.js` 文件,我们添加一条规则,把`jquery.min.js`重定向到`jquery.js`:
37 | url:
38 | ```
39 | http://ajax.lug.ustc.edu.cn/ajax/libs/jquery/1.11.2/jquery.min.js
40 | ```
41 | replacer(url):
42 | ```
43 | http://ajax.lug.ustc.edu.cn/ajax/libs/jquery/1.11.2/jquery.js
44 | ```
45 |
46 | ##### fc.5sing 跳转
47 | 有一次我在网上找到一个翻唱链接,`http://fc.5sing.com/5936546.html`(这只是我临时找的,之前要找的早丢了),点进去发现访问不了。
48 | 原来是 5sing 被酷狗收购了,新的链接地址应该是 `http://5sing.kugou.com/fc/5936546.html`。
49 | 于是我添加了一条规则,让所有`fc.5sing.com`域名下的链接均能正常跳转到`5sing.kugou.com`域名。
50 |
51 | regexp:
52 | ```
53 | ^http:\/\/fc\.5sing\.com\/(\d+)\.html.*$
54 | ```
55 | replacer(函数):
56 | ```
57 | function (url){
58 | var matchResult = url.match(/^http:\/\/fc\.5sing\.com\/(\d+)\.html.*$/)
59 | return 'http://5sing.kugou.com/fc/' + matchResult[1] + '.html'
60 | }
61 | ```
62 | 
63 |
64 |
65 | #### google web fonts 替换为 ustc.edu.cn
66 |
67 | regexp:
68 | ```
69 | ^https?:\/\/(((ajax|fonts)\.googleapis\.com)|(themes\.googleusercontent\.com)|(fonts\.gstatic\.com))
70 | ```
71 | replacer(函数):
72 | ```
73 | function (url){
74 | return url.replace('googleapis.com', 'lug.ustc.edu.cn')
75 | .replace('themes.googleusercontent.com', 'google-themes.lug.ustc.edu.cn')
76 | .replace('fonts.gstatic.com', 'fonts-gstatic.lug.ustc.edu.cn')
77 | }
78 | ```
79 |
80 |
81 |
82 | #### 干掉谷歌统计:
83 |
84 | url:
85 | ```
86 | http://www.google-analytics.com/analytics.js
87 | ```
88 | replacer(url):置空
89 |
90 |
91 | ### 内置方法
92 | - download()
93 |
94 | 你可以在 replacer 函数中调用 download 方法,对资源进行下载操作,下面的实例表示在`music.qq.com`试听音乐时自动下载音频文件:
95 |
96 |
97 | regexp:
98 | ```
99 | ^http:\/\/cc\.stream\.qqmusic\.qq\.com\/.*\.m4a.*$
100 | ```
101 | replacer(函数):
102 | ```
103 | function (url){
104 | // 如果函数返回值为 undefined 则不会重定向
105 | download(url)
106 | }
107 | ```
108 |
109 | ### 导出和导入
110 | 设置页面有`导出`和`导入`两个按钮,分别可以讲当前设置导出为`.bac`格式的文本文件,以及从`.bac`文件导入备份的设置。
111 |
112 | 项目路径下有一个`示例备份`,里面包含本文档中的例子。
113 |
114 | **请不要随便导入未知文件,切记**
--------------------------------------------------------------------------------
/_locales/en/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "settingTitle": {
3 | "message": "Setting"
4 | },
5 | "helpTitle": {
6 | "message": "Help"
7 | },
8 | "aboutTitle": {
9 | "message": "About"
10 | },
11 | "ruleListTitle": {
12 | "message": "Rules List"
13 | },
14 | "textareaPlaceholder_url": {
15 | "message": "An URL, then the request will be redirected to the URL. If this box was leave empty, the request would be blocked."
16 | },
17 | "textareaPlaceholder_function": {
18 | "message": "A function receiving the origin url as the first argument, and it should return an new URL. e.g.:\n\nurl => url+'#myhash'\n}"
19 | },
20 | "textareaPlaceholder_data": {
21 | "message": "A piece of data, which will be encoded to a Data-URL, then the request will be redirected to the Data-URL.\nYou can use it to modify your css or js imported with or
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | -
25 |
26 |
27 | -
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
43 |
44 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
74 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
{{messages.version}}
122 |
{{version}}
123 |
{{messages.homePage}}
124 |
github.com/meowtec/Owl-redirector
125 |
{{messages.author}}
126 |
黑猫
127 |
使用如下开源软件
128 |
129 | Zepto,
130 | Angularjs,
131 | icomoon,
132 | Punycode.js
133 |
134 |
135 |
136 |
137 |
138 |
139 |