diff --git a/chrome/config.js b/chrome/config.js index 874a944d..13b7664d 100644 --- a/chrome/config.js +++ b/chrome/config.js @@ -17,9 +17,9 @@ */ /*jslint browser: true */ -/*global chrome: false, get_storage: false, set_storage: false, new_random_ip: false, new_sogou_auth_str: false */ -/*global setup_lite_header: false, setup_redirect: false, setup_normal_header: false, setup_proxy: false, setup_timezone: false, setup_extra_header: false */ -/*global clear_lite_header: false, clear_redirect: false, clear_normal_header: false, clear_proxy: false, clear_timezone: false */ +/*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 ga_report_event: false, ga_report_ratio: false, ga_report_error: false */ "use strict"; @@ -40,8 +40,6 @@ unblock_youku.header_extra_url_list = [ unblock_youku.ip_addr = new_random_ip(); console.log('ip addr: ' + unblock_youku.ip_addr); -unblock_youku.sogou_auth = new_sogou_auth_str(); -console.log('sogou_auth: ' + unblock_youku.sogou_auth); unblock_youku.version = chrome.runtime.getManifest().version; // the lastest version to show NEW on the icon; it's usually a big update with new features @@ -93,7 +91,7 @@ function clear_mode_settings(mode_name) { switch (mode_name) { case 'lite': // clear_timezone(); - clear_lite_header(); + clear_header(); console.log('cleared settings for lite'); break; case 'redirect': @@ -103,7 +101,7 @@ function clear_mode_settings(mode_name) { case 'normal': // clear_timezone(); clear_proxy(); - clear_normal_header(); + clear_header(); console.log('cleared settings for normal'); break; default: @@ -119,14 +117,14 @@ function clear_mode_settings(mode_name) { function setup_mode_settings(mode_name) { switch (mode_name) { case 'lite': - setup_lite_header(); + setup_header(); // setup_timezone(); break; case 'redirect': setup_redirect(); break; case 'normal': - setup_normal_header(); + setup_header(); setup_proxy(); // setup_timezone(); break; diff --git a/chrome/header.js b/chrome/header.js index 79656fab..c6d1b589 100644 --- a/chrome/header.js +++ b/chrome/header.js @@ -16,38 +16,15 @@ * along with this program. If not, see . */ -/*global chrome: false, unblock_youku: false, compute_sogou_tag: false */ +/*global chrome: false, unblock_youku: false */ /*global ga_report_error: false */ "use strict"; -function lite_header_modifier(details) { - details.requestHeaders.push({ - name: 'X-Forwarded-For', - value: unblock_youku.ip_addr - }, { - name: 'Client-IP', - value: unblock_youku.ip_addr - }); - return {requestHeaders: details.requestHeaders}; -} - -function normal_header_modifier(details) { - var timestamp = Math.round(details.timeStamp / 1000).toString(16); - var tag = compute_sogou_tag(timestamp, details.url); - - console.log('t=' + timestamp + ' h=' + tag + ' ' + details.url); +function header_modifier(details) { + console.log('Modify headers of ' + details.url); details.requestHeaders.push({ - name: 'X-Sogou-Auth', - value: unblock_youku.sogou_auth - }, { - name: 'X-Sogou-Timestamp', - value: timestamp - }, { - name: 'X-Sogou-Tag', - value: tag - }, { name: 'X-Forwarded-For', value: unblock_youku.ip_addr }, { @@ -58,56 +35,31 @@ function normal_header_modifier(details) { return {requestHeaders: details.requestHeaders}; } -function setup_lite_header() { - if (!chrome.webRequest.onBeforeSendHeaders.hasListener(lite_header_modifier)) { - chrome.webRequest.onBeforeSendHeaders.addListener( - lite_header_modifier, - {urls: unblock_youku.normal_url_list}, // the same url list as normal mode - ['requestHeaders', 'blocking'] - ); - console.log('lite_header_modifier is set'); - } else { - var err_msg = 'lite_header_modifier is already there!'; - console.error(err_msg); - ga_report_error('Unexpected Error', err_msg); - } -} -function setup_normal_header() { - if (!chrome.webRequest.onBeforeSendHeaders.hasListener(normal_header_modifier)) { +function setup_header() { + if (!chrome.webRequest.onBeforeSendHeaders.hasListener(header_modifier)) { chrome.webRequest.onBeforeSendHeaders.addListener( - normal_header_modifier, + header_modifier, { urls: unblock_youku.normal_url_list }, ['requestHeaders', 'blocking'] ); - console.log('normal_header_modifier is set'); + console.log('header_modifier is set'); } else { - var err_msg = 'normal_header_modifer is already there!'; + var err_msg = 'header_modifer is already there!'; console.error(err_msg); ga_report_error('Unexpected Error', err_msg); } } -function clear_lite_header() { - if (chrome.webRequest.onBeforeSendHeaders.hasListener(lite_header_modifier)) { - chrome.webRequest.onBeforeSendHeaders.removeListener(lite_header_modifier); - console.log('lite_header_modifier is removed'); - } else { - var err_msg = 'lite_header_modifer is not there!'; - console.error(err_msg); - ga_report_error('Unexpected Error', err_msg); - } -} - -function clear_normal_header() { - if (chrome.webRequest.onBeforeSendHeaders.hasListener(normal_header_modifier)) { - chrome.webRequest.onBeforeSendHeaders.removeListener(normal_header_modifier); - console.log('normal_header_modifier is removed'); +function clear_header() { + if (chrome.webRequest.onBeforeSendHeaders.hasListener(header_modifier)) { + chrome.webRequest.onBeforeSendHeaders.removeListener(header_modifier); + console.log('header_modifier is removed'); } else { - var err_msg = 'normal_header_modifier is not there!'; + var err_msg = 'header_modifier is not there!'; console.error(err_msg); ga_report_error('Unexpected Error', err_msg); } diff --git a/manifest.json b/manifest.json index 1c7b12ad..608a7451 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Unblock Youku", - "version": "2.7.4.0", + "version": "2.7.4.1", "manifest_version": 2, "minimum_chrome_version": "25.0", "description": "__MSG_description__", @@ -21,7 +21,6 @@ "scripts": [ "shared/urls.js", "shared/tools.js", - "shared/sogou.js", "chrome/pages/js/analytics.js", "chrome/storage.js", "chrome/header.js",