diff --git a/.eslintrc.json b/.eslintrc.json index 88bbf599..b211b9d3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,6 +3,7 @@ "browser": true, "webextensions": true, "node": true, + "jquery": true, "es2021": true }, "extends": [ diff --git a/_locales/en/messages.json b/_locales/en/messages.json index eff02c3e..4e7e82cf 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -45,12 +45,12 @@ "message": "https://www.uku.im/index.html" }, "support_title": { - "message": "We Need Your Support" + "message": "We Need Your Donation" }, "support_message": { - "message": "Please support us to make Unblock Youku better." + "message": "Please donate to us to make Unblock Youku more usable." }, "support_button": { - "message": " Please Support Us" + "message": " Donate to us " } } diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index fa980573..b544ca59 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -45,12 +45,12 @@ "message": "https://www.uku.im/index.html" }, "support_title": { - "message": "我们需要您的支持" + "message": "我们需要您的捐款" }, "support_message": { "message": "请帮助 Unblock Youku 长久稳定和免费地运行下去" }, "support_button": { - "message": " 请支持我们" + "message": " 向我们捐款 " } } diff --git a/_locales/zh_TW/messages.json b/_locales/zh_TW/messages.json index 0c4bf0e1..6df8163a 100644 --- a/_locales/zh_TW/messages.json +++ b/_locales/zh_TW/messages.json @@ -45,12 +45,12 @@ "message": "https://www.uku.im/index_zht.html" }, "support_title": { - "message": "我們需要您的支持" + "message": "我們需要您的捐款" }, "support_message": { "message": "請幫助 Unblock Youku 長久穩定和免費地運行下去" }, "support_button": { - "message": " 請支持我們" + "message": " 向我們捐款 " } } diff --git a/chrome/config.js b/chrome/config.js index 968df776..b84aa605 100644 --- a/chrome/config.js +++ b/chrome/config.js @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -/*global setup_redirect: false, setup_header: false, setup_proxy: false */ +/*global 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"; @@ -23,18 +23,15 @@ // ====== Constant and Variable Settings ====== var unblock_youku = unblock_youku || {}; // namespace -// only for proxy mode +// Default proxy server settings unblock_youku.default_proxy_server_proc = 'HTTPS'; unblock_youku.default_proxy_server_addr = 'secure.uku.im:8443'; unblock_youku.backup_proxy_server_proc = 'HTTPS'; unblock_youku.backup_proxy_server_addr = 'secure.uku.im:993'; -// only for redirect mode -unblock_youku.default_redirect_server = 'www.yōukù.com/proxy'; -unblock_youku.backup_redirect_server = 'bak.yōukù.com/proxy'; unblock_youku.ip_addr = new_random_ip(); -console.log('ip addr: ' + unblock_youku.ip_addr); +console.log('generated random ip addr: ' + unblock_youku.ip_addr); // ====== Configuration Functions ====== @@ -45,7 +42,7 @@ function set_mode_name(mode_name, callback) { ga_report_error('Unexpected Error', err_msg); } - if (mode_name === 'off' || mode_name === 'lite') { + if (mode_name === 'off') { set_storage('unblock_youku_mode', mode_name, callback); } else { set_storage('unblock_youku_mode', 'normal', callback); @@ -60,10 +57,8 @@ function get_mode_name(callback) { } get_storage('unblock_youku_mode', function(current_mode) { - if (typeof current_mode === 'undefined' || ( - current_mode !== 'off' && - current_mode !== 'lite' )) { - set_mode_name('normal', function() { + if (typeof current_mode === 'undefined' || current_mode !== 'off') { + set_mode_name('normal', function () { callback('normal'); }); } else { @@ -74,24 +69,20 @@ function get_mode_name(callback) { function clear_mode_settings(mode_name) { switch (mode_name) { - case 'off': - console.log('cleared settings for off'); - break; - case 'lite': - clear_header(); - clear_redirect(); - console.log('cleared settings for lite'); - break; - case 'normal': - clear_header(); - clear_proxy(); - console.log('cleared settings for normal'); - break; - default: - var err_msg = 'clear_mode_settings: should never come here'; - console.error(err_msg); - ga_report_error('Unexpected Error', err_msg); - break; + case 'off': + console.log('cleared settings for off'); + break; + case 'normal': + clear_header(); + clear_redirect(); + clear_proxy(); + console.log('cleared settings for normal'); + break; + default: + var err_msg = 'clear_mode_settings: should never come here'; + console.error(err_msg); + ga_report_error('Unexpected Error', err_msg); + break; } console.log('cleared the settings for the mode: ' + mode_name); @@ -99,29 +90,27 @@ function clear_mode_settings(mode_name) { function setup_mode_settings(mode_name) { switch (mode_name) { - case 'off': - chrome.browserAction.setBadgeText({text: 'OFF'}); - chrome.browserAction.setTitle({title: 'Unblock Youku has been turned off.'}); - change_browser_icon('off'); - break; - case 'lite': - setup_header(); - setup_redirect(); - chrome.browserAction.setBadgeText({text: 'LITE'}); - chrome.browserAction.setTitle({title: 'Unblock Youku is running in the lite mode.'}); - change_browser_icon('off'); - break; - case 'normal': - // setup_header(); - setup_proxy(); - chrome.browserAction.setBadgeText({text: ''}); - change_browser_icon('normal'); - break; - default: - var err_msg = 'setup_mode_settings: should never come here'; - console.error(err_msg); - ga_report_error('Unexpected Error', err_msg); - break; + case 'off': + chrome.browserAction.setBadgeText({ text: 'OFF' }); + chrome.browserAction.setTitle({ title: 'Unblock Youku has been turned off.' }); + change_browser_icon('off'); + break; + case 'lite': + set_mode_name('normal', function() { + console.log('migrate lite mode to normal mode'); + }); + // fall through + case 'normal': + setup_header(); + setup_proxy(); + chrome.browserAction.setBadgeText({ text: '' }); + change_browser_icon('normal'); + break; + default: + var err_msg = 'setup_mode_settings: should never come here'; + console.error(err_msg); + ga_report_error('Unexpected Error', err_msg); + break; } console.log('initialized the settings for the mode: ' + mode_name); @@ -139,23 +128,23 @@ function change_browser_icon(option) { var d = today.getDate(); var m = today.getMonth() + 1; - // hard-coded spring festivals + // hard-coded spring festival dates var is_spring = false; switch (y) { - case 2016: // February 8, 2016 - if ((m === 1 && d >= 29) || (m === 2 && d <= 18)) { - is_spring = true; - } + case 2023: // Jan. 22, 2023 + is_spring = m === 1; + break; + case 2024: // Feb. 10, 2024 + is_spring = m === 2; break; - case 2017: // January 28, 2017 - if ((m === 1 && d >= 18) || (m === 2 && d <= 7)) { - is_spring = true; - } + case 2025: // Jan. 29, 2025 + is_spring = m === 1; break; - case 2018: // February 16, 2018 - if (m === 2 && (6 <= d && d <= 26)) { - is_spring = true; - } + case 2026: // Feb. 17, 2026 + is_spring = m === 2; + break; + case 2027: // Feb. 7, 2027 + is_spring = m === 2; break; } if (is_spring) { @@ -209,19 +198,6 @@ function storage_monitor(changes, area) { } } - if (typeof changes.custom_redirect_server !== 'undefined') { - var redirect_server_change = changes.custom_redirect_server; - - if (typeof redirect_server_change.newValue !== 'undefined') { - // have to use a localStorage cache for using in the blocking webRequest listener - localStorage.custom_redirect_server = redirect_server_change.newValue; - } else { - if (typeof localStorage.custom_redirect_server !== 'undefined') { - localStorage.removeItem('custom_redirect_server'); - } - } - } - if (typeof changes.custom_proxy_server !== 'undefined') { var proxy_server_change = changes.custom_proxy_server; if (typeof proxy_server_change.newValue !== 'undefined' diff --git a/chrome/pages/js/options-proxy.js b/chrome/pages/js/options-proxy.js index a4a2c201..d1afc14d 100644 --- a/chrome/pages/js/options-proxy.js +++ b/chrome/pages/js/options-proxy.js @@ -15,8 +15,6 @@ * along with this program. If not, see . */ -/*global chrome: false, $: false, localStorage: false */ - var background = background || chrome.extension.getBackgroundPage(); var default_proxy_server_proc = background.unblock_youku.default_proxy_server_proc; var default_proxy_server_addr = background.unblock_youku.default_proxy_server_addr; @@ -79,6 +77,7 @@ function get_custom_proxy_server(callback) { function test_custom_proxy_server(callback) { "use strict"; + // TODO: Change this URL to a new one. It stopped working a while ago. var test_url = 'http://ipservice.163.com/isFromMainland'; show_proxy_test_message('info', 'Testing connection & Unblock...'); $.get(test_url, function(data) { @@ -131,12 +130,12 @@ $(document).ready(function() { background.setup_proxy(); $('#custom_proxy_reset').attr('disabled', false); show_proxy_message('info', 'Enabled custom proxy server.'); - test_custom_proxy_server(); + // test_custom_proxy_server(); } else { background.set_mode_name('normal', function() { $('#custom_proxy_reset').attr("disabled", false); show_proxy_message('warning', 'Enabled custom proxy server, and changed to proxy mode.'); - test_custom_proxy_server(); + // test_custom_proxy_server(); }); } }); @@ -154,14 +153,14 @@ $(document).ready(function() { $('#custom_proxy_addr').attr('disabled', false); $('#custom_proxy_enable').attr('disabled', false); show_proxy_message('warning', 'Reset custom proxy server.'); - test_custom_proxy_server(); + // test_custom_proxy_server(); } else { background.set_mode_name('normal', function() { $('#custom_proxy_proc').attr('disabled', false); $('#custom_proxy_addr').attr('disabled', false); $('#custom_proxy_enable').attr('disabled', false); show_proxy_message('warning', 'Reset custom proxy server, and changed to proxy mode.'); - test_custom_proxy_server(); + // test_custom_proxy_server(); }); } }); diff --git a/chrome/pages/js/options-redirect.js b/chrome/pages/js/options-redirect.js deleted file mode 100644 index a82c1535..00000000 --- a/chrome/pages/js/options-redirect.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 . - */ - -/*global $: false, btoa: false */ - -var background = background || chrome.extension.getBackgroundPage(); -var default_redirect_server = background.unblock_youku.default_redirect_server; - -function remove_custom_redirect_server(callback) { - "use strict"; - // localStorage.removeItem('custom_redirect_server'); - background.remove_storage('custom_redirect_server', callback); -} - -function get_custom_redirect_server(callback) { - "use strict"; - background.get_storage('custom_redirect_server', function(server_addr) { - if (typeof server_addr === 'undefined') { - callback(default_redirect_server); - } else { - callback(server_addr); - } - }); -} - -function set_custom_redirect_server(server_addr, callback) { - "use strict"; - if (server_addr === default_redirect_server) { - // must remove, otherwise the post server won't be invoked - remove_custom_redirect_server(callback); - } else { - // chrome.storage.sync.onChange listener will change localStorage as well - // localStorage.custom_redirect_server = server_addr; - background.set_storage('custom_redirect_server', server_addr, callback); - } -} - - -function show_redirect_message(type, content) { - "use strict"; - var alert_type = 'info'; - if (type === 'success' || type === 'warning') { - alert_type = type; // success, info, or warning - } - - $('#redirect_message').html('
' + content + '
'); -} - - -function show_redirect_error(content) { - $('#redirect_message').html('
' + content + '
'); -} - - -$('document').ready(function() { - "use strict"; - get_custom_redirect_server(function(server_addr) { - $('input#custom_redirect_server').val(server_addr); - }); - - - $('button#custom_redirect_test').click(function() { - var test_url = 'http://' + $('input#custom_redirect_server').val() + '?url=' + btoa('http://ipservice.163.com/isFromMainland'); - show_redirect_message('info', 'Waiting...'); - $.get(test_url, function(data) { - if (data === 'true') { - show_redirect_message('success', 'Test passed. Please remember to save the new configuration.'); - } else { - show_redirect_error('Test failed! Perhaps your server isn\'t located in mainland China.'); - } - }).error(function() { - show_redirect_error('Test failed! Perhaps the server isn\'t working properly.'); - }); - }); - - $('button#custom_redirect_save').click(function() { - set_custom_redirect_server($('input#custom_redirect_server').val(), function() { - show_redirect_message('info', 'The new backend server is set.'); - }); - }); - - - $('button#custom_redirect_reset').click(function() { - remove_custom_redirect_server(function() { - $('input#custom_redirect_server').val(default_redirect_server); - show_redirect_message('warning', 'Reset to the default backend server.'); - }); - }); - - $('#form_custom_redirect_server').submit(function(event) { - // prevent the default action of submitting a form - event.preventDefault(); - }); -}); - diff --git a/chrome/pages/js/popup.js b/chrome/pages/js/popup.js index 83e0050e..c068f441 100644 --- a/chrome/pages/js/popup.js +++ b/chrome/pages/js/popup.js @@ -15,8 +15,6 @@ * along with this program. If not, see . */ -/*jslint browser: true */ -/*global $: false, chrome: false, ga_report_event: false */ function set_i18n_text() { "use strict"; @@ -33,14 +31,9 @@ function set_i18n_text() { $('span.mode_off_name').html(get_msg('mode_off')); $('span.mode_off_desc').html(get_msg('mode_off_description')); - $('span.mode_lite_name').html(get_msg('mode_lite')); - $('span.mode_lite_desc').html(get_msg('mode_lite_description')); $('span.mode_normal_name').html(get_msg('mode_normal')); $('span.mode_normal_desc').html(get_msg('mode_normal_description')); - //$('span.mode_redirect_name').html(get_msg('mode_redirect')); - //$('span.mode_redirect_desc').html(get_msg('mode_redirect_description')); - //$('div#help_text').html(get_msg('help')); $('div#faq').html(get_msg('faq')); $('div#feedback').html(get_msg('feedback')); $('div#rating').html(get_msg('rating')); @@ -58,12 +51,6 @@ $(document).ready(function() { case 'off': $('label#off').addClass('active'); break; - case 'lite': - $('label#lite').addClass('active'); - break; - case 'redirect': - $('label#redirect').addClass('active'); - break; default: $('label#normal').addClass('active'); break; @@ -85,32 +72,12 @@ $(document).ready(function() { console.log('to change mode to off'); background.change_mode('off'); }); - $('input#input_lite').change(function() { - console.log('to change mode to lite'); - background.change_mode('lite'); - }); $('input#input_normal').change(function() { console.log('to change mode to normal'); background.change_mode('normal'); }); - //$('input#input_redirect').change(function() { - // console.log('to change mode to redirect'); - // background.change_mode('redirect'); - //}); // enable tooltip $('#tooltip').tooltip(); - - var my_date = new Date(); - if (typeof localStorage.first_time === 'undefined') { - localStorage.first_time = my_date.getTime(); - } else if (my_date.getTime() > parseInt(localStorage.first_time, 10) + 1000 * 60 * 60 * 24 * 3) { - $('div#rating').show(); // delay 3 days for the rating div to show up, hahaha - } - - $('#support_button').click(function() { - // Make sure the donation page is only shown once - background.localStorage.showed_donation_page = new Date().getTime(); - }); }); diff --git a/chrome/pages/options.html b/chrome/pages/options.html index 71177cf5..d8b543f5 100644 --- a/chrome/pages/options.html +++ b/chrome/pages/options.html @@ -6,7 +6,6 @@ - @@ -43,29 +42,6 @@
-
-
-
-
- Custom backend server for the Redirect Mode -
-
- http:// - - ?url= -
-
-
-
- - - -
-
-
-
-
-
diff --git a/chrome/pages/popup.html b/chrome/pages/popup.html index 4683963b..03f71f04 100644 --- a/chrome/pages/popup.html +++ b/chrome/pages/popup.html @@ -17,7 +17,8 @@
NEW

- +
@@ -57,37 +58,14 @@ -
-
- - - - - - - - - - - - - - - -
- -
-
diff --git a/chrome/proxy.js b/chrome/proxy.js index a6f780b2..b60430ff 100644 --- a/chrome/proxy.js +++ b/chrome/proxy.js @@ -60,11 +60,6 @@ function setup_proxy() { backup_proxy_server_addr = localStorage.custom_proxy_server_addr; } - /* DEBUG -- BEGIN */ - // proxy_server_proc = 'SOCKS5'; - // proxy_server_addr = '127.0.0.1:1080'; - /* DEBUG -- END */ - setup_pac_data(proxy_server_proc, proxy_server_addr, backup_proxy_server_proc, backup_proxy_server_addr); console.log('using the proxy server: ' + proxy_server_proc + ' ' + proxy_server_addr); diff --git a/chrome/redirect.js b/chrome/redirect.js index 1ee51201..2f6af78f 100644 --- a/chrome/redirect.js +++ b/chrome/redirect.js @@ -15,9 +15,7 @@ * along with this program. If not, see . */ -/*jslint browser: true */ -/*global chrome: false, unblock_youku: false, btoa: false */ -/*global ga_report_error: false, string_starts_with: false */ +/*global string_starts_with: false */ "use strict"; @@ -57,74 +55,11 @@ function http_redirector(details) { } -function check_redirect_server(server_addr, success_callback, failure_callback) { - console.log('to test the redirection server: ' + server_addr); - var xhr = new XMLHttpRequest(); - - var xhr_timer = setTimeout(function() { - xhr.abort(); - console.warn(server_addr + ' TIMEOUT!'); - failure_callback('Timeout'); - }, 10000); // 10s - - xhr.open('GET', 'http://' + server_addr.match(/^(.[^\/]+)/)[1] + '/status', true); - xhr.timeout = 12000; // 12s - xhr.onreadystatechange = function() { - if (xhr.readyState === 4) { - if ((xhr.status === 200 || xhr.status === 304) - && xhr.responseText.indexOf('OK') !== -1) { - clearTimeout(xhr_timer); - success_callback(); - } else { - clearTimeout(xhr_timer); - failure_callback('Wrong Status: [' + xhr.status + '] ' + xhr.responseText); - } - } - }; - xhr.onerror = function(err) { - console.warn(server_addr + ' ERROR!'); - clearTimeout(xhr_timer); - failure_callback(JSON.stringify(err)); - }; - xhr.send(); -} - - -function setup_redirect() { - if (!chrome.webRequest.onBeforeRequest.hasListener(http_redirector)) { - chrome.webRequest.onBeforeRequest.addListener( - http_redirector, - { - urls: unblock_youku.redirect_urls - }, - ["blocking"] - ); - console.log('http_redirector is set'); - } else { - var err_msg = 'http_redirector is already there!'; - console.error(err_msg); - ga_report_error('Unexpected Error', err_msg); - } - - unblock_youku.actual_redirect_server = unblock_youku.default_redirect_server; - check_redirect_server(unblock_youku.actual_redirect_server, function() { - console.log('default_redirect_server seems to be working fine: ' + unblock_youku.actual_redirect_server); - }, function(err_msg) { - unblock_youku.actual_redirect_server = unblock_youku.backup_redirect_server; - console.warn('default_redirect_server error: ' + err_msg); - console.warn('changed to backup_redirect_server: ' + unblock_youku.actual_redirect_server); - ga_report_error('Redirect Server Error', unblock_youku.default_redirect_server + ': ' + err_msg); - }); -} - - function clear_redirect() { if (chrome.webRequest.onBeforeRequest.hasListener(http_redirector)) { chrome.webRequest.onBeforeRequest.removeListener(http_redirector); console.log('http_redirector is removed'); } else { - var err_msg = 'http_redirector is not there!'; - console.error(err_msg); - ga_report_error('Unexpected Error', err_msg); + console.log('http_redirector is not there!'); } } diff --git a/manifest.json b/manifest.json index d2a6a82b..64285a94 100644 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,8 @@ { "name": "Unblock Youku", - "version": "3.9.3", + "version": "3.10.0", "manifest_version": 2, - "minimum_chrome_version": "25.0", + "minimum_chrome_version": "80.0", "description": "__MSG_description__", "icons": { "16": "chrome/icons/icon16.png", diff --git a/shared/urls.js b/shared/urls.js index a5100232..3a17eac0 100644 --- a/shared/urls.js +++ b/shared/urls.js @@ -17,25 +17,6 @@ var unblock_youku = unblock_youku || {}; -/* - PLEASE READ THIS FIRST! - - This file contains several lists of URLs, which are used in different unblock modes: - - - The (non-proxy) lite mode of our Chrome extension will use: - - header_urls, and - - redirect_urls. - - The (default) standard mode will use: - - header_urls, - - redirect_urls, and - - chrome_proxy_urls. - - The PAC service (for iOS/Android) will use all lists: - - header_urls, - - redirect_urls, - - chrome_proxy_urls, and - - pac_proxy_urls. - */ - /* * Note that the HTTPS URLs must NOT have any path portions. * @@ -45,25 +26,17 @@ var unblock_youku = unblock_youku || {}; */ -// Just changing headers of these URLs will be sufficient. +// The HTTP headers of these URLs will be modified. unblock_youku.header_urls = [ - 'http://v.api.hunantv.com/*', - 'http://live.gslb.letv.com/*', - 'http://ac.qq.com/*', 'http://*.ssports.com/*', 'http://ssports.com/*', 'http://ssports.smgbb.cn/*', - 'http://www.bilibili.com/*', - 'http://interface.bilibili.com/*', - 'http://bangumi.bilibili.com/*', 'https://pstream.api.mgtv.com/*', 'http://kandian.com/player/getEpgInfo*', - 'http://u.y.qq.com/cgi-bin/*', - 'https://u.y.qq.com/*' ]; -// These URLs can work with the redirect functionality (mainly used in Flash players). -unblock_youku.redirect_urls = [ +// These URLs will go through a proxy. +unblock_youku.chrome_proxy_urls = [ 'https://dmd-fifajs-h5-ikuweb.youku.com/*', 'https://dmd-fifa-h5-ikuweb.youku.com/*', 'http://acs.youku.com/*', @@ -233,12 +206,8 @@ unblock_youku.redirect_urls = [ 'http://vip.sports.cntv.cn/check.do*', 'http://vip.sports.cntv.cn/play.do*', 'http://vip.sports.cntv.cn/servlets/encryptvideopath.do*', - 'http://211.151.157.15/*' -]; - + 'http://211.151.157.15/*', -// These URLs have to go through a proxy (for our Chrome extension). -unblock_youku.chrome_proxy_urls = unblock_youku.redirect_urls.concat([ 'http://www.tudou.com/programs/view/*', 'http://www.tudou.com/albumplay/*', 'http://www.tudou.com/listplay/*', @@ -369,7 +338,7 @@ unblock_youku.chrome_proxy_urls = unblock_youku.redirect_urls.concat([ // for development purposes 'http://flask-test-iwauxcyxjb.cn-hangzhou.fcapp.run/*', 'https://flask-test-iwauxcyxjb.cn-hangzhou.fcapp.run/*' -]); +]; // These URLs will not go through proxy servers (for our Chrome extension).