diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 00000000..88bbf599
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,16 @@
+{
+ "env": {
+ "browser": true,
+ "webextensions": true,
+ "node": true,
+ "es2021": true
+ },
+ "extends": [
+ "eslint:recommended"
+ ],
+ "parserOptions": {
+ "ecmaVersion": "latest",
+ "sourceType": "module"
+ },
+ "rules": {}
+}
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 07738032..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-sudo: false
-language: node_js
-node_js:
- - "4"
- - "5"
-script:
- - npm run test
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 8ecdb9fe..00000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,51 +0,0 @@
-# 如何向 Unblock Youku 开源项目做出贡献?
-
-非常感谢您的兴趣和支持!只有大家的支持和贡献才能使 Unblock Youku 项目长久地免费稳定地服务海外千千万万的朋友们。
-
-这个页面包含一些在技术上给 Unblock Youku 贡献的办法。也欢迎捐款来支持我们服务器的开销,[捐款请前往 Unblock Youku 主页 ](https://www.uku.im/index_zhs.html)。
-
-### 我在使用 Unblock Youku 时遇到了问题
-
-如果在使用 Unblock Youku 时发现问题(例如在某些网站上不能正常工作),欢迎来向我们寻求帮助。及时的信息反馈也能帮更多的朋友解决类似的问题。
-
-1. [首先查看我们的常见问题解答 FAQ](https://uku.im/faq),看问题是否能用 FAQ 里提到的方法解决。
-2. [如果 FAQ 的方法没能解决您的问题,欢迎去我们的论坛进行反馈](https://uku.im/feedback)。反馈前请查看最近有没有别人遇到了类似的问题,以及他们的解决办法是什么。反馈时请尽量详细地按照模板填写信息(例如遇到问题的网址、使用的软件、还有您所在的地区),更多的信息才能让我们更及时的帮您解决问题。
-
-### 我想提出新的功能或改进
-
-欢迎为我们的开源项目提出意见和改进的办法,我们的开源项目的前进离不开你的帮助。
-
-建议或意见可以 [提交至 GitHub](https://github.com/Unblocker/Unblock-Youku/issues) 或 [直接向我发邮件](https://zhuzhu.org/)。
-
-### 我想利用我的技术特长来提供帮助
-
-程序员拯救世界!:smile:
-
-让我们的技术能第一时间服务到千千万万的海外友人,是一件非常有成就感的事情!参加开源项目的开发和维护也是一个锻炼和展现自己技术实力的机会。
-
-##### 帮助用户解决问题,第一时间获取用户反馈
-
-[我们的论坛](https://uku.im/feedback)经常会收到各种各样的用户反馈,常见的例如 Unblock Youku 在某个网站上突然失效。时常阅读这些用户反馈使我们能及时了解用户需求并解决问题。
-
-1. 如果用户提供的信息不全,可以尝试询问更多的信息。
-2. 测试用户提供的信息,例如测试用户提供的视频网址,看能否重现用户所述的问题。
- * 如果问题不能重现:可以给用户提供简单的解决方法,例如 [FAQ](https://uku.im/faq) 中的办法,看能不能解决问题。
- * 如果问题可以重现:请帮忙在 GitHub 上创建个 issue 从技术角度重述此问题,也方便在 GitHub 管理和追踪问题。
-
-##### 帮助修复问题,添加新的功能和改进
-
-可以关注 [我们的 GitHub Issue 列表](https://github.com/Unblocker/Unblock-Youku/issues),查看现有的尚待解决的问题。也欢迎提出新的想法来改进我们的开源项目。
-
-整个 Unblock Youku 的项目主要有下面几个组成部分:
-
-1. Chrome extension: 由 JavaScript 写成,代码主要在 `chrome/` 和 `shared/` 两个文件夹下
-2. 普通模式的代理服务器:这个是运行开源的 Squid 系统,我们只需改动配置文件。具体的配置和安装可见 [Wiki 页面](https://uku.im/squid)
-3. 转发模式的服务器程序:由 JavaScript/Node.js 写成,代码主要在 `server/` 和 `shared/` 两个文件夹下
-
-(更加详细的项目结构描述正在准备中...)
-
-##### Chrome extension 开发的技术知识准备
-
-虽说我们的开源项目主要由 JavaScript 写成,但是只需要非常简单的 JavaScript 知识。如果之前没有 JavaScript 经验但是想学习,推荐 [JavaScript: The Good Parts](http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742/),书很薄只有 176 页。
-
-Chrome extension 的开发可以阅读 [Google 官方的开发教程](https://developer.chrome.com/extensions)。只需要在 Chrome 里打开 `chrome://extensions`页面勾选上 `Developer mode`,就可以手动加载 Unblock Youku 的源码进行开发。
diff --git a/chrome/config.js b/chrome/config.js
index de881e1a..968df776 100644
--- a/chrome/config.js
+++ b/chrome/config.js
@@ -15,10 +15,8 @@
* along with this program. If not, see .
*/
-/*jslint browser: true */
-/*global chrome: false, get_storage: false, set_storage: false, new_random_ip: false */
-/*global setup_redirect: false, setup_header: false, setup_proxy: false, setup_timezone: false, setup_extra_header: false */
-/*global clear_redirect: false, clear_header: false, clear_proxy: false, clear_timezone: false */
+/*global setup_redirect: false, setup_header: false, setup_proxy: false */
+/*global clear_redirect: false, clear_header: false, clear_proxy: false */
/*global ga_report_event: false, ga_report_ratio: false, ga_report_error: false */
"use strict";
@@ -276,6 +274,4 @@ document.addEventListener("DOMContentLoaded", function() {
ga_report_ratio('Init Mode', current_mode_name);
ga_report_ratio('Version', unblock_youku.version);
});
-
- // setup_extra_redirector();
});
diff --git a/chrome/donation.js b/chrome/donation.js
index b2aa3d6b..aa16dd5d 100644
--- a/chrome/donation.js
+++ b/chrome/donation.js
@@ -15,14 +15,13 @@
* along with this program. If not, see .
*/
-/*global chrome: false, localStorage: false */
-"use strict";
+'use strict';
function create_donation_tab() {
- var donation_url = chrome.i18n.getMessage('donation_url');
+ const donation_url = chrome.i18n.getMessage('donation_url');
chrome.tabs.create({
- url: donation_url
+ url: donation_url,
});
}
@@ -30,4 +29,4 @@ chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason === 'install') {
create_donation_tab();
}
-});
\ No newline at end of file
+});
diff --git a/chrome/header.js b/chrome/header.js
index 55796cc2..b42cb588 100644
--- a/chrome/header.js
+++ b/chrome/header.js
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*/
-/*global chrome: false, unblock_youku: false */
+/*global unblock_youku: false */
/*global ga_report_error: false */
"use strict";
diff --git a/chrome/redirect.js b/chrome/redirect.js
index 5471deec..1ee51201 100644
--- a/chrome/redirect.js
+++ b/chrome/redirect.js
@@ -36,15 +36,6 @@ function http_redirector(details) {
return {redirectUrl: redirect_url};
}
- // if (details.url.slice(0, 18) === 'http://v.youku.com') {
- // // remove random number to improve cache hitrate
- // details.url = details.url.replace(/&ran=[0-9]*|ran=[0-9]*&/gi, '');
- // } else if (details.url.slice(0, 23) === 'http://hot.vrs.sohu.com') {
- // details.url = details.url.replace(/&t=0\.[0-9]*|t=0\.[0-9]*&/gi, '');
- // } else if (details.url.slice(0, 23) === 'http://hot.vrs.letv.com') {
- // details.url = details.url.replace(/&tn=0\.[0-9]*|tn=0\.[0-9]*&/gi, '');
- // }
-
var backend_server;
if (typeof localStorage.custom_redirect_server === 'undefined') {
backend_server = unblock_youku.actual_redirect_server;
@@ -52,7 +43,6 @@ function http_redirector(details) {
backend_server = localStorage.custom_redirect_server;
}
- //var redirect_url = 'http://127.0.0.1.xip.io:8080/?url=' + urlsafe_b64encode(details.url);
if (string_starts_with(details.url, 'http://')) {
redirect_url = 'http://' + backend_server + '/http/' + details.url.substring('http://'.length);
} else if (string_starts_with(details.url, 'https://')) {
@@ -138,31 +128,3 @@ function clear_redirect() {
ga_report_error('Unexpected Error', err_msg);
}
}
-
-
-// extra sites to redirect
-/*
-function extra_http_redirector(details) {
- var redirect_url = 'http://117.27.241.117/' + details.url.replace(/^.*\/\/[^\/]+/, '');
- console.log('redirect url: ' + redirect_url);
- return {redirectUrl: redirect_url};
-}
-
-function setup_extra_redirector() {
- if (!chrome.webRequest.onBeforeRequest.hasListener(extra_http_redirector)) {
- chrome.webRequest.onBeforeRequest.addListener(
- extra_http_redirector,
- {
- urls: ['http://*.music.126.net/*']
- },
- ["blocking"]
- );
- console.log('extra_http_redirector is set');
- } else {
- var err_msg = 'extra_http_redirector is already there!';
- console.error(err_msg);
- ga_report_error('Unexpected Error', err_msg);
- }
-}
-*/
-
diff --git a/package.json b/package.json
index 53e52eb9..258e8058 100644
--- a/package.json
+++ b/package.json
@@ -1,18 +1,15 @@
{
"name": "ub.uku.js",
- "version": "2.0.0",
+ "version": "0.0.1",
"dependencies": {
"colors": "*",
"nomnom": "1.8.x",
"request": "2.83.x",
- "validator": "9.1.x",
- "uglify-js": "2.7.x"
+ "uglify-js": "2.7.x",
+ "validator": "9.1.x"
},
"scripts": {
- "start": "node server/server.js",
- "test": "python test/run-all-tests.py",
- "test:unit": "_mocha unit_test/**/*-tests.js -r babel-core/register",
- "test:unit:watch": "npm run test:unit -- --watch"
+ "start": "node server/server.js"
},
"engines": {
"node": "8.9.x",
@@ -24,12 +21,6 @@
},
"license": "AGPL-3.0",
"devDependencies": {
- "babel-core": "^6.26.0",
- "babel-preset-es2015": "^6.3.13",
- "chai": "^3.5.0",
- "eslint": "^2.4.0",
- "eslint-config-airbnb": "^6.2.0",
- "eslint-plugin-react": "^4.2.3",
- "mocha": "^2.4.5"
+ "eslint": "^8.18.0"
}
}
diff --git a/test/run-all-tests.py b/test/run-all-tests.py
deleted file mode 100755
index bb011c43..00000000
--- a/test/run-all-tests.py
+++ /dev/null
@@ -1,165 +0,0 @@
-#!/usr/bin/env python
-
-"""
- Allow you smoothly surf on many websites blocking non-mainland visitors.
- Copyright (C) 2012 - 2016 Bo Zhu http://zhuzhu.org
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-"""
-
-import subprocess
-import time
-import sys
-import os
-
-# http://goo.gl/2wtRL
-# os.chdir(os.path.dirname(sys.argv[0]))
-if os.path.dirname(sys.argv[0]) != '':
- os.chdir(os.path.dirname(sys.argv[0]))
-
-print 'PhantomJS',
-try:
- version = subprocess.check_output(['phantomjs', '--version'])
- print version
- sys.stdout.flush()
-except Exception as exp:
- print 'is not installed.'
- print 'Please install it and try again.'
- sys.stdout.flush()
- sys.exit(-1)
-
-
-server_process = None
-
-
-def start_server():
- global server_process
- print 'To start the server, and wait for 3 seconds to set up...'
- sys.stdout.flush()
- test_env = os.environ.copy()
- test_env['PROXY_ADDR'] = 'https://secure.uku.im:993'
- test_env['BAK_PROXY_ADDR'] = 'http://proxy.uku.im:443'
- test_env['PAC_PROXY_ADDR'] = 'http://proxy.uku.im:443'
- server_process = subprocess.Popen(
- ['node', '../server/server.js'],
- env=test_env)
- time.sleep(3)
-
-def wait_server_open(server, port, timeout):
- import socket
- import errno
- from time import time as now
-
- # ending time for time out
- end = now() + timeout
-
- while True:
- s = socket.socket()
- try:
- next_timeout = end - now() # check for timeout
- if next_timeout < 0:
- return False
-
- s.connect((server, port))
- except socket.error, err:
- # if connection failed, try again
- s.close()
- continue
- else:
- s.close()
- return True
-
-def stop_server():
- time.sleep(1)
- print 'To stop the server...',
- sys.stdout.flush()
- server_process.terminate()
- server_process.wait()
- print 'done.'
- sys.stdout.flush()
-
-
-# http://goo.gl/xaBer
-def red_alert(text):
- print "\033[7;31m" + text + "\033[0m"
- sys.stdout.flush()
-
-
-def run_all_tests():
- print
- print 'To run all test-*.js files...'
- sys.stdout.flush()
- num_failed = 0
- num_passed = 0
- for file_name in os.listdir('.'):
- if (file_name.startswith('test-') or file_name.startswith('check-')) \
- and file_name.endswith('.js'):
- if (file_name.startswith('test-')):
- command = ['phantomjs', file_name]
- else:
- command = ['node', file_name]
- print
- print ' '.join(command)
- sys.stdout.flush()
- return_value = subprocess.call(command)
- time.sleep(2) # sleep 2 seconds between tests
- if return_value != 0:
- num_failed += 1
- red_alert(file_name + ' FAILED!')
- else:
- num_passed += 1
- print file_name + ' passed.'
- sys.stdout.flush()
- print
- sys.stdout.flush()
- if num_failed > 0:
- red_alert('Final results: ' + str(num_failed) + ' TESTS FAILED'
- + ' (out of ' + str(num_failed + num_passed) + ')')
- else:
- print 'All %d tests passed.' % (num_passed + num_failed)
- print
- sys.stdout.flush()
- return num_failed
-
-
-def extra_checks():
- with open('../chrome/proxy.js', 'r') as f:
- for line in f:
- line = line.lower().strip()
- if ('proxy_server' in line and '127.0.0.1' in line) or \
- ('proxy_server' in line and 'socks' in line):
- if not line.startswith('//'):
- red_alert('The debug server is still in use!')
- return False
- return True
-
-
-def main():
- if not extra_checks():
- sys.exit(-2)
-
- exit_code = -1
- try:
- start_server()
- if (wait_server_open('127.0.0.1', 8888, 20)): # time out in 20s
- exit_code = run_all_tests()
- else:
- red_alert('Error open connection')
- finally:
- stop_server()
- sys.exit(exit_code)
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/run-selenium.py b/test/run-selenium.py
deleted file mode 100755
index bda8469b..00000000
--- a/test/run-selenium.py
+++ /dev/null
@@ -1,82 +0,0 @@
-import os
-import sys
-import json
-import time
-from selenium import webdriver
-from selenium.webdriver.chrome.options import Options
-
-if os.path.dirname(sys.argv[0]) != '':
- os.chdir(os.path.dirname(sys.argv[0]))
-
-
-driver = None
-
-
-def start_up():
- global driver
- chrome_options = Options()
- chrome_options.add_argument('load-extension=../')
- print 'Opening a Chrome browser'
- driver = webdriver.Chrome(chrome_options=chrome_options)
- time.sleep(1)
-
-
-def clean_up():
- global driver
- time.sleep(1)
- if driver is not None:
- print 'Closing the Chrome browser'
- driver.quit()
- driver = None
-
-
-def run_tests():
- num_fails = 0
-
- print 'Testing ipservice.163.com...',
- driver.get('http://ipservice.163.com/isFromMainland')
- flag = driver.find_elements_by_tag_name('pre').pop().text
- if flag != u'true':
- print 'Failed! Return value is not true'
- num_fails += 1
- else:
- print 'OK'
-
- time.sleep(1)
- print 'Testing httpbin.org...',
- driver.get('http://httpbin.org/ip')
- ip_json = driver.find_elements_by_tag_name('pre').pop().text
- ip = json.loads(ip_json)['origin']
- time.sleep(1)
- driver.get('http://www.geoplugin.net/json.gp?ip=' + ip)
- geo_json = driver.find_elements_by_tag_name('pre').pop().text
- country_code = json.loads(geo_json)['geoplugin_countryCode']
- if country_code == 'CN':
- print 'Failed! Access to httpbin.org should not be through proxies'
- num_fails += 1
- elif country_code == '':
- print 'Unknown. Country code is unavailable'
- else:
- print 'OK'
-
- return num_fails
-
-
-def main():
- try:
- start_up()
- num_failures = run_tests()
- if num_failures == 0:
- print 'All tests passed'
- else:
- print 'ATTENTION: %d test(s) failed' % num_failures
- clean_up()
- return num_failures
- except Exception as err:
- print 'Got exception:', err
- clean_up()
- return -1
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/test/test-crossdomain-xml.js b/test/test-crossdomain-xml.js
deleted file mode 100644
index c4aac68d..00000000
--- a/test/test-crossdomain-xml.js
+++ /dev/null
@@ -1,18 +0,0 @@
-var page = require('webpage').create();
-
-var test_url = 'http://127.0.0.1:8888/crossdomain.xml';
-
-page.open(test_url, function(status) {
- if (status !== 'success') {
- console.error('Failed in downloading crossdomain.xml...');
- phantom.exit(1);
- } else {
- var expected = '';
- if (page.content.indexOf(expected) == -1) {
- console.error("crossdomain.xml file isn't correct!");
- phantom.exit(2);
- } else {
- phantom.exit(0);
- }
- }
-});
diff --git a/test/test-google-2.js b/test/test-google-2.js
deleted file mode 100644
index a842f729..00000000
--- a/test/test-google-2.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var page = require('webpage').create();
-
-var test_url = 'http://127.0.0.1:8888/proxy/https/google.com';
-
-page.open(test_url, function(status) {
- if (status !== 'success') {
- phantom.exit(0);
- } else {
- console.error('Access control went wrong!');
- phantom.exit(1);
- }
-});
diff --git a/test/test-google.js b/test/test-google.js
deleted file mode 100644
index 740f5eaf..00000000
--- a/test/test-google.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var page = require('webpage').create();
-
-var test_url = 'http://127.0.0.1:8888/proxy.php?url=' + btoa('http://google.com');
-
-page.open(test_url, function(status) {
- if (status !== 'success') {
- phantom.exit(0);
- } else {
- console.error('Access control went wrong!');
- phantom.exit(1);
- }
-});
diff --git a/test/test-localhost-2.js b/test/test-localhost-2.js
deleted file mode 100644
index 4e9deaeb..00000000
--- a/test/test-localhost-2.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var page = require('webpage').create();
-
-var test_url = 'http://127.0.0.1:8888/proxy/http/127.0.0.1:8888/status';
-
-page.open(test_url, function(status) {
- if (status !== 'success') {
- phantom.exit(0);
- } else {
- console.error('Target parser went wrong!');
- phantom.exit(1);
- }
-});
diff --git a/test/test-localhost.js b/test/test-localhost.js
deleted file mode 100644
index 358d9b6f..00000000
--- a/test/test-localhost.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var page = require('webpage').create();
-
-var test_url = 'http://127.0.0.1:8888/proxy.php?url=' + btoa('http://127.0.0.1');
-
-page.open(test_url, function(status) {
- if (status !== 'success') {
- phantom.exit(0);
- } else {
- console.error('Target parser went wrong!');
- phantom.exit(1);
- }
-});
diff --git a/test/test-proxy-pac.js b/test/test-proxy-pac.js
deleted file mode 100644
index db7b189d..00000000
--- a/test/test-proxy-pac.js
+++ /dev/null
@@ -1,19 +0,0 @@
-var page = require('webpage').create();
-
-var test_url = 'http://127.0.0.1:8888/pac.pac';
-
-page.open(test_url, function(status) {
- if (status !== 'success') {
- console.error('Failed in opening page...');
- phantom.exit(1);
- } else {
- // console.log(page.content);
- if (page.content.indexOf('FindProxyForURL') === -1 ||
- page.content.indexOf('youku.com') === -1) {
- console.error("PAC file is invalid...");
- phantom.exit(2);
- } else {
- phantom.exit(0);
- }
- }
-});
diff --git a/test/test-status-page.js b/test/test-status-page.js
deleted file mode 100644
index 41a27c77..00000000
--- a/test/test-status-page.js
+++ /dev/null
@@ -1,17 +0,0 @@
-var page = require('webpage').create();
-
-var test_url = 'http://127.0.0.1:8888/status';
-
-page.open(test_url, function(status) {
- if (status !== 'success') {
- console.error('Failed in opening page...');
- phantom.exit(1);
- } else {
- if (page.content.indexOf('OK') === -1) {
- console.error("Status page didn't work well...");
- phantom.exit(2);
- } else {
- phantom.exit(0);
- }
- }
-});