Skip to content

Commit

Permalink
1. Finish rewriting the options page
Browse files Browse the repository at this point in the history
2. Add content scripts back
3. Reformat remaining files to comply with the coding style

Still need to:
1. Add header modifier back
2. Potentially add some unit tests and e2e tests?
  • Loading branch information
zhuzhuor committed Jul 1, 2022
1 parent 62fb6e4 commit d4e778f
Show file tree
Hide file tree
Showing 13 changed files with 337 additions and 332 deletions.
20 changes: 0 additions & 20 deletions .eslintrc.js

This file was deleted.

25 changes: 25 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"env": {
"browser": true,
"es2021": true,
"webextensions": true,
"jquery": true
},
"extends": [
"google"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"require-jsdoc": "off",
"no-multi-str": "off",
"max-len": [
"error",
{
"code": 100
}
]
}
}
70 changes: 60 additions & 10 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"background": {
"service_worker": "src/background.mjs",
"type": "module"
},
"action": {
"default_title": "Unblock Youku isn't working properly! Visit http://uku.im/faq for solutions.",
"default_icon": "icons/icon19gray.png",
"default_popup": "src/popup.html"
},
"options_page": "src/options.html",
"permissions": [
"proxy",
"declarativeNetRequestWithHostAccess",
Expand All @@ -28,5 +18,65 @@
"host_permissions": [
"http://*/*",
"https://*/*"
],
"background": {
"service_worker": "src/background.mjs",
"type": "module"
},
"action": {
"default_popup": "src/popup.html",
"default_icon": "icons/icon19gray.png",
"default_title": "Unblock Youku isn't working properly! Visit http://uku.im/faq for solutions."
},
"options_page": "src/options.html",
"content_scripts": [
{
"matches": [
"http://www.tudou.com/*"
],
"js": [
"src/content_scripts/tudou.js"
],
"run_at": "document_end",
"all_frames": true
},
{
"matches": [
"http://play.baidu.com/*"
],
"css": [
"src/content_scripts/play.baidu.css"
],
"all_frames": true
},
{
"matches": [
"http://music.163.com/*"
],
"js": [
"src/content_scripts/music.163.js"
],
"run_at": "document_end",
"all_frames": true
},
{
"matches": [
"http://unblockcn.com/*",
"https://unblockcn.com/*",
"http://*.unblockcn.com/*",
"https://*.unblockcn.com/*",
"http://unblockyouku.cn/*",
"http://*.unblockyouku.cn/*",
"http://724sky.com/*",
"http://*.724sky.com/*",
"http://tieba.baidu.com/f?kw=unblockcn*",
"http://*.tieba.baidu.com/f?kw=unblockcn*"
],
"js": [
"src/content_scripts/unblockcn.js"
],
"run_at": "document_end",
"all_frames": true
}
]
}
22 changes: 2 additions & 20 deletions src/content_scripts/music.163.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
/*
* Copyright (C) 2012 - 2014 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 <http://www.gnu.org/licenses/>.
*/
'use strict';

/*jslint browser: true */
"use strict";

var s = document.createElement('script');
const s = document.createElement('script');
s.type = 'text/javascript';
s.innerText = ' \
(function() { \
Expand Down
18 changes: 0 additions & 18 deletions src/content_scripts/play.baidu.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/*
* Copyright (C) 2012 - 2014 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 <http://www.gnu.org/licenses/>.
*/


div#foreignIP, div.ui-widget-overlay {
display: none !important;
}
Expand Down
58 changes: 19 additions & 39 deletions src/content_scripts/play.baidu.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
/*
* Copyright (C) 2012 - 2014 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 <http://www.gnu.org/licenses/>.
*/
'use strict';

/*jslint browser: true */
"use strict";

var s = document.createElement('script');
const s = document.createElement('script');
s.type = 'text/javascript';
s.innerText = ' \
(function() { \
var i, list = document.getElementsByTagName("script"); \
for (i = 0; i < list.length; i++) { \
list[i].innerHTML = list[i].innerHTML.replace(/isForeign[^;]*/gi, "isForeign = \\\"\\\""); \
} \
mbox.isForeign = ""; \
document.body.classList.remove("foreignIP"); \
}());';
(function() { \
var i, list = document.getElementsByTagName("script"); \
for (i = 0; i < list.length; i++) { \
list[i].innerHTML = list[i].innerHTML.replace(/isForeign[^;]*/gi, "isForeign = \\\"\\\""); \
} \
mbox.isForeign = ""; \
document.body.classList.remove("foreignIP"); \
}());';

var target = null;
var i, list = document.getElementsByTagName("script");
let target = null;
let i; const list = document.getElementsByTagName('script');
for (i = 0; i < list.length; i++) {
if (list[i].innerHTML.indexOf('isForeign') !== -1) {
target = list[i];
break;
}
}
if (list[i].innerHTML.indexOf('isForeign') !== -1) {
target = list[i];
break;
}
}
if (target !== null) {
target.parentNode.insertBefore(s, target.nextSibling);
target.parentNode.insertBefore(s, target.nextSibling);
} else {
document.body.appendChild(s);
document.body.appendChild(s);
}
// console.log(target);
// console.log('load successfuly');
22 changes: 2 additions & 20 deletions src/content_scripts/tudou.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
/*
* Copyright (C) 2012 - 2014 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 <http://www.gnu.org/licenses/>.
*/
'use strict';

/*jslint browser: true */
"use strict";

var s = document.createElement('script');
const s = document.createElement('script');
s.type = 'text/javascript';
s.innerText = ' \
(function() { \
Expand Down
19 changes: 12 additions & 7 deletions src/content_scripts/unblockcn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
* - https://github.com/Unblocker/malicious-unblockcn
*/

/*jslint browser: true */
"use strict";
'use strict';

document.body.innerHTML =
'<div style="width:100%;height:auto;z-index:2147483647;text-align:center;font-size:1.5em;padding:5px;border-style:solid;color:black;border-color:red;background-color:white;">' +
document.body.innerHTML =
'<div style="' +
'width:100%;height:auto;z-index:2147483647;text-align:center;font-size:1.5em;' +
'padding:5px;border-style:solid;color:black;border-color:red;' +
'background-color:white;">' +
'请各位 Unblock Youku 用户不要上当受骗,Unblock Youku 并没有改名为 UnblockCN。<br>' +
'1. UnblockCN 在 Unblock Youku 服务器<a href="https://git.io/vgXeh">被攻击的同一时间散播 Unblock Youku 改名的恶意谣言</a>。<br>' +
'2. UnblockCN 会<a href="https://git.io/vgVtc">劫持用户页面,强迫用户付费购买 VIP</a>,并伪造 Unblock Youku 网站。<br>' +
'如果不幸被骗安装 UnblockCN 软件,请阅读<a style="text-decoration:underline" href="https://github.com/Unblocker/Unblock-Youku/issues/468">这里的解决办法</a>。' +
'1. UnblockCN 在 Unblock Youku 服务器<a href="https://git.io/vgXeh">' +
'被攻击的同一时间散播 Unblock Youku 改名的恶意谣言</a>。<br>' +
'2. UnblockCN 会<a href="https://git.io/vgVtc">劫持用户页面,强迫用户付费购买 VIP</a>,' +
'并伪造 Unblock Youku 网站。<br>' +
'如果不幸被骗安装 UnblockCN 软件,请阅读' +
'<a style="text-decoration:underline" href="https://bit.ly/3NArrwb">这里的解决办法</a>。' +
'</div>' + document.body.innerHTML;
9 changes: 4 additions & 5 deletions src/modules/_proxy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ async function setPacScript(
console.log('To set up proxy...');

const pacScript = urls2pac(
PROXY_BYPASS_URLS,
PROXY_URLS,
defaultProxyAddress, defaultProxyProtocol,
backupProxyAddress, backupProxyProtocol);
PROXY_BYPASS_URLS, PROXY_URLS,
defaultProxyProtocol, defaultProxyAddress,
backupProxyProtocol, backupProxyAddress);

console.group('Printing PAC script content:');
console.groupCollapsed('Printing PAC script content...');
console.log(pacScript);
console.groupEnd();

Expand Down
Loading

0 comments on commit d4e778f

Please sign in to comment.