better popup for extension

This commit is contained in:
Ilya Ig. Petrov 2015-12-01 11:24:45 +05:00
parent f538109330
commit c11a30a319
150 changed files with 31009 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -1,32 +1,106 @@
'use strict'; 'use strict';
var Antizapret = { var RKN = {
version: chrome.runtime.getManifest().version,
csvMirrors: [ csvMirrors: [
'https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv', 'https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv',
'http://sourceforge.net/p/z-i/code-0/HEAD/tree/dump.csv?format=raw', 'http://sourceforge.net/p/z-i/code-0/HEAD/tree/dump.csv?format=raw',
'https://www.assembla.com/spaces/z-i/git/source/master/dump.csv?_format=raw' 'https://www.assembla.com/spaces/z-i/git/source/master/dump.csv?_format=raw'
], ],
lastUpdate: new Date(0), lastUpdate: (new Date(0)).toString(),
updatePeriodInMinutes: 7*60, updatePeriodInMinutes: 7*60,
ifEnabled: false,
updateIcon: function(cb) {
var cb = cb || () => {};
return chrome.browserAction.setIcon(
{ path: this.ifEnabled ? './assets/icons/rkn.png' : './assets/icons/rkn-disabled.png' },
cb
);
},
disable: function(cb) {
var cb = cb || () => {};
if(!this.ifEnabled)
return cb();
this.checkForUpdates( (err, res) => {
if (err) return cb(err);
this.applyPac();
this.ifEnabled = false;
this.persistToStorage();
return this.updateIcon(cb);
});
},
enable: function(cb) {
var cb = cb || () => {};
return chrome.proxy.settings.clear({/*All*/}, () => {
this.ifEnabled = true;
this.persistToStorage();
return this.updateIcon(cb);
});
},
switch: function(cb) {
var cb = cb || () => {};
return this.ifEnabled ? this.disable(cb) : this.enable(cb);
},
persistToStorage: function(cb) {
var cb = cb || () => {};
var storage = {};
storage[this.version] = JSON.stringify(this);
chrome.storage.local.set(storage, cb);
},
syncWithStorage: function(cb) {
var cb = cb || () => {};
chrome.storage.local.get(
this.version,
object => {
if (!Object.keys(object).length)
return this.persistToStorage(cb);
var self = JSON.parse(object[this.version]);
for(var key of Object.keys(self))
this[key] = self[key];
return cb(this);
}
);
},
install: function() {
chrome.storage.local.clear();
this.disable();
},
rescheduleUpdate: function(period) { rescheduleUpdate: function(period) {
var checkNewBlocked = 'Check for new blocked sites'; var checkNewBlocked = 'Check for new blocked sites';
var period = period || this.updatePeriodInMinutes; var period = period || this.updatePeriodInMinutes;
chrome.alarms.clearAll( (ifWasCleared) => { chrome.alarms.clearAll( ifWasCleared => {
chrome.alarms.create(checkNewBlocked, { chrome.alarms.create(checkNewBlocked, {
delayInMinutes: period delayInMinutes: period
}); });
chrome.alarms.onAlarm.addListener( alarm => { chrome.alarms.onAlarm.addListener( alarm => {
if (alarm.name === checkNewBlocked) if (alarm.name === checkNewBlocked) {
this.checkForUpdate(); this.checkForUpdate();
}
}); });
}); });
}, },
checkForUpdates: function(url, cb) { checkForUpdates: function(url, cb) {
if (!url) if (!url || !cb)
return this._useTheMirrorsLuke(this.checkForUpdates, url, cb); return this._useTheMirrorsLuke(this.checkForUpdates, url, cb);
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
@ -37,7 +111,7 @@ var Antizapret = {
return cb(req.status); return cb(req.status);
var date = Date.parse(req.getResponseHeader('Date')); var date = Date.parse(req.getResponseHeader('Date'));
if (date > this.lastUpdate) if (date > Date.parse(this.lastUpdate))
return this.update(url, cb); return this.update(url, cb);
return cb(null); return cb(null);
@ -46,21 +120,28 @@ var Antizapret = {
}, },
update: function(url, cb) { update: function(url, cb) {
if (!url) if (!url || !cb)
return this._useTheMirrorsLuke(this.update, url, cb); return this._useTheMirrorsLuke(this.update, url, cb);
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.open('GET', url, true); req.open('GET', url, true);
req.onload = event => { req.onload = event => {
this.lastUpdate = Date.now(); this.lastUpdate = (new Date()).toString();
this.applyCsv( req.responseText ); this.generatePacFromCsv(req.responseText);
this.persistToStorage();
this.rescheduleUpdate(); this.rescheduleUpdate();
return cb(null, req.responseText); return cb(null, req.responseText);
}; };
req.send(null); req.send(null);
}, },
applyCsv: function(csv) { generatePacFromCsv: function(csv) {
var pac = generatePac(csv); this.pac = chrome.extension.getBackgroundPage().generatePac(csv);
return this.pac;
},
applyPac: function(pac) {
var pac = pac || this.pac;
var config = { var config = {
mode: 'pac_script', mode: 'pac_script',
pacScript: { pacScript: {
@ -102,15 +183,18 @@ var Antizapret = {
} }
}; };
chrome.storage.local.clear();
RKN.syncWithStorage( () => RKN.updateIcon() );
chrome.runtime.onInstalled.addListener( details => { chrome.runtime.onInstalled.addListener( details => {
switch(details.reason) { switch(details.reason) {
case 'install': case 'install':
case 'update': case 'update':
Antizapret.checkForUpdates() RKN.install();
} }
}); });
chrome.browserAction.onClicked.addListener( tab => Antizapret.checkForUpdates() ); chrome.browserAction.onClicked.addListener( tab => {alert('!!');} );
//==============GENERATE-PACS.JS============================ //==============GENERATE-PACS.JS============================

View File

@ -1,14 +1,10 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Антизапрет", "name": "РосКомНадзор",
"description": "Безопасный Интернет от РосКомНадзор.", "description": "Безопасный Интернет от РосКомНадзор с возможностью отказаться.",
"version": "0.1", "version": "0.1",
"browser_action": {
"default_icon": "unlock.png",
"default_title": "Обсуждай на https://reddit.com/r/ru"
},
"permissions": [ "permissions": [
"proxy", "proxy",
"storage", "storage",
@ -18,14 +14,19 @@
"https://*/", "https://*/",
"ftp://*/" "ftp://*/"
], ],
"icons": { "16": "unlock.ico", "icons": {
"128": "unlock.png" }, "128": "./assets/icons/rkn.png"
},
"background": { "background": {
"scripts": ["background.js"], "scripts": ["background.js"],
"persistent": false "persistent": false
}, },
"browser_action": {
"default_popup": "./pages/popup.html"
},
"options_page": "./pages/options.html",
"author": "ilyaigpetrov@gmail.com", "author": "ilyaigpetrov@gmail.com",
"homepage_url": "https://github.com/ilyaigpetrov/antizapret-chrome-extension", "homepage_url": "https://github.com/ilyaigpetrov/consorship-free",
"short_name": "Антизапрет" "short_name": "Антизапрет"
} }

View File

@ -0,0 +1,45 @@
nl.drew.cp.lang.s['en'] = {
"msgOn":"on",
"msgOff":"off",
"allSites":"All Sites",
"thisSite":"This Site",
"listsTab":"Lists Sites",
"userProTab":"User proxys",
"proxyEnabled": "Proxy enabled for all sites",
"anonymityEnabled": "Enable anonymity for all sites",
"locationForAll": "Use proxy location for all sites:",
"torForAll": "TOR for all sites",
"notUseProxy":"Not use proxy for this site",
"alwUseProxy":"Always use proxy for this site",
"anonForSite":"Enable anonymity for this site",
"locSite":"Use proxy location for this site:",
"torForSite": "TOR for this site",
"setHttp":"Use proxy for https traffic",
"setHelp":"Tips enable",
"proxyOff": "proxy <b>off</b> for this site",
"proxyEnabledHelp": "if you disable this option, you will have access to all proxies, not just public and increases speed",
"anonymityEnabledHelp": "Anonymity allows you to hide your IP, but it also imposes some restrictions. Some sites may block the access because of anonymity.",
"locationForAllHelp": "If possible, the proxy will be chosen this country",
"notUseProxyHelp":"even if proxy is enabled for all sites",
"alwUseProxyHelp":"even if proxy is disabled for all sites",
"anonForSiteHelp":"only for this site",
"locSiteHelp":"",
"torAllHelp":"send all traffic through TOR",
"torSiteHelp":"send site traffic through TOR",
"EmptyURL":"Empty URL",
"WrongURLformat":"Wrong URL format",
"WrongURLprotocol":"Wrong URL protocol",
"ThisURLalreadyadded":"This URL already added",
"Nooptionschanged":"No options changed",
"interfaceLanguage":"Interface language",
"uProxyNameFormat": "Wrong format of the list name. Must consist of letters, digits and _-",
"uProxyNameAlreadyHave": "Already there is the proxy named ",
"errUproxyIpFormat": "Proxy is defined as IP:PORT, for example: <b>127.0.0.1:443</b> or <b>proxyname.example:1080</b>"
}

View File

@ -0,0 +1,11 @@
{
"chrome_extension_name": {
"message": "Proxy for Chrome"
},
"chrome_extension_description": {
"message": "Free proxy servers for you"
},
"browser_action_title": {
"message": "on/off"
}
}

View File

@ -0,0 +1,45 @@
nl.drew.cp.lang.s['ru'] = {
"msgOn":"вкл",
"msgOff":"выкл",
"allSites":"Все сайты",
"thisSite":"Текущий сайт",
"listsTab":"Списки сайтов",
"userProTab":"Мои прокси",
"proxyOff": "прокси <b>выкл.</b> для этого сайта",
"proxyEnabled": "Вкл. прокси для всех сайтов",
"anonymityEnabled": "Вкл. анонимность для всех сайтов",
"locationForAll": "Для всех сайтов использовать локацию:",
"torForAll": "Все сайты через TOR",
"notUseProxy":"Для этого сайта не использовать прокси",
"alwUseProxy":"Всегда использовать прокси для этого сайта",
"anonForSite":"Вкл. анонимность для этого сайта",
"locSite":"Для этого сайта использовать локацию:",
"torForSite": "Этот сайт через TOR",
"setHttp":"Использовать прокси для https протокола",
"setHelp":"Включить подсказки",
"locationForAllHelp": "По возможности будет выбран прокси этой страны",
"proxyEnabledHelp": "если отключить эту опцию, то будут доступны все прокси, а не только общественные, что может значительно увеличить скорость",
"anonymityEnabledHelp": "Анонимность позволяет скрыть свой IP, но одновременно накладывает некоторые ограничения. Некоторые сайты могут прекратить ваш доступ из-за анонимности.",
"notUseProxyHelp":"даже если прокси включен для всех сайтов",
"alwUseProxyHelp":"даже если прокси отключен для всех сайтов",
"anonForSiteHelp":"только для этого сайта",
"locSiteHelp":"",
"torAllHelp":"направить весь трафик через шлюз tor",
"torSiteHelp":"использовать tor для доступа к этому сайту",
"EmptyURL":"Поле URL пустое",
"WrongURLformat":"Неправильный формать URL",
"WrongURLprotocol":"Неправильный протокол URL",
"ThisURLalreadyadded":"Этот адрес уже добавлен",
"Nooptionschanged":"Нет измененных опций",
"interfaceLanguage":"Язык интерфейса",
"errUProxyNameFormat": "Имя прокси должно состоять из букв, цифр, тире и знака подчеркивания. От 3 до 9 символов",
"errUProxyNameAlreadyHave": "Уже есть прокси с именем ",
"errUproxyIpFormat": "Прокси задается в виде IP:PORT, например 127.0.0.1:443 или proxyname.example:1080"
}

View File

@ -0,0 +1,11 @@
{
"chrome_extension_name": {
"message": "Proxy for Chrome"
},
"chrome_extension_description": {
"message": "Бесплатные прокси сервера для вашего браузера"
},
"browser_action_title": {
"message": "babyList - вкл/выкл"
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="js/core/vars.js"></script>
<script type="text/javascript" charset="utf-8" src="js/lib/ls.js"></script>
<script type="text/javascript" charset="utf-8" src="js/lib/lib.js"></script>
<script type="text/javascript" charset="utf-8" src="js/lib/icoanimation.js"></script>
<script type="text/javascript" charset="utf-8" src="js/core/conf.js"></script>
<script type="text/javascript" charset="utf-8" src="js/core/proxy.js"></script>
<script type="text/javascript" charset="utf-8" src="js/core/api.js"></script>
<script type="text/javascript" charset="utf-8" src="js/core/lib.js"></script>
<script type="text/javascript" charset="utf-8" src="js/core/interf.js"></script>
<script type="text/javascript" charset="utf-8" src="js/core/header.js"></script>
<script type="text/javascript" charset="utf-8" src="js/core/cache.js"></script>
<script type="text/javascript" charset="utf-8" src="js/core/core.js"></script>
</head>
<body>
<img src="im/ico19-2.png"/>
<img src="im/ico19g-2.png"/>
<img src="im/co/ru.png"/>
<img src="im/co/de.png"/>
<img src="im/co/uk.png"/>
<img src="im/co/fr.png"/>
<img src="im/co/nl.png"/>
</body>
</html>

View File

@ -0,0 +1,245 @@
div#foot {
position: absolute;
bottom: 0;
display: block;
width: 100%;
margin-bottom: 5px;
padding-top: 5px;
}
.cp-os-light {
font-family: 'Open Sans', sans-serif;
font-weight: 300;
}
.cp-os {
font-family: 'Open Sans', sans-serif;
font-weight: 400;
}
.cp-os-bold {
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
.cp-os-condensed {
font-family: 'Open Sans Condensed', sans-serif;
font-weight: 300;
}
.cp-os-condensed-bold {
font-family: 'Open Sans Condensed', sans-serif;
font-weight: 700;
}
.cp-pointer {
cursor: pointer;
}
.cp-pointer:hover {
color: #777777;
}
#mainproxy {
font-size: 14px;
}
td#mainproxyco {
width: 44px;
}
#mainproxyco img {
height: 28px;
width: 42px;
box-shadow: 0 0 1px 1px #dfdfdf;
}
#listtable img {
width: 20px;
}
#hideip img {
height: 30px;
}
.uk-text-success {
color: #5B7900;
}
.uk-tab li {
font-family: 'Open Sans', sans-serif;
font-weight: 700;
font-size: 12px;
}
#configproxy > li {
padding: 20px 20px 20px 15px;
}
#configproxy > li.uk-active {
background-color: #fff;
}
a, .uk-tab > li > a {
color: #006D9A;
}
#flags-all, #flags-site {
position: relative;
}
.cp-flags {
display: none;
position: relative;
}
.cp-uproxy {
padding-left: 7px;
display: inline-block;
*display: inline;
*zoom: 1;
}
.cp-uproxy > div {
}
.cp-flag {
cursor: pointer;
display: inline-block;
*display: inline;
*zoom: 1;
background-color: #fff;
border: 1px solid #fff;
border-radius: 3px;
padding: 5px 5px 5px 5px;
-webkit-transition: background-color 0.3s;
transition: background-color 0.3s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.cp-flag img {
margin: 0;
padding: 0;
width: 32px;
box-shadow: 0 0 2px 1px #efefef;
}
label img {
margin: 0;
padding: 0;
width: 22px;
box-shadow: 0 0 2px 1px #d0d0d0;
}
.cp-flag:hover {
border: 1px solid #ccc;
box-shadow: 0 0 2px 1px #dfdfdf;
}
.cp-flag.is-active {
border: 1px solid #fff;
background: #B8BDC6;
/*
background: -webkit-radial-gradient(center, ellipse cover, #ffffff 0%, #646473 200%);
*/
}
.cp-uproxy.is-active {
}
.cp-flag.is-active:after, .cp-uproxy.is-active:after {
font-family: FontAwesome;
content: "\f058";
position: absolute;
margin-left: -22px;
top: 26px;
color: #80A000;
}
tr, td, table {
border: 0px solid #da314b;
}
.cp-uppercase {
text-transform: uppercase;
}
::selection {
background: #006D9A;
}
.uk-form {
font-size: 11px;
}
.cp-newhost input {
margin-left: -3px;
}
.uk-form input[type="text"] {
height: 23px;
}
td.cp-act {
width: 54px;
}
.cp-pname, .cp-pproto {
font-size: 14px;
}
.cp-pip {
font-weight: bold;
font-size: 12px;
}
.cp-pproto select {
height: 23px;
}
#addproxy {
font-size: 24px;
margin-right: 18px;
}
.uk-badge {
background: #006D9A;
}
.uk-badge a {
color: #fff;
}
.uk-dropdown {
width: 200px;
}
.uk-dropdown-scrollable {
max-height: 140px;
}
.cp-vspace {
height: 7px;
padding: 0;
margin: 0;
}
.cp-unvis {
visibility: hidden;
}
.uk-scrollable-text {
max-height: 300px;
min-height: 100px;
height: auto;
}

View File

@ -0,0 +1,99 @@
/*! UIkit 2.12.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/* ========================================================================
Component: Notify
========================================================================== */
/*
* Message container for positioning
*/
.uk-notify {
position: fixed;
top: 10px;
left: 10px;
z-index: 1040;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 350px;
}
/* Position modifiers
========================================================================== */
.uk-notify-top-right,
.uk-notify-bottom-right {
left: auto;
right: 10px;
}
.uk-notify-top-center,
.uk-notify-bottom-center {
left: 50%;
margin-left: -175px;
}
.uk-notify-bottom-left,
.uk-notify-bottom-right,
.uk-notify-bottom-center {
top: auto;
bottom: 10px;
}
/* Responsiveness
========================================================================== */
/* Phones portrait and smaller */
@media (max-width: 479px) {
/*
* Fit in small screen
*/
.uk-notify {
left: 10px;
right: 10px;
width: auto;
margin: 0;
}
}
/* Sub-object: `uk-notify-message`
========================================================================== */
.uk-notify-message {
position: relative;
margin-bottom: 10px;
padding: 15px;
background: #444444;
color: #ffffff;
font-size: 16px;
line-height: 22px;
cursor: pointer;
border: 1px solid #444444;
border-radius: 4px;
}
/* Close in notify
========================================================================== */
.uk-notify-message > .uk-close {
visibility: hidden;
float: right;
}
.uk-notify-message:hover > .uk-close {
visibility: visible;
}
/* Modifier: `uk-alert-info`
========================================================================== */
.uk-notify-message-primary {
background: #ebf7fd;
color: #2d7091;
border-color: rgba(45, 112, 145, 0.3);
}
/* Modifier: `uk-alert-success`
========================================================================== */
.uk-notify-message-success {
background: #f2fae3;
color: #659f13;
border-color: rgba(101, 159, 19, 0.3);
}
/* Modifier: `uk-notify-message-warning`
========================================================================== */
.uk-notify-message-warning {
background: #fffceb;
color: #e28327;
border-color: rgba(226, 131, 39, 0.3);
}
/* Modifier: `uk-notify-message-danger`
========================================================================== */
.uk-notify-message-danger {
background: #fff1f0;
color: #d85030;
border-color: rgba(216, 80, 48, 0.3);
}

View File

@ -0,0 +1,123 @@
/* jquery.switcher - 1.2.4
* https://github.com/djanix/jquery-switcher
* Copyright (c) 2014-11-04 - */
.switcher {
cursor: pointer;
/*
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
*/
font-size: 12px;
text-transform: uppercase;
display: inline-block;
*display: inline;
*zoom: 1;
}
.switcher .content {
position: relative;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.switcher .text {
display: none;
overflow: hidden;
text-align: center;
white-space: nowrap;
}
.switcher.is-disabled {
opacity: 0.4;
}
.switcher.default {
background-color: #efeff0;
border: 1px solid #eee;
border-radius: 4px;
line-height: 26px;
min-width: 80px;
padding: 2px;
-webkit-transition: background-color 0.3s;
transition: background-color 0.3s;
margin: 4px 6px 0px 0px;
}
.switcher.default input {
display: none;
}
.switcher.default .slider {
background-color: white;
border-radius: 4px;
-webkit-box-shadow: 0 0 2px 1px #dfdfdf;
box-shadow: 0 0 2px 1px #dfdfdf;
height: 26px;
left: 0;
position: absolute;
top: 0;
-webkit-transform: translateX(0%);
-ms-transform: translateX(0%);
transform: translateX(0%);
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
width: 50%;
z-index: 2;
}
.switcher.default .text {
width: 50%;
display: inline-block;
*display: inline;
*zoom: 1;
}
.switcher.default .textYes {
color: white;
float: left;
}
.switcher.default .textNo {
color: #9f9f9f;
float: right;
}
.switcher.default.is-active {
background-color: #80A000;
}
.switcher.default.is-active .slider {
-webkit-transform: translateX(100%);
-ms-transform: translateX(100%);
transform: translateX(100%);
}
.switcher.short {
cursor: pointer;
display: inline-block;
margin-right: 5px;
vertical-align: middle;
margin-bottom: 3px;
}
.switcher.short input {
display: none;
}
.switcher.short .content {
border: 1px solid #aaaaaa;
border-radius: 50%;
height: 18px;
padding: 0;
width: 18px;
}
.switcher.short .slider {
background-color: #519b20;
border-radius: 50%;
height: 12px;
margin: 3px;
opacity: 0;
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
-webkit-transition: all 0.2s;
transition: all 0.2s;
width: 12px;
}
.switcher.short.is-active .slider {
opacity: 1;
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,509 @@
nl.drew.cp.core.api = function() {
var api = {port:null};
api.handling = function(port, msg) {
var lid;
nl.drew.cp.core.api.port = port;
if (msg.msg == "log") {
nl.drew.cp.lib.debug(msg.param);
} else {
if (msg.msg == "on") {
nl.drew.cp.core.main.start(true);
nl.drew.cp.core.cache.nowProxyAllClean();
} else {
if (msg.msg == "off") {
nl.drew.cp.core.main.stop();
nl.drew.cp.core.cache.nowProxyAllClean();
} else {
if (msg.msg == "icoupd") {
nl.drew.cp.core.interf.icoupdate2();
} else {
if (msg.msg == "set") {
if (msg.param == "https") {
if (typeof msg.val != "undefined") {
nl.drew.cp.state.https = msg.val;
nl.drew.cp.ls.set("https", nl.drew.cp.state.https, false);
}
} else {
if (msg.param == "uproxyremove") {
if (typeof msg.val != "undefined" && typeof msg.val.co != "undefined" && msg.val.co) {
var delUproxyList = nl.drew.cp.core.lib.inUproxyList(msg.val.co);
if (delUproxyList > -1) {
nl.drew.cp.state.uproxys.splice(delUproxyList, 1);
nl.drew.cp.ls.set("uproxys", nl.drew.cp.state.uproxys, false);
nl.drew.cp.core.cache.nowProxyAllClean();
nl.drew.cp.core.filter.inst();
}
}
} else {
if (msg.param == "uproxy") {
if (typeof msg.val != "undefined" && typeof msg.val.oldname != "undefined" && msg.val.oldname) {
var i = nl.drew.cp.core.lib.inUproxyList(msg.val.oldname);
var newname = msg.val.proto.toUpperCase() + " " + msg.val.ip + ":" + msg.val.port;
if (i > -1) {
nl.drew.cp.state.uproxys[i].co = msg.val.co;
nl.drew.cp.state.uproxys[i].proto = msg.val.proto;
nl.drew.cp.state.uproxys[i].ip = msg.val.ip;
nl.drew.cp.state.uproxys[i].port = msg.val.port;
nl.drew.cp.state.uproxys[i].name = newname;
nl.drew.cp.state.uproxys[i].off = msg.val.hasOwnProperty("off") ? msg.val.off : nl.drew.cp.state.uproxys[i].off;
if (nl.drew.cp.state.listContrySite.hasOwnProperty(msg.val.oldname)) {
nl.drew.cp.state.listContrySite[msg.val.co] = nl.drew.cp.lib.clone(nl.drew.cp.state.listContrySite[msg.val.oldname]);
delete nl.drew.cp.state.listContrySite[msg.val.oldname];
}
} else {
nl.drew.cp.state.uproxys.push({ip:msg.val.ip, port:msg.val.port, sport:"", proto:msg.val.proto, co:msg.val.co, name:newname, off:msg.val.hasOwnProperty("off") ? msg.val.off : false});
}
nl.drew.cp.core.cache.nowProxyAllClean();
nl.drew.cp.ls.set("uproxys", nl.drew.cp.state.uproxys, false);
nl.drew.cp.core.filter.inst();
}
} else {
if (msg.param == "liston") {
if (typeof msg.val != "undefined") {
nl.drew.cp.core.lib.liston(msg.val);
nl.drew.cp.core.api.postMessage({param:"lists", val:nl.drew.cp.core.lib.globalListGen()});
}
} else {
if (msg.param == "listoff") {
if (typeof msg.val != "undefined") {
nl.drew.cp.core.lib.listoff(msg.val);
}
} else {
if (msg.param == "listonrest") {
if (typeof msg.val != "undefined") {
nl.drew.cp.core.lib.liston(msg.val, true);
}
} else {
if (msg.param == "listonremove") {
if (typeof msg.val != "undefined") {
var nosend = false;
if (typeof msg.val.nosend != "undefined") {
nosend = msg.val.nosend;
}
nl.drew.cp.core.lib.listoff(msg.val.host, true, nosend);
}
} else {
if (msg.param == "listoffrest") {
if (typeof msg.val != "undefined") {
if (nl.drew.cp.core.lib.inOffSiteListAllParam(msg.val) == -1) {
nl.drew.cp.state.offlist.push(msg.val);
}
}
nl.drew.cp.core.cache.nowProxyClean({host:msg.val});
} else {
if (msg.param == "listoffremove") {
if (typeof msg.val != "undefined") {
lid = nl.drew.cp.core.lib.inOffSiteListAllParam(msg.val);
if (lid == -1) {
return;
}
nl.drew.cp.state.offlist.splice(lid, 1);
nl.drew.cp.ls.set("offlist", nl.drew.cp.state.offlist, false);
nl.drew.cp.core.cache.nowProxyClean({host:msg.val});
}
} else {
if (msg.param == "globalalwproxy") {
if (typeof msg.val != "undefined") {
nl.drew.cp.state.alwProxy = msg.val;
nl.drew.cp.ls.set("globalalwproxy", nl.drew.cp.state.alwProxy, false);
nl.drew.cp.core.cache.nowProxyAllClean();
nl.drew.cp.core.filter.inst();
}
} else {
if (msg.param == "contrymain") {
if (typeof msg.val != "undefined" && msg.val) {
nl.drew.cp.state.contryMain = msg.val;
nl.drew.cp.ls.set("contrymain", nl.drew.cp.state.contryMain, false);
nl.drew.cp.core.cache.nowProxyAllClean();
nl.drew.cp.core.filter.inst();
}
} else {
if (msg.param == "tor") {
if (typeof msg.val != "undefined") {
if (typeof msg.val.all != "undefined") {
nl.drew.cp.state.torAll = msg.val.all;
nl.drew.cp.ls.set("torall", nl.drew.cp.state.torAll, false);
}
nl.drew.cp.core.api.sendtoPortAnonymitynow();
}
} else {
if (msg.param == "torsite") {
if (typeof msg.val != "undefined" && typeof msg.val.host != "undefined" && msg.val.host) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
if ((typeof msg.val.list == "undefined" || !msg.val.list) && (!purl.allow || msg.val.host != purl.host)) {
return;
}
if (msg.val.val) {
if (nl.drew.cp.core.lib.inTorSiteList(msg.val.host) > -1) {
return;
}
nl.drew.cp.state.listTorSite.push(msg.val.host);
} else {
var ind = nl.drew.cp.core.lib.inTorSiteList(msg.val.host);
if (ind == -1) {
return;
}
nl.drew.cp.state.listTorSite.splice(ind, 1);
}
nl.drew.cp.ls.set("torSite", nl.drew.cp.state.listTorSite, false);
nl.drew.cp.core.interf.icoupdate7(tab.url);
nl.drew.cp.core.api.sendtoPortAnonymitynow(msg.val);
});
}
} else {
if (msg.param == "anonymity") {
if (typeof msg.val != "undefined") {
if (typeof msg.val.all != "undefined") {
nl.drew.cp.state.anonymityAll = msg.val.all;
nl.drew.cp.ls.set("anonymityall", nl.drew.cp.state.anonymityAll, false);
}
nl.drew.cp.core.api.sendtoPortAnonymitynow();
}
} else {
if (msg.param == "anonymitysite") {
if (typeof msg.val != "undefined" && typeof msg.val.host != "undefined" && msg.val.host) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
if ((typeof msg.val.list == "undefined" || !msg.val.list) && (!purl.allow || msg.val.host != purl.host)) {
return;
}
if (msg.val.val) {
if (nl.drew.cp.core.lib.inAnSiteList(msg.val.host) > -1) {
return;
}
nl.drew.cp.state.listAnSite.push(msg.val.host);
} else {
var ind = nl.drew.cp.core.lib.inAnSiteList(msg.val.host);
if (ind == -1) {
return;
}
nl.drew.cp.state.listAnSite.splice(ind, 1);
}
lid = nl.drew.cp.core.lib.checkListOnOff(msg.val.host);
if (lid > -1) {
nl.drew.cp.state.offlist.splice(lid, 1);
}
nl.drew.cp.ls.set("anSite", nl.drew.cp.state.listAnSite, false);
var nosend = false;
if (typeof msg.val.nosend != "undefined") {
nosend = msg.val.nosend;
}
if (!nosend) {
nl.drew.cp.core.api.sendtoPortAnonymitynow(msg.val);
}
nl.drew.cp.core.api.sendList(msg.val.listRequest, msg.val.host);
});
}
} else {
if (msg.param == "nonproxy") {
if (typeof msg.val != "undefined" && typeof msg.val.host != "undefined" && msg.val.host) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
nl.drew.cp.core.cache.nowProxyClean(purl);
if ((typeof msg.val.list == "undefined" || !msg.val.list) && (!purl.allow || msg.val.host != purl.host)) {
return;
}
if (msg.val.val) {
if (nl.drew.cp.core.lib.inNonProxySiteList(msg.val.host) > -1) {
return;
}
nl.drew.cp.state.listNonProxySite.push(msg.val.host);
var ind = nl.drew.cp.core.lib.inAlwProxySiteList(msg.val.host);
if (ind > -1) {
nl.drew.cp.state.listAlwProxySite.splice(ind, 1);
}
} else {
var ind = nl.drew.cp.core.lib.inNonProxySiteList(msg.val.host);
if (ind == -1) {
return;
}
nl.drew.cp.state.listNonProxySite.splice(ind, 1);
}
lid = nl.drew.cp.core.lib.checkListOnOff(msg.val.host);
if (lid > -1) {
nl.drew.cp.state.offlist.splice(lid, 1);
}
nl.drew.cp.ls.set("alwProxySite", nl.drew.cp.state.listAlwProxySite, false);
nl.drew.cp.ls.set("nonProxySite", nl.drew.cp.state.listNonProxySite, false);
nl.drew.cp.core.filter.inst();
var nosend = false;
if (typeof msg.val.nosend != "undefined") {
nosend = msg.val.nosend;
}
if (!nosend) {
nl.drew.cp.core.api.sendtoPortInProxyList(msg.val);
}
nl.drew.cp.core.api.sendList(msg.val.listRequest, msg.val.host);
});
}
} else {
if (msg.param == "alwproxy") {
if (typeof msg.val != "undefined" && typeof msg.val.host != "undefined" && msg.val.host) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
nl.drew.cp.core.cache.nowProxyClean(purl);
if ((typeof msg.val.list == "undefined" || !msg.val.list) && (!purl.allow || msg.val.host != purl.host)) {
return;
}
if (msg.val.val) {
if (nl.drew.cp.core.lib.inAlwProxySiteListEqually(msg.val.host) > -1) {
return;
}
nl.drew.cp.state.listAlwProxySite.push(msg.val.host);
var ind = nl.drew.cp.core.lib.inNonProxySiteList(msg.val.host);
if (ind > -1) {
nl.drew.cp.state.listNonProxySite.splice(ind, 1);
}
} else {
var ind = nl.drew.cp.core.lib.inAlwProxySiteListEqually(msg.val.host);
if (ind == -1) {
return;
}
nl.drew.cp.state.listAlwProxySite.splice(ind, 1);
}
lid = nl.drew.cp.core.lib.checkListOnOff(msg.val.host);
if (lid > -1) {
nl.drew.cp.state.offlist.splice(lid, 1);
}
nl.drew.cp.ls.set("alwProxySite", nl.drew.cp.state.listAlwProxySite, false);
nl.drew.cp.ls.set("nonProxySite", nl.drew.cp.state.listNonProxySite, false);
nl.drew.cp.core.filter.inst();
var nosend = false;
if (typeof msg.val.nosend != "undefined") {
nosend = msg.val.nosend;
}
if (!nosend) {
nl.drew.cp.core.api.sendtoPortInProxyList(msg.val);
}
nl.drew.cp.core.api.sendList(msg.val.listRequest, msg.val.host);
});
}
} else {
if (msg.param == "contrysite") {
if (typeof msg.val != "undefined" && typeof msg.val.host != "undefined" && msg.val.host) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
nl.drew.cp.core.cache.nowProxyClean(purl);
if ((typeof msg.val.list == "undefined" || !msg.val.list) && (!purl.allow || msg.val.host != purl.host)) {
return;
}
var key = msg.val.val;
if (key != "main") {
nl.drew.cp.core.lib.delContrySiteList(msg.val.host);
if (typeof nl.drew.cp.state.listContrySite[key] == "undefined") {
nl.drew.cp.state.listContrySite[key] = [];
}
nl.drew.cp.state.listContrySite[key].push(msg.val.host);
} else {
nl.drew.cp.core.lib.delContrySiteList(msg.val.host);
}
lid = nl.drew.cp.core.lib.checkListOnOff(msg.val.host);
if (lid > -1) {
nl.drew.cp.state.offlist.splice(lid, 1);
}
nl.drew.cp.ls.set("contrySiteList", nl.drew.cp.state.listContrySite, false);
nl.drew.cp.core.proxy.getNowProxy(null, purl, true, true);
nl.drew.cp.core.filter.inst();
var nosend = false;
if (typeof msg.val.nosend != "undefined") {
nosend = msg.val.nosend;
}
if (!nosend) {
nl.drew.cp.core.api.sendtoPortInProxyList(msg.val);
if (typeof msg.val.list != "undefined" && msg.val.list) {
nl.drew.cp.core.api.sendtoPortContrys(msg.val);
}
nl.drew.cp.core.api.sendtoPortAnonymitynow(msg.val);
}
nl.drew.cp.core.api.sendList(msg.val.listRequest, msg.val.host);
});
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
} else {
if (msg.msg == "get") {
if (msg.param == "https") {
port.postMessage({param:"https", val:nl.drew.cp.state.https});
} else {
if (msg.param == "globalalwproxy") {
port.postMessage({param:"globalalwproxy", val:nl.drew.cp.state.alwProxy});
} else {
if (msg.param == "isenabled") {
port.postMessage({param:"isenabled", val:nl.drew.cp.state.isenabled});
} else {
if (msg.param == "state") {
port.postMessage({param:"state", val:nl.drew.cp.state.state});
} else {
if (msg.param == "uproxy") {
port.postMessage({param:"uproxy", val:{uproxy:nl.drew.cp.state.uproxys, template:nl.drew.cp.config.proxyTemplate}});
} else {
if (msg.param == "mainproxy") {
nl.drew.cp.core.api.sendtoPortMainproxy();
} else {
if (msg.param == "contrys") {
nl.drew.cp.core.api.sendtoPortContrys(msg.val);
} else {
if (msg.param == "anonymity") {
nl.drew.cp.core.api.sendtoPortAnonymity(msg.val);
} else {
if (msg.param == "anonymitynow") {
nl.drew.cp.core.api.sendtoPortAnonymitynow(msg.val);
} else {
if (msg.param == "tor") {
nl.drew.cp.core.api.sendtoPortTor(msg.val);
} else {
if (msg.param == "nonproxyalwproxy") {
nl.drew.cp.core.api.sendtoPortInProxyList(msg.val);
} else {
if (msg.param == "lists") {
nl.drew.cp.core.api.sendList(true);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
};
api.sendList = function(isSend, host) {
if (!isSend) {
return;
}
nl.drew.cp.core.api.postMessage({param:"lists", val:nl.drew.cp.core.lib.globalListGen(), host:host});
};
api.sendtoPortInProxyList = function(val) {
if (nl.drew.cp.core.api.port) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
purl.host = nl.drew.cp.core.api.preSendtoPort(val, purl);
nl.drew.cp.core.api.postMessage({param:"nonproxyalwproxy", val:{host:purl.host, nonproxy:nl.drew.cp.core.lib.inNonProxySiteList(purl.host), alwproxy:nl.drew.cp.core.lib.inAlwProxySiteList(purl.host)}});
});
}
};
api.sendtoPortAnonymitynow = function(val) {
if (nl.drew.cp.core.api.port) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
purl.host = nl.drew.cp.core.api.preSendtoPort(val, purl);
var nowProxy = nl.drew.cp.core.proxy.getNowProxy(null, purl, true, true);
if (nowProxy && nowProxy.co.length > 2) {
nl.drew.cp.core.api.postMessage({param:"anonymitynow", val:[false, false]});
} else {
nl.drew.cp.core.api.postMessage({param:"anonymitynow", val:[nl.drew.cp.core.header.getAnonymityNow(purl.host), nl.drew.cp.core.header.getTorNow(purl.host)]});
}
nl.drew.cp.core.interf.icoupdate7(tab.url);
});
}
};
api.sendtoPortAnonymity = function(val) {
if (nl.drew.cp.core.api.port) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
purl.host = nl.drew.cp.core.api.preSendtoPort(val, purl);
nl.drew.cp.core.api.postMessage({param:"anonymity", val:nl.drew.cp.core.header.getAnonymity(purl.host)});
});
}
};
api.sendtoPortTor = function(val) {
if (nl.drew.cp.core.api.port) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
purl.host = nl.drew.cp.core.api.preSendtoPort(val, purl);
nl.drew.cp.core.api.postMessage({param:"tor", val:nl.drew.cp.core.header.getTor(purl.host)});
});
}
};
api.sendtoPortState = function() {
nl.drew.cp.core.api.postMessage({param:"state", val:nl.drew.cp.state.state});
};
api.sendtoPortMainproxy = function(nowProxys) {
if (nl.drew.cp.core.api.port) {
chrome.tabs.getSelected(null, function(tab) {
if (nl.drew.cp.state.started) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
var nowProxy = {};
if (nl.drew.cp.state.alwProxy) {
nowProxy = {name:"&nbsp; proxy server", co:"public", allow:true};
} else {
nowProxy = nl.drew.cp.core.proxy.getNowProxy(nowProxys, purl, true, true);
}
if (purl.allow && nowProxy == null) {
nowProxy = {host:purl.host};
}
nl.drew.cp.core.interf.icoupdate7(tab.url);
nl.drew.cp.core.api.sendtoPort({param:"mainproxy", val:nowProxy});
} else {
nl.drew.cp.core.api.postMessage({param:"mainproxy", val:false});
}
});
}
};
api.sendtoPortContrys = function(val) {
if (nl.drew.cp.core.api.port) {
chrome.tabs.getSelected(null, function(tab) {
var purl = nl.drew.cp.lib.parseUrl(tab.url);
purl.host = nl.drew.cp.core.api.preSendtoPort(val, purl);
nl.drew.cp.core.api.postMessage({param:"contrys", val:{contrys:nl.drew.cp.state.contrys, uproxys:nl.drew.cp.state.uproxys, contrymain:nl.drew.cp.state.contryMain, contrysite:nl.drew.cp.core.lib.inContrySiteList(purl.host), host:purl.host}});
});
}
};
api.preSendtoPort = function(val, purl) {
if ((!val || typeof val.list == "undefined" || !val.list) && !purl.allow) {
return "";
} else {
if (val && typeof val.list != "undefined" && val.list) {
return val.host;
} else {
if (!val || typeof val.host == "undefined" || !val.host) {
return purl.host;
} else {
if (val.host != purl.host) {
return "";
}
}
}
}
return purl.host;
};
api.sendtoPort = function(msg) {
nl.drew.cp.core.api.postMessage(msg);
};
api.postMessage = function(msg) {
if (nl.drew.cp.core.api.port) {
try {
nl.drew.cp.core.api.port.postMessage(msg);
} catch (err) {
}
}
};
return api;
}();

View File

@ -0,0 +1,13 @@
nl.drew.cp.core.cache = function() {
var cache = {};
cache.nowProxyAllClean = function() {
nl.drew.cp.state.nowProxyCache = {};
};
cache.nowProxyClean = function(purl) {
if (typeof purl.host != "undefined" && purl.host) {
delete nl.drew.cp.state.nowProxyCache[purl.host];
}
};
return cache;
}();

View File

@ -0,0 +1,185 @@
nl.drew.cp.core.conf = function() {
var conf = {};
conf.getApiUrl = function() {
if (nl.drew.cp.ls.isset("conf")) {
var conf = nl.drew.cp.ls.get("conf");
if (conf) {
if (typeof conf.Apiurl != "undefined" && conf.Apiurl.length > 0) {
nl.drew.cp.config.apiurl = conf.Apiurl;
}
if (typeof conf.Apiext != "undefined" && conf.Apiext.length > 0) {
nl.drew.cp.config.apiext = conf.Apiext;
}
if (typeof conf.Apiind != "undefined" && conf.Apiind.length > 0) {
nl.drew.cp.config.apiind = conf.Apiind;
}
if (typeof conf.Apidop != "undefined" && conf.Apidop.length > 0) {
nl.drew.cp.config.apidop = conf.Apidop;
}
}
}
var ret = new Array;
var uriapi;
for (var i in nl.drew.cp.config.apiurl) {
for (var j in nl.drew.cp.config.apiext) {
for (var k in nl.drew.cp.config.apiind) {
uriapi = nl.drew.cp.config.apiurl[i] + nl.drew.cp.config.apiind[k] + "." + nl.drew.cp.config.apiext[j];
ret.push("https://" + uriapi + "/");
}
}
}
nl.drew.cp.state.allApiUrls = ret;
nl.drew.cp.state.allApiUrls = nl.drew.cp.state.allApiUrls.concat(nl.drew.cp.config.apidop);
};
conf.preLoadConfigFromServer = function(callback) {
if (!nl.drew.cp.state.isenabled) {
if (callback != null) {
callback();
}
return;
}
nl.drew.cp.state.loadConfigFailCount = 0;
var allapiurlsLen = nl.drew.cp.state.allApiUrls.length;
if (allapiurlsLen < 1) {
nl.drew.cp.lib.debug("+++++++ crome-proxy +++++++ no api urls");
return null;
}
var ind = Math.random() * allapiurlsLen;
ind = ind ^ 0;
nl.drew.cp.state.apiUrl = nl.drew.cp.state.allApiUrls[ind];
conf.loadConfigFromServer(callback, ind);
};
conf.loadLocalConfig = function() {
if (nl.drew.cp.ls.isset("isenabled")) {
nl.drew.cp.state.isenabled = nl.drew.cp.ls.get("isenabled", false);
} else {
nl.drew.cp.state.isenabled = nl.drew.cp.config.isenabled;
}
if (nl.drew.cp.state.isenabled) {
if (nl.drew.cp.ls.isset("authHeader") && nl.drew.cp.ls.isset("authHeaderEnd")) {
nl.drew.cp.state.authHeader = nl.drew.cp.ls.get("authHeader", "96W3tAJeY40DufpX");
nl.drew.cp.state.authHeaderEnd = nl.drew.cp.ls.get("authHeaderEnd", false);
}
if (nl.drew.cp.ls.isset("contrymain")) {
var contrymain = nl.drew.cp.ls.get("contrymain", false);
if (contrymain) {
nl.drew.cp.state.contryMain = contrymain;
}
}
if (nl.drew.cp.ls.isset("globalalwproxy")) {
nl.drew.cp.state.alwProxy = nl.drew.cp.ls.get("globalalwproxy", false);
}
if (nl.drew.cp.ls.isset("anonymityall")) {
nl.drew.cp.state.anonymityAll = nl.drew.cp.ls.get("anonymityall", false);
}
if (nl.drew.cp.ls.isset("contrySiteList")) {
nl.drew.cp.state.listContrySite = nl.drew.cp.ls.get("contrySiteList", false);
}
if (nl.drew.cp.ls.isset("alwProxySite")) {
nl.drew.cp.state.listAlwProxySite = nl.drew.cp.ls.get("alwProxySite", false);
}
if (nl.drew.cp.ls.isset("nonProxySite")) {
nl.drew.cp.state.listNonProxySite = nl.drew.cp.ls.get("nonProxySite", false);
}
if (nl.drew.cp.ls.isset("anSite")) {
nl.drew.cp.state.listAnSite = nl.drew.cp.ls.get("anSite", false);
}
if (nl.drew.cp.ls.isset("torSite")) {
nl.drew.cp.state.listTorSite = nl.drew.cp.ls.get("torSite", false);
}
if (nl.drew.cp.ls.isset("offlist")) {
nl.drew.cp.state.offlist = nl.drew.cp.ls.get("offlist", false);
}
if (nl.drew.cp.ls.isset("uproxys")) {
nl.drew.cp.state.uproxys = nl.drew.cp.ls.get("uproxys", false);
}
nl.drew.cp.core.proxy.loadLocalProxy();
}
};
conf.clearConfigTimer = function() {
if (nl.drew.cp.state.loadConfigUpdTimer) {
clearTimeout(nl.drew.cp.state.loadConfigUpdTimer);
nl.drew.cp.state.loadConfigUpdTimer = null;
}
};
conf.startConfigTimer = function(callback) {
nl.drew.cp.state.loadConfigUpdTimer = setTimeout(function startLoadConfig() {
nl.drew.cp.core.conf.preLoadConfigFromServer(callback);
}, nl.drew.cp.config.loadConfigUpdT);
};
conf.startConfigTimer3 = function() {
nl.drew.cp.state.loadConfigUpdTimer = setTimeout(function startLoadConfig() {
nl.drew.cp.core.conf.loadConfigFromServer();
}, nl.drew.cp.config.loadConfigUpdT3);
};
conf.loadConfigFromServer = function(callback, ind) {
var apiUrl = nl.drew.cp.state.apiUrl;
if (!apiUrl) {
nl.drew.cp.lib.debug("+++++++ crome-proxy +++++++ no api url");
return null;
}
var onFail = function() {
var allapiurlsLen = nl.drew.cp.state.allApiUrls.length;
nl.drew.cp.state.loadConfigFailCount++;
if (ind !== null) {
ind++;
if (ind >= allapiurlsLen) {
ind = 0;
}
nl.drew.cp.state.apiUrl = nl.drew.cp.state.allApiUrls[ind];
if (nl.drew.cp.state.loadConfigFailCount >= allapiurlsLen) {
nl.drew.cp.state.loadConfigFailCountt = 0;
conf.loadConfigFromServer(callback, null);
nl.drew.cp.core.interf.icoupdate();
} else {
conf.loadConfigFromServer(callback, ind);
}
return null;
} else {
nl.drew.cp.core.conf.clearConfigTimer();
nl.drew.cp.core.conf.startConfigTimer(callback);
}
};
nl.drew.cp.lib.ReqJson(apiUrl + nl.drew.cp.config.api + "?crome-proxy-ywPHzueGrJX4vLYmC6Zj8TpotBacbgEf", 1E4, function(response) {
nl.drew.cp.core.conf.serverRespParse(response);
if (callback != null) {
callback();
}
nl.drew.cp.core.conf.clearConfigTimer();
nl.drew.cp.core.conf.startConfigTimer3();
}, onFail, onFail, "POST", "ip=" + encodeURIComponent(nl.drew.cp.state.ip) + "&s=" + encodeURIComponent(nl.drew.cp.state.lastUpdate) + "&sk=" + encodeURIComponent(nl.drew.cp.state.lastUpdateKey));
};
conf.serverRespParse = function(response) {
var responseJSON = {};
try {
responseJSON = JSON.parse(response);
} catch (e) {
nl.drew.cp.lib.debug("+++++++ crome-proxy +++++++ can't parse");
return null;
}
if (typeof responseJSON.Key != "undefined" && responseJSON.Key && typeof responseJSON.KeyD != "undefined" && typeof responseJSON.Now != "undefined") {
nl.drew.cp.state.authHeader = responseJSON.Key;
nl.drew.cp.state.authHeaderEnd = responseJSON.KeyD + (nl.drew.cp.lib.time() - responseJSON.Now);
nl.drew.cp.ls.set("authHeader", nl.drew.cp.state.authHeader, "96W3tAJeY40DufpX");
nl.drew.cp.ls.set("authHeaderEnd", nl.drew.cp.state.authHeaderEnd, false);
}
if (typeof responseJSON.Proxy != "undefined" && Object.prototype.toString.call(responseJSON.Proxy) === "[object Array]") {
nl.drew.cp.core.proxy.fromServerParser(responseJSON.Proxy);
} else {
if (typeof responseJSON.ProxyStat != "undefined") {
nl.drew.cp.core.proxy.setProxysCh(responseJSON.ProxyStat);
nl.drew.cp.core.proxy.setMainProxys();
}
}
if (typeof responseJSON.Conf != "undefined" && responseJSON.Conf) {
}
if (typeof responseJSON.S != "undefined" && responseJSON.S) {
nl.drew.cp.state.lastUpdate = responseJSON.S;
}
if (typeof responseJSON.KeyD != "undefined" && responseJSON.KeyD) {
nl.drew.cp.state.lastUpdateKey = responseJSON.KeyD;
}
};
return conf;
}();

View File

@ -0,0 +1,118 @@
nl.drew.cp.core.main = function() {
var main = {};
main.firstStart = function() {
chrome.runtime.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
nl.drew.cp.core.api.handling(port, msg);
});
});
nl.drew.cp.state.icon = new iconAnimator("im/ico38-2.png");
nl.drew.cp.state.iconoff = new iconAnimator("im/ico19g-2.png");
chrome.tabs.onActivated.addListener(function onActTabs(info) {
nl.drew.cp.core.interf.icoupdate71(info.tabId);
});
chrome.webRequest.onCompleted.addListener(function onCompleted(details) {
if (details.url) {
nl.drew.cp.core.interf.icoupdate7(details.url);
}
}, {urls:["http://*/*", "https://*/*", "ftp://*/*", "file://*/*"], types:["main_frame"]});
nl.drew.cp.core.main.start();
};
main.onProxyError = function(details) {
if (details && typeof details.levelOfControl != "undefined" && details.levelOfControl != "controllable_by_this_extension" && details.levelOfControl != "controlled_by_this_extension") {
nl.drew.cp.state.started = null;
nl.drew.cp.core.main.started(false);
return false;
} else {
chrome.proxy.settings.get({"incognito":false}, function(details) {
if (details && typeof details.levelOfControl != "undefined" && details.levelOfControl != "controllable_by_this_extension" && details.levelOfControl != "controlled_by_this_extension") {
nl.drew.cp.state.started = null;
nl.drew.cp.core.main.started(false);
return false;
}
});
}
if (!nl.drew.cp.state.timerCheckProxy) {
nl.drew.cp.state.timerCheckProxy = setInterval(nl.drew.cp.core.main.onProxyError, 7E3);
}
};
main.start = function(needEnabled) {
chrome.proxy.settings.get({"incognito":false}, function(details) {
nl.drew.cp.core.main.onProxyError(details);
if (needEnabled) {
nl.drew.cp.state.isenabled = true;
nl.drew.cp.ls.set("isenabled", true, false);
}
if (nl.drew.cp.state.started !== null && !nl.drew.cp.state.started) {
nl.drew.cp.state.started = null;
nl.drew.cp.state.state = {text:"Starting...", cl:"uk-text-success", blink:true};
nl.drew.cp.core.api.sendtoPortState();
nl.drew.cp.core.conf.loadLocalConfig();
if (nl.drew.cp.state.isenabled) {
nl.drew.cp.core.header.inst();
var proxyObjKeys = Object.keys(nl.drew.cp.state.proxys);
if (proxyObjKeys.length > 1 && nl.drew.cp.state.authHeader.length > 0 && nl.drew.cp.state.authHeaderEnd > nl.drew.cp.lib.time()) {
nl.drew.cp.core.proxy.setMainProxys();
nl.drew.cp.core.filter.inst(function() {
nl.drew.cp.core.main.started(true);
nl.drew.cp.core.conf.getApiUrl();
nl.drew.cp.core.conf.preLoadConfigFromServer(function() {
nl.drew.cp.core.filter.inst(nl.drew.cp.core.interf.icoupdate71);
});
});
} else {
nl.drew.cp.core.conf.getApiUrl();
nl.drew.cp.core.conf.preLoadConfigFromServer(function() {
nl.drew.cp.core.proxy.setMainProxys();
nl.drew.cp.core.filter.inst(function() {
nl.drew.cp.core.main.started(true);
});
});
}
} else {
nl.drew.cp.core.main.started(false);
}
} else {
nl.drew.cp.core.interf.icoupdate();
}
});
};
main.stop = function() {
nl.drew.cp.state.isenabled = false;
nl.drew.cp.ls.set("isenabled", false, false);
if (nl.drew.cp.state.started !== null && nl.drew.cp.state.started) {
nl.drew.cp.state.started = null;
nl.drew.cp.core.filter.uninst(function() {
});
nl.drew.cp.core.header.uninst();
nl.drew.cp.core.main.started(false);
}
if (nl.drew.cp.state.timerCheckProxy) {
clearInterval(nl.drew.cp.state.timerCheckProxy);
}
nl.drew.cp.state.timerCheckProxy = null;
};
main.started = function(flag) {
if (flag) {
nl.drew.cp.state.state = {text:"Ok", cl:"uk-text-success", blink:false};
nl.drew.cp.core.api.sendtoPortState();
nl.drew.cp.state.started = true;
nl.drew.cp.core.interf.icoupdate71();
} else {
nl.drew.cp.state.state = {text:"Off", cl:"uk-text-muted", blink:false};
nl.drew.cp.core.api.sendtoPortState();
nl.drew.cp.core.api.sendtoPortContrys();
nl.drew.cp.core.interf.icoupdate();
nl.drew.cp.state.started = false;
nl.drew.cp.core.api.sendtoPortMainproxy();
}
};
return main;
}();
window.addEventListener("load", function load(event) {
window.removeEventListener("load", load, false);
setTimeout(nl.drew.cp.core.main.firstStart, 1);
}, false);
window.addEventListener("close", function load(event) {
}, false);

View File

@ -0,0 +1,96 @@
nl.drew.cp.core.header = function() {
var header = {};
header.inst = function() {
nl.drew.cp.core.header.uninst();
chrome.webRequest.onHeadersReceived.addListener(nl.drew.cp.core.header.onResponse, {urls:["http://*/*"]});
chrome.webRequest.onBeforeSendHeaders.addListener(nl.drew.cp.core.header.listener, {urls:["http://*/*"]}, ["requestHeaders", "blocking"]);
};
header.uninst = function() {
if (chrome.webRequest.onBeforeSendHeaders.hasListener(nl.drew.cp.core.header.listener)) {
chrome.webRequest.onBeforeSendHeaders.removeListener(nl.drew.cp.core.header.listener);
}
if (chrome.webRequest.onHeadersReceived.hasListener(nl.drew.cp.core.header.onResponse)) {
chrome.webRequest.onHeadersReceived.removeListener(nl.drew.cp.core.header.onResponse);
}
};
header.listener = function(details) {
var auth = "";
var name = "";
var purl = nl.drew.cp.lib.parseUrl(details.url);
if (!purl.allow) {
return{requestHeaders:details.requestHeaders};
}
var nowProxy = nl.drew.cp.core.proxy.getNowProxy(null, purl, true, false);
if (!nowProxy) {
return{requestHeaders:details.requestHeaders};
}
if (nowProxy.co.length == 2) {
name = "Proxy-Authorization";
if (nl.drew.cp.core.header.getTorNow(purl.host) || nl.drew.cp.state.alwProxy) {
auth = nl.drew.cp.state.authHeader[2];
} else {
if (nl.drew.cp.core.header.getAnonymityNow(purl.host)) {
auth = nl.drew.cp.state.authHeader[1];
} else {
auth = nl.drew.cp.state.authHeader[0];
}
}
} else {
if (nowProxy.ip == "proxy.googlezip.net" || nowProxy.ip == "compress.googlezip.net" || nowProxy.ip == "74.125.205.211") {
name = "Chrome-Proxy";
auth = nl.drew.cp.core.header.authGoogleHeader();
}
}
if (name) {
details.requestHeaders.push({name:name, value:auth});
}
return{requestHeaders:details.requestHeaders};
};
header.getAnonymityNow = function(host) {
var ret = false;
if (nl.drew.cp.state.anonymityAll) {
return true;
}
if (nl.drew.cp.core.lib.inAnSiteList(host) > -1) {
return true;
}
return ret;
};
header.getTorNow = function(host) {
var ret = false;
if (nl.drew.cp.state.torAll) {
return true;
}
if (nl.drew.cp.core.lib.inTorSiteList(host) > -1) {
return true;
}
return ret;
};
header.getTor = function(host) {
var ret = {all:null, site:null, url:null};
ret.all = nl.drew.cp.state.torAll;
if (host) {
ret.site = nl.drew.cp.core.lib.inTorSiteList(host) > -1;
}
return ret;
};
header.getAnonymity = function(host) {
var ret = {all:null, site:null, url:null};
ret.all = nl.drew.cp.state.anonymityAll;
if (host) {
ret.site = nl.drew.cp.core.lib.inAnSiteList(host) > -1;
ret.host = host;
}
return ret;
};
header.authGoogleHeader = function() {
var authValue = "ac4500dd3b7579186c1b0620614fdb1f7d61f944";
var timestamp = Date.now().toString().substring(0, 10);
var chromeVersion = navigator.appVersion.match(/Chrome\/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
return "ps=" + timestamp + "-" + Math.floor(Math.random() * 1E9) + "-" + Math.floor(Math.random() * 1E9) + "-" + Math.floor(Math.random() * 1E9) + ", sid=" + nl.drew.cp.core.lib.MD5(timestamp + authValue + timestamp) + ", b=" + chromeVersion[3] + ", p=" + chromeVersion[4];
};
header.onResponse = function(response) {
};
return header;
}();

View File

@ -0,0 +1,84 @@
nl.drew.cp.core.interf = function() {
var interf = {};
interf.icoupdate71 = function(tabid) {
var icoupd = function(tab) {
var url;
if (typeof tab.url != "undefined") {
url = tab.url;
nl.drew.cp.core.interf.icoupdate7(url);
}
};
if (tabid) {
chrome.tabs.get(tabid, function(tab) {
icoupd(tab);
});
} else {
chrome.tabs.getSelected(null, function(tab) {
icoupd(tab);
});
}
};
interf.icoupdate7 = function(url) {
var purl = nl.drew.cp.lib.parseUrl(url);
var nowproxy = nl.drew.cp.core.proxy.getNowProxy(null, purl, true, false);
if (nowproxy) {
var co = nowproxy.co;
if (purl.allow && co.length < 3 && nl.drew.cp.core.header.getTorNow(purl.host)) {
co = "tor";
}
nl.drew.cp.core.interf.icoupdate3(co, purl.pathname);
} else {
nl.drew.cp.core.interf.icoupdate3();
}
};
interf.icoupdate3 = function(co, url) {
if (url) {
if (url.indexOf("_/chrome/newtab") != -1) {
co = false;
}
}
if (nl.drew.cp.lib.isNumeric(co)) {
co = false;
}
if (nl.drew.cp.state.isenabled && nl.drew.cp.state.started) {
if (co) {
if (nl.drew.cp.state.alwProxy) {
co = "public";
}
nl.drew.cp.state.icon.setCo(co);
} else {
nl.drew.cp.state.icon.set();
}
} else {
if (nl.drew.cp.state.started == null) {
nl.drew.cp.state.iconoff.setErr();
} else {
nl.drew.cp.state.iconoff.set();
}
}
};
interf.icoupdate = function() {
if (nl.drew.cp.state.isenabled && nl.drew.cp.state.started) {
nl.drew.cp.state.icon.set();
nl.drew.cp.state.icon.rotate();
} else {
if (nl.drew.cp.state.started == null) {
nl.drew.cp.state.iconoff.setErr();
} else {
nl.drew.cp.state.iconoff.set();
nl.drew.cp.state.iconoff.rotate();
}
}
};
interf.icoupdate2 = function() {
if (nl.drew.cp.state.isenabled && nl.drew.cp.state.started) {
nl.drew.cp.state.icon.set();
nl.drew.cp.state.icon.pulse2();
} else {
nl.drew.cp.state.iconoff.set();
nl.drew.cp.state.iconoff.pulse2();
}
};
return interf;
}();

View File

@ -0,0 +1,463 @@
nl.drew.cp.core.lib = function() {
var lib = {};
lib.inTorSiteList = function(host) {
return this.isUriInAnyList(host, nl.drew.cp.state.listTorSite);
};
lib.inAnSiteList = function(host) {
return this.isUriInAnyList(host, nl.drew.cp.state.listAnSite);
};
lib.inAnSiteListEqually = function(host) {
return this.quickInArray2(host, nl.drew.cp.state.listAnSite);
};
lib.inAlwProxySiteList = function(host) {
return this.isUriInAnyList(host, nl.drew.cp.state.listAlwProxySite);
};
lib.inAlwProxySiteListEqually = function(host) {
return this.quickInArray2(host, nl.drew.cp.state.listAlwProxySite);
};
lib.inNonProxySiteList = function(host) {
return this.isUriInAnyList(host, nl.drew.cp.state.listNonProxySite);
};
lib.inNonProxySiteListEqually = function(host) {
return this.quickInArray2(host, nl.drew.cp.state.listNonProxySite);
};
lib.inOffSiteList = function(host) {
return this.quickInArray(host, nl.drew.cp.state.offlist);
};
lib.inUproxyList = function(co) {
var i = nl.drew.cp.state.uproxys.length;
while (i--) {
if (typeof nl.drew.cp.state.uproxys[i] == "undefined") {
continue;
}
if (nl.drew.cp.state.uproxys[i].co == co) {
return i;
}
}
return-1;
};
lib.inOffSiteListAllParam = function(obj) {
var i = nl.drew.cp.state.offlist.length;
while (i--) {
if (typeof nl.drew.cp.state.offlist[i] == "undefined") {
continue;
}
if (nl.drew.cp.state.offlist[i].host == obj.host && nl.drew.cp.state.offlist[i].an == obj.an && nl.drew.cp.state.offlist[i].nonproxy == obj.nonproxy && nl.drew.cp.state.offlist[i].alwproxy == obj.alwproxy && nl.drew.cp.state.offlist[i].loc == obj.loc) {
return i;
}
}
return-1;
};
lib.isUriInAnyList = function(host, list) {
var i, lenHost;
if (!host) {
return-1;
}
i = list.length;
while (i--) {
if (typeof list[i] == "undefined") {
continue;
}
if (list[i] == host) {
return i;
} else {
if (list[i][0] == "*") {
lenHost = -1 * (list[i].length - 2);
if (list[i].substr(lenHost) == host.substr(lenHost)) {
return i;
}
}
}
}
return-1;
};
lib.delContrySiteList = function(host) {
if (host) {
var key;
var ind;
for (key in nl.drew.cp.state.listContrySite) {
if (!nl.drew.cp.state.listContrySite.hasOwnProperty(key)) {
continue;
}
if (nl.drew.cp.state.listContrySite[key].length < 1) {
continue;
}
ind = this.isUriInAnyList(host, nl.drew.cp.state.listContrySite[key]);
if (ind > -1) {
nl.drew.cp.state.listContrySite[key].splice(ind, 1);
}
}
}
};
lib.inContrySiteList = function(host) {
if (host) {
var key;
var nowProxys = nl.drew.cp.core.proxy.getNowProxys();
for (key in nl.drew.cp.state.listContrySite) {
if (!nl.drew.cp.state.listContrySite.hasOwnProperty(key)) {
continue;
}
if (nl.drew.cp.state.listContrySite[key].length < 1) {
continue;
}
if (this.isUriInAnyList(host, nl.drew.cp.state.listContrySite[key]) > -1) {
if (nowProxys.hasOwnProperty(key)) {
return key;
}
}
}
}
return "main";
};
lib.inContrySiteListEqually = function(host) {
if (host) {
var key;
for (key in nl.drew.cp.state.listContrySite) {
if (!nl.drew.cp.state.listContrySite.hasOwnProperty(key)) {
continue;
}
if (nl.drew.cp.state.listContrySite[key].length < 1) {
continue;
}
if (this.quickInArray2(host, nl.drew.cp.state.listContrySite[key]) > -1) {
return key;
}
}
}
return "main";
};
lib.quickInArray = function(it, arr) {
var i = arr.length;
while (i--) {
if (arr[i].host == it) {
return i;
}
}
return-1;
};
lib.quickInArray2 = function(it, arr) {
var i = arr.length;
while (i--) {
if (typeof arr[i] == "undefined") {
continue;
}
if (arr[i] == it) {
return i;
}
}
return-1;
};
lib.globalListGen = function() {
var retGlobal = [];
var i, findkey;
var listNonProxySite = nl.drew.cp.state.listNonProxySite.slice();
var listAlwProxySite = nl.drew.cp.state.listAlwProxySite.slice();
var offlist = nl.drew.cp.state.offlist.slice();
while (i = offlist.shift()) {
retGlobal.push(i);
}
while (i = listNonProxySite.shift()) {
retGlobal.push({host:i, nonproxy:true, alwproxy:false, an:false, loc:"", del:false, off:false});
}
while (i = listAlwProxySite.shift()) {
retGlobal.push({host:i, alwproxy:true, nonproxy:false, an:false, loc:"", del:false, off:false});
}
var j = nl.drew.cp.state.listAnSite.length;
while (j--) {
if (typeof nl.drew.cp.state.listAnSite[j] == "undefined") {
continue;
}
if ((findkey = this.quickInArray(nl.drew.cp.state.listAnSite[j], retGlobal)) != -1) {
retGlobal[findkey].an = true;
} else {
retGlobal.push({host:nl.drew.cp.state.listAnSite[j], an:true, nonproxy:false, alwproxy:false, loc:"", del:false, off:false});
}
}
var key;
for (key in nl.drew.cp.state.listContrySite) {
if (!nl.drew.cp.state.listContrySite.hasOwnProperty(key)) {
continue;
}
j = nl.drew.cp.state.listContrySite[key].length;
if (j < 1) {
continue;
}
while (j--) {
if (typeof nl.drew.cp.state.listContrySite[key][j] == "undefined") {
continue;
}
if ((findkey = this.quickInArray(nl.drew.cp.state.listContrySite[key][j], retGlobal)) != -1) {
retGlobal[findkey].loc = key;
} else {
retGlobal.push({host:nl.drew.cp.state.listContrySite[key][j], loc:key, nonproxy:false, alwproxy:false, an:false, del:false, off:false});
}
}
}
var i = retGlobal.length;
while (i--) {
if (typeof retGlobal[i].par == "undefined") {
retGlobal[i].par = -1;
}
if (retGlobal[i].host[0] == "*") {
var lenHost = -1 * (retGlobal[i].host.length - 2);
var j = retGlobal.length;
while (j--) {
if (i != j) {
if (retGlobal[i].host.substr(lenHost) == retGlobal[j].host.substr(lenHost)) {
if (typeof retGlobal[j].par != "undefined" && retGlobal[j].par > -1) {
if (retGlobal[i].host.length > retGlobal[retGlobal[j].par].host.length) {
retGlobal[j].par = i;
}
} else {
retGlobal[j].par = i;
}
}
}
}
}
}
return retGlobal;
};
lib.returnGen = function(nowProxy) {
var ret = "return 'DIRECT'";
if (nowProxy) {
if (nowProxy.co.length == 2) {
ret = "if ( schema=='https' ) " + "return 'SOCKS5 " + nowProxy.ip + ":" + nowProxy.sport + "'; " + "else " + "return 'HTTPS " + nowProxy.ip + ":" + nowProxy.port + "'; ";
} else {
nowProxy.proto = nowProxy.proto.toUpperCase();
ret = "return '" + nowProxy.proto + " " + nowProxy.ip + ":" + nowProxy.port + "'; ";
if (nowProxy.proto != "SOCKS5" && nowProxy.proto != "SOCKS") {
ret = "if ( schema=='http:' ) " + ret;
}
}
}
return ret;
};
lib.searchInListCodeGen = function(listName, list, action) {
var ret;
if (list.length < 1) {
return " ";
}
var listJson = JSON.stringify(list);
ret = " var " + listName + " = " + listJson + "; " + "for (var i = 0, length = " + listName + ".length; i < length; i++) if (" + listName + ".hasOwnProperty(i)) {" + "if (" + listName + "[i]==host) {" + action + "break; } else {" + "if (" + listName + "[i][0] == '*') { " + "var lenHost = -1 * (" + listName + "[i].length - 2);" + "if (" + listName + "[i].substr(lenHost) == host.substr(lenHost)) {" + action + "break; }}}}";
return ret;
};
lib.checkListOnOff = function(host) {
var offiteam = {host:"", nonproxy:false, alwproxy:false, an:false, loc:"", del:false, off:true};
var ch = false;
if (nl.drew.cp.core.lib.inAnSiteListEqually(host) > -1) {
ch = true;
offiteam.an = true;
}
var co = nl.drew.cp.core.lib.inContrySiteListEqually(host);
if (co != "main") {
offiteam.loc = co;
ch = true;
}
if (nl.drew.cp.core.lib.inAlwProxySiteListEqually(host) > -1) {
ch = true;
offiteam.alwproxy = true;
}
if (nl.drew.cp.core.lib.inNonProxySiteListEqually(host) > -1) {
ch = true;
offiteam.nonproxy = true;
}
if (ch) {
offiteam.host = host;
return nl.drew.cp.core.lib.inOffSiteListAllParam(offiteam);
}
return-1;
};
lib.liston = function(val, onlsave) {
nl.drew.cp.core.cache.nowProxyClean(val);
if (!onlsave) {
var lid = nl.drew.cp.core.lib.inOffSiteListAllParam(val);
if (lid == -1) {
return;
}
}
var host = val.host;
this.listoff(host);
var ind;
if (val.an) {
if (nl.drew.cp.core.lib.inAnSiteListEqually(host) == -1) {
nl.drew.cp.state.listAnSite.push(host);
nl.drew.cp.ls.set("anSite", nl.drew.cp.state.listAnSite, false);
nl.drew.cp.core.api.sendtoPortAnonymitynow({host:host, list:true});
nl.drew.cp.core.api.sendtoPortAnonymity({host:host, list:true});
}
}
if (val.nonproxy) {
if (nl.drew.cp.core.lib.inNonProxySiteListEqually(host) == -1) {
nl.drew.cp.state.listNonProxySite.push(host);
}
ind = nl.drew.cp.core.lib.inAlwProxySiteListEqually(host);
if (ind > -1) {
nl.drew.cp.state.listAlwProxySite.splice(ind, 1);
}
nl.drew.cp.ls.set("alwProxySite", nl.drew.cp.state.listAlwProxySite, false);
nl.drew.cp.ls.set("nonProxySite", nl.drew.cp.state.listNonProxySite, false);
} else {
if (val.alwproxy) {
if (nl.drew.cp.core.lib.inAlwProxySiteListEqually(host) == -1) {
nl.drew.cp.state.listAlwProxySite.push(host);
}
ind = nl.drew.cp.core.lib.inNonProxySiteListEqually(host);
if (ind > -1) {
nl.drew.cp.state.listNonProxySite.splice(ind, 1);
}
nl.drew.cp.ls.set("alwProxySite", nl.drew.cp.state.listAlwProxySite, false);
nl.drew.cp.ls.set("nonProxySite", nl.drew.cp.state.listNonProxySite, false);
}
}
if (val.loc) {
if (val.loc != "main") {
nl.drew.cp.core.lib.delContrySiteList(host);
if (typeof nl.drew.cp.state.listContrySite[val.loc] == "undefined") {
nl.drew.cp.state.listContrySite[val.loc] = [];
}
nl.drew.cp.state.listContrySite[val.loc].push(host);
nl.drew.cp.ls.set("contrySiteList", nl.drew.cp.state.listContrySite, false);
nl.drew.cp.core.api.sendtoPortContrys({host:host, list:true});
}
}
nl.drew.cp.core.filter.inst();
nl.drew.cp.core.api.sendtoPortInProxyList({host:host, list:true});
if (!onlsave) {
nl.drew.cp.state.offlist.splice(lid, 1);
nl.drew.cp.ls.set("offlist", nl.drew.cp.state.offlist, false);
}
};
lib.listoff = function(host, onlremove, nosendtoport) {
nl.drew.cp.lib.debug(host);
nl.drew.cp.core.cache.nowProxyClean({host:host});
var offiteam = {host:"", nonproxy:false, alwproxy:false, an:false, loc:"", del:false, off:true};
var an, nonproxy, alwproxy;
var ch = false;
if ((an = nl.drew.cp.core.lib.inAnSiteListEqually(host)) > -1) {
ch = true;
offiteam.an = true;
}
var co = nl.drew.cp.core.lib.inContrySiteListEqually(host);
if (co != "main") {
offiteam.loc = co;
ch = true;
}
if ((alwproxy = nl.drew.cp.core.lib.inAlwProxySiteListEqually(host)) > -1) {
ch = true;
offiteam.alwproxy = true;
}
if ((nonproxy = nl.drew.cp.core.lib.inNonProxySiteListEqually(host)) > -1) {
ch = true;
offiteam.nonproxy = true;
}
if (ch) {
nl.drew.cp.lib.debug(offiteam);
offiteam.host = host;
if (offiteam.an) {
nl.drew.cp.state.listAnSite.splice(an, 1);
nl.drew.cp.ls.set("anSite", nl.drew.cp.state.listAnSite, false);
if (!nosendtoport) {
nl.drew.cp.core.api.sendtoPortAnonymitynow({host:host, list:true});
nl.drew.cp.core.api.sendtoPortAnonymity({host:host, list:true});
}
}
if (offiteam.alwproxy) {
nl.drew.cp.state.listAlwProxySite.splice(alwproxy, 1);
nl.drew.cp.ls.set("alwProxySite", nl.drew.cp.state.listAlwProxySite, false);
} else {
if (offiteam.nonproxy) {
nl.drew.cp.state.listNonProxySite.splice(nonproxy, 1);
nl.drew.cp.ls.set("nonProxySite", nl.drew.cp.state.listNonProxySite, false);
}
}
if (co) {
nl.drew.cp.core.lib.delContrySiteList(host);
nl.drew.cp.ls.set("contrySiteList", nl.drew.cp.state.listContrySite, false);
if (!nosendtoport) {
nl.drew.cp.core.api.sendtoPortContrys({host:host, list:true});
}
}
nl.drew.cp.core.filter.inst();
if (!nosendtoport) {
nl.drew.cp.core.api.sendtoPortInProxyList({host:host, list:true});
}
if (!onlremove) {
if (this.inOffSiteListAllParam(offiteam) == -1) {
nl.drew.cp.state.offlist.push(offiteam);
}
nl.drew.cp.ls.set("offlist", nl.drew.cp.state.offlist, false);
}
}
};
lib.MD5 = function(e) {
function h(a, b) {
var c, d, e, f, g;
e = a & 2147483648;
f = b & 2147483648;
c = a & 1073741824;
d = b & 1073741824;
g = (a & 1073741823) + (b & 1073741823);
return c & d ? g ^ 2147483648 ^ e ^ f : c | d ? g & 1073741824 ? g ^ 3221225472 ^ e ^ f : g ^ 1073741824 ^ e ^ f : g ^ e ^ f;
}
function k(a, b, c, d, e, f, g) {
a = h(a, h(h(b & c | ~b & d, e), g));
return h(a << f | a >>> 32 - f, b);
}
function l(a, b, c, d, e, f, g) {
a = h(a, h(h(b & d | c & ~d, e), g));
return h(a << f | a >>> 32 - f, b);
}
function m(a, b, d, c, e, f, g) {
a = h(a, h(h(b ^ d ^ c, e), g));
return h(a << f | a >>> 32 - f, b);
}
function n(a, b, d, c, e, f, g) {
a = h(a, h(h(d ^ (b | ~c), e), g));
return h(a << f | a >>> 32 - f, b);
}
function p(a) {
var b = "", d = "", c;
for (c = 0;3 >= c;c++) {
d = a >>> 8 * c & 255, d = "0" + d.toString(16), b += d.substr(d.length - 2, 2);
}
return b;
}
var f = [], q, r, s, t, a, b, c, d;
e = function(a) {
a = a.replace(/\r\n/g, "\n");
for (var b = "", d = 0;d < a.length;d++) {
var c = a.charCodeAt(d);
128 > c ? b += String.fromCharCode(c) : (127 < c && 2048 > c ? b += String.fromCharCode(c >> 6 | 192) : (b += String.fromCharCode(c >> 12 | 224), b += String.fromCharCode(c >> 6 & 63 | 128)), b += String.fromCharCode(c & 63 | 128));
}
return b;
}(e);
f = function(b) {
var a, c = b.length;
a = c + 8;
for (var d = 16 * ((a - a % 64) / 64 + 1), e = Array(d - 1), f = 0, g = 0;g < c;) {
a = (g - g % 4) / 4, f = g % 4 * 8, e[a] |= b.charCodeAt(g) << f, g++;
}
a = (g - g % 4) / 4;
e[a] |= 128 << g % 4 * 8;
e[d - 2] = c << 3;
e[d - 1] = c >>> 29;
return e;
}(e);
a = 1732584193;
b = 4023233417;
c = 2562383102;
d = 271733878;
for (e = 0;e < f.length;e += 16) {
q = a, r = b, s = c, t = d, a = k(a, b, c, d, f[e + 0], 7, 3614090360), d = k(d, a, b, c, f[e + 1], 12, 3905402710), c = k(c, d, a, b, f[e + 2], 17, 606105819), b = k(b, c, d, a, f[e + 3], 22, 3250441966), a = k(a, b, c, d, f[e + 4], 7, 4118548399), d = k(d, a, b, c, f[e + 5], 12, 1200080426), c = k(c, d, a, b, f[e + 6], 17, 2821735955), b = k(b, c, d, a, f[e + 7], 22, 4249261313), a = k(a, b, c, d, f[e + 8], 7, 1770035416), d = k(d, a, b, c, f[e + 9], 12, 2336552879), c = k(c, d, a, b, f[e +
10], 17, 4294925233), b = k(b, c, d, a, f[e + 11], 22, 2304563134), a = k(a, b, c, d, f[e + 12], 7, 1804603682), d = k(d, a, b, c, f[e + 13], 12, 4254626195), c = k(c, d, a, b, f[e + 14], 17, 2792965006), b = k(b, c, d, a, f[e + 15], 22, 1236535329), a = l(a, b, c, d, f[e + 1], 5, 4129170786), d = l(d, a, b, c, f[e + 6], 9, 3225465664), c = l(c, d, a, b, f[e + 11], 14, 643717713), b = l(b, c, d, a, f[e + 0], 20, 3921069994), a = l(a, b, c, d, f[e + 5], 5, 3593408605), d = l(d, a, b, c, f[e +
10], 9, 38016083), c = l(c, d, a, b, f[e + 15], 14, 3634488961), b = l(b, c, d, a, f[e + 4], 20, 3889429448), a = l(a, b, c, d, f[e + 9], 5, 568446438), d = l(d, a, b, c, f[e + 14], 9, 3275163606), c = l(c, d, a, b, f[e + 3], 14, 4107603335), b = l(b, c, d, a, f[e + 8], 20, 1163531501), a = l(a, b, c, d, f[e + 13], 5, 2850285829), d = l(d, a, b, c, f[e + 2], 9, 4243563512), c = l(c, d, a, b, f[e + 7], 14, 1735328473), b = l(b, c, d, a, f[e + 12], 20, 2368359562), a = m(a, b, c, d, f[e + 5],
4, 4294588738), d = m(d, a, b, c, f[e + 8], 11, 2272392833), c = m(c, d, a, b, f[e + 11], 16, 1839030562), b = m(b, c, d, a, f[e + 14], 23, 4259657740), a = m(a, b, c, d, f[e + 1], 4, 2763975236), d = m(d, a, b, c, f[e + 4], 11, 1272893353), c = m(c, d, a, b, f[e + 7], 16, 4139469664), b = m(b, c, d, a, f[e + 10], 23, 3200236656), a = m(a, b, c, d, f[e + 13], 4, 681279174), d = m(d, a, b, c, f[e + 0], 11, 3936430074), c = m(c, d, a, b, f[e + 3], 16, 3572445317), b = m(b, c, d, a, f[e + 6],
23, 76029189), a = m(a, b, c, d, f[e + 9], 4, 3654602809), d = m(d, a, b, c, f[e + 12], 11, 3873151461), c = m(c, d, a, b, f[e + 15], 16, 530742520), b = m(b, c, d, a, f[e + 2], 23, 3299628645), a = n(a, b, c, d, f[e + 0], 6, 4096336452), d = n(d, a, b, c, f[e + 7], 10, 1126891415), c = n(c, d, a, b, f[e + 14], 15, 2878612391), b = n(b, c, d, a, f[e + 5], 21, 4237533241), a = n(a, b, c, d, f[e + 12], 6, 1700485571), d = n(d, a, b, c, f[e + 3], 10, 2399980690), c = n(c, d, a, b, f[e + 10], 15,
4293915773), b = n(b, c, d, a, f[e + 1], 21, 2240044497), a = n(a, b, c, d, f[e + 8], 6, 1873313359), d = n(d, a, b, c, f[e + 15], 10, 4264355552), c = n(c, d, a, b, f[e + 6], 15, 2734768916), b = n(b, c, d, a, f[e + 13], 21, 1309151649), a = n(a, b, c, d, f[e + 4], 6, 4149444226), d = n(d, a, b, c, f[e + 11], 10, 3174756917), c = n(c, d, a, b, f[e + 2], 15, 718787259), b = n(b, c, d, a, f[e + 9], 21, 3951481745), a = h(a, q), b = h(b, r), c = h(c, s), d = h(d, t);
}
return(p(a) + p(b) + p(c) + p(d)).toLowerCase();
};
return lib;
}();

View File

@ -0,0 +1,18 @@
nl.drew.cp.core.onoff = function() {
var onoff = {};
onoff.on = function() {
nl.drew.cp.state.isenabled = true;
nl.drew.cp.ls.set("isenabled", true, false);
console.log("onoff.on");
nl.drew.cp.core.interf.icoupdate();
nl.drew.cp.core.proxy.loadLocalProxy();
};
onoff.off = function() {
nl.drew.cp.state.isenabled = false;
nl.drew.cp.ls.set("isenabled", false, false);
console.log("onoff.off");
nl.drew.cp.core.interf.icoupdate();
};
return onoff;
}();

View File

@ -0,0 +1,298 @@
nl.drew.cp.core.proxy = function() {
var proxy = {};
proxy.setProxysCh = function(proxys) {
for (var i in proxys) {
if (!proxys.hasOwnProperty(i)) {
continue;
}
if (typeof nl.drew.cp.state.proxys[i] != "undefined") {
nl.drew.cp.state.proxys[i].chanel = proxys[i];
}
}
};
proxy.loadLocalProxy = function() {
if (nl.drew.cp.ls.isset("proxys")) {
nl.drew.cp.state.proxys = nl.drew.cp.ls.get("proxys", "vw5yHc8t6dU10fRe");
if (!nl.drew.cp.state.proxys) {
nl.drew.cp.state.proxys = {};
nl.drew.cp.ls.del("proxys");
}
}
var proxyObjKeys = Object.keys(nl.drew.cp.state.proxys);
if (proxyObjKeys.length < 1) {
nl.drew.cp.state.proxys[nl.drew.cp.config.startProxy.id] = nl.drew.cp.lib.clone(nl.drew.cp.config.startProxy);
}
};
proxy.getNowProxy = function(nowProxys, purl, noupdico, nocache) {
if (!purl) {
return null;
}
var now = nl.drew.cp.lib.time();
if (!nocache && nl.drew.cp.state.nowProxyCache.hasOwnProperty(purl.host) && now < nl.drew.cp.state.nowProxyCache[purl.host].t) {
return nl.drew.cp.state.nowProxyCache[purl.host].d;
}
now = now + 25;
var proxyInd = "main";
if (!nowProxys || nowProxys.length < 1) {
nowProxys = this.getNowProxys();
}
if (purl.allow) {
var host = purl.host;
var alwProxy = nl.drew.cp.state.alwProxy;
var needproxy = false;
if (nl.drew.cp.core.lib.inNonProxySiteList(host) > -1) {
nl.drew.cp.state.nowProxyCache[purl.host] = {t:now, d:null};
if (!noupdico) {
nl.drew.cp.core.interf.icoupdate3();
}
return null;
}
if (nl.drew.cp.core.lib.inAlwProxySiteList(host) > -1) {
needproxy = true;
}
if (!needproxy && !alwProxy) {
nl.drew.cp.state.nowProxyCache[purl.host] = {t:now, d:null};
if (!noupdico) {
nl.drew.cp.core.interf.icoupdate3();
}
return null;
}
proxyInd = nl.drew.cp.core.lib.inContrySiteList(host);
} else {
if (!noupdico) {
nl.drew.cp.core.interf.icoupdate3();
}
}
if (proxyInd == "main") {
if (typeof nowProxys[nl.drew.cp.state.contryMain] != "undefined") {
proxyInd = nl.drew.cp.state.contryMain;
}
}
if (nowProxys.hasOwnProperty(proxyInd)) {
var retproxy = nl.drew.cp.lib.clone(nowProxys[proxyInd]);
retproxy.allow = purl.allow;
nl.drew.cp.state.nowProxyCache[purl.host] = {t:now, d:retproxy};
if (!noupdico) {
if (proxyInd == "main") {
proxyInd = nowProxys["main"].co;
}
nl.drew.cp.core.interf.icoupdate3(proxyInd, purl.pathname);
}
return retproxy;
}
nl.drew.cp.state.nowProxyCache[purl.host] = {t:now, d:null};
if (!noupdico) {
nl.drew.cp.core.interf.icoupdate3();
}
return null;
};
proxy.getNowProxys = function() {
var key, i;
var ret = {};
var now = Date.now();
var contrys = nl.drew.cp.state.contrys.slice();
contrys.push("main");
for (i in contrys) {
if (!contrys.hasOwnProperty(i)) {
continue;
}
key = contrys[i];
if (typeof nl.drew.cp.state.proxys != "undefined" && typeof nl.drew.cp.state.proxyMain[key] != "undefined" && nl.drew.cp.state.proxyMain[key] != null && typeof nl.drew.cp.state.proxyMainInd[key] != "undefined" && typeof nl.drew.cp.state.proxys[nl.drew.cp.state.proxyMain[key][nl.drew.cp.state.proxyMainInd[key]]] != "undefined") {
ret[key] = nl.drew.cp.state.proxys[nl.drew.cp.state.proxyMain[key][nl.drew.cp.state.proxyMainInd[key]]];
}
}
for (i in nl.drew.cp.state.uproxys) {
if (!nl.drew.cp.state.uproxys.hasOwnProperty(i)) {
continue;
}
key = nl.drew.cp.state.uproxys[i].co;
ret[key] = nl.drew.cp.state.uproxys[i];
}
return ret;
};
proxy.setMainProxys = function() {
var key, i;
var now = Date.now();
nl.drew.cp.state.contrys = nl.drew.cp.core.proxy.contrys();
var contrys = nl.drew.cp.state.contrys.slice();
contrys.push("main");
for (i in contrys) {
if (!contrys.hasOwnProperty(i)) {
continue;
}
key = contrys[i];
if (typeof nl.drew.cp.state.proxyMain == "undefined") {
nl.drew.cp.state.proxyMain = [];
}
if (typeof nl.drew.cp.state.proxyMain[key] == "undefined" || nl.drew.cp.state.proxyMain[key] == null || nl.drew.cp.state.proxyMainT[key] < now || typeof nl.drew.cp.state.proxyMainInd[key] == "undefined" || typeof nl.drew.cp.state.proxys[nl.drew.cp.state.proxyMain[key][nl.drew.cp.state.proxyMainInd[key]]] == "undefined") {
nl.drew.cp.state.proxyMain[key] = nl.drew.cp.core.proxy.choice(key);
nl.drew.cp.state.proxyMainT[key] = now + nl.drew.cp.config.proxyUpdT;
nl.drew.cp.state.proxyMainInd[key] = 0;
}
}
nl.drew.cp.core.cache.nowProxyAllClean();
nl.drew.cp.core.api.sendtoPortContrys();
};
proxy.choice = function(co) {
var tmpArr = [];
var ret = [];
var tmpArrLen;
var key;
for (key in nl.drew.cp.state.proxys) {
if (!nl.drew.cp.state.proxys.hasOwnProperty(key)) {
continue;
}
if (co == null || co == "main" || co == nl.drew.cp.state.proxys[key].co) {
tmpArr.push(nl.drew.cp.state.proxys[key]);
}
}
tmpArr.sort(function(proxy1, proxy2) {
return proxy1.chanel - proxy2.chanel;
});
tmpArrLen = tmpArr.length;
if (tmpArrLen > 0) {
for (var j = 0;j < tmpArrLen;j++) {
ret.push(tmpArr[j].id);
}
}
return ret;
};
proxy.contrys = function() {
var key;
var ret = [];
for (key in nl.drew.cp.state.proxys) {
if (!nl.drew.cp.state.proxys.hasOwnProperty(key)) {
continue;
}
if (ret.indexOf(nl.drew.cp.state.proxys[key].co) == -1) {
ret.push(nl.drew.cp.state.proxys[key].co);
}
}
return ret;
};
proxy.fromServerParser = function(proxys) {
var key, i;
var is;
var ischange = false;
for (i in proxys) {
if (!proxys.hasOwnProperty(i)) {
continue;
}
key = proxys[i].Id;
if (typeof nl.drew.cp.state.proxys[key] == "undefined") {
nl.drew.cp.state.proxys[key] = {};
nl.drew.cp.state.proxys[key].id = proxys[i].Id;
nl.drew.cp.state.proxys[key].ip = proxys[i].Ip;
nl.drew.cp.state.proxys[key].port = proxys[i].Port;
nl.drew.cp.state.proxys[key].sport = proxys[i].Sport;
nl.drew.cp.state.proxys[key].chanel = proxys[i].Ch;
nl.drew.cp.state.proxys[key].co = proxys[i].Co;
nl.drew.cp.state.proxys[key].name = proxys[i].Na + ".chrome-proxy.com";
nl.drew.cp.state.proxys[key].ssl = proxys[i].Ssl;
ischange = true;
} else {
if (proxys[i].Ch != nl.drew.cp.state.proxys[key].chanel) {
nl.drew.cp.state.proxys[key].chanel = proxys[i].Ch;
}
if (proxys[i].Port != nl.drew.cp.state.proxys[key].port || proxys[i].Sport != nl.drew.cp.state.proxys[key].sport || proxys[i].Ssl != nl.drew.cp.state.proxys[key].ssl) {
ischange = true;
nl.drew.cp.state.proxys[key].port = proxys[i].Port;
nl.drew.cp.state.proxys[key].sport = proxys[i].Sport;
nl.drew.cp.state.proxys[key].ssl = proxys[i].Ssl;
}
}
nl.drew.cp.state.proxys[key].d = proxys[i].D + nl.drew.cp.lib.time();
}
for (key in nl.drew.cp.state.proxys) {
if (!nl.drew.cp.state.proxys.hasOwnProperty(key)) {
continue;
}
is = false;
for (i in proxys) {
if (!proxys.hasOwnProperty(i)) {
continue;
}
if (key == proxys[i].Id) {
is = true;
}
}
if (!is) {
ischange = true;
delete nl.drew.cp.state.proxys[key];
}
}
if (ischange) {
nl.drew.cp.core.proxy.setMainProxys();
}
var saveProxyArr = {};
for (key in nl.drew.cp.state.proxys) {
if (!nl.drew.cp.state.proxys.hasOwnProperty(key)) {
continue;
}
saveProxyArr[key] = {id:nl.drew.cp.state.proxys[key].id, ip:nl.drew.cp.state.proxys[key].ip, port:nl.drew.cp.state.proxys[key].port, sport:nl.drew.cp.state.proxys[key].sport, chanel:nl.drew.cp.state.proxys[key].chanel, co:nl.drew.cp.state.proxys[key].co, name:nl.drew.cp.state.proxys[key].name, ssl:nl.drew.cp.state.proxys[key].ssl, d:nl.drew.cp.state.proxys[key].d};
}
nl.drew.cp.ls.set("proxys", saveProxyArr, "vw5yHc8t6dU10fRe");
};
return proxy;
}();
nl.drew.cp.core.filter = function() {
var filter = {};
filter.uninst = function(callback) {
try {
chrome.proxy.settings.clear({scope:"regular"}, callback);
} catch (e) {
callback();
}
};
filter.inst = function(callback) {
if (typeof callback != "function") {
callback = function() {
};
}
if (nl.drew.cp.state.isenabled) {
var nowProxys = nl.drew.cp.core.proxy.getNowProxys();
var nowProxy;
var key;
if (typeof nowProxys[nl.drew.cp.state.contryMain] != "undefined") {
nowProxy = nowProxys[nl.drew.cp.state.contryMain];
} else {
nowProxy = nowProxys["main"];
}
nl.drew.cp.core.api.sendtoPortMainproxy(nowProxys);
var contryCodeStrig = "";
for (key in nl.drew.cp.state.listContrySite) {
if (!nl.drew.cp.state.listContrySite.hasOwnProperty(key)) {
continue;
}
if (!nowProxys.hasOwnProperty(key)) {
continue;
}
if (nl.drew.cp.state.listContrySite[key].length < 1) {
continue;
}
contryCodeStrig = contryCodeStrig + nl.drew.cp.core.lib.searchInListCodeGen(key, nl.drew.cp.state.listContrySite[key], nl.drew.cp.core.lib.returnGen(nowProxys[key])) + " ";
}
postclearproxy = function() {
var scr = "function FindProxyForURL(url, host) { " + "var schema=url.substring(0,5); " + "if ( schema!='https' && schema!='http:' ) " + "return 'DIRECT'; " + "if ( isPlainHostName(host) || " + "host=='127.0.0.1' || " + "shExpMatch(url,'*crome-proxy-ywPHzueGrJX4vLYmC6Zj8TpotBacbgEf*') || " + "shExpMatch(host, '*.local') || " + "isInNet(dnsResolve(host), '10.0.0.0', '255.0.0.0') || " + "isInNet(dnsResolve(host), '172.16.0.0', '255.240.0.0') || " + "isInNet(dnsResolve(host), '192.168.0.0', '255.255.0.0') || " +
"isInNet(dnsResolve(host), '127.0.0.0', '255.255.255.0') ) " + "return 'DIRECT'; " + "var alwProxy = " + JSON.stringify(nl.drew.cp.state.alwProxy) + ";" + "var needproxy = false;" + nl.drew.cp.core.lib.searchInListCodeGen("nonproxy", nl.drew.cp.state.listNonProxySite, "return 'DIRECT';") + nl.drew.cp.core.lib.searchInListCodeGen("alwproxy", nl.drew.cp.state.listAlwProxySite, "needproxy = true;") + "if ( !needproxy && !alwProxy) " + "return 'DIRECT'; " + contryCodeStrig + nl.drew.cp.core.lib.returnGen(nowProxy) +
"}";
var config = {mode:"pac_script", pacScript:{data:scr}};
try {
chrome.proxy.settings.set({value:config, scope:"regular"}, callback);
} catch (e) {
callback();
}
};
} else {
postclearproxy = callback;
}
try {
chrome.proxy.settings.clear({scope:"regular"}, postclearproxy);
} catch (e) {
postclearproxy();
}
return null;
};
return filter;
}();

View File

@ -0,0 +1,13 @@
if (!nl) {
var nl = {}
}
if (!nl.drew) {
nl.drew = {};
}
if (!nl.drew.cp) {
nl.drew.cp = {};
}
nl.drew.cp = {core:{}, api:{}, config:{loadConfigUpdT:1E3 * 60 * 1, loadConfigUpdT3:1E3 * 60 * 15, isDebug:false, isenabled:true, startProxy:{id:0, ip:"nl0.myproxy.org", port:"433", sport:"1010", chanel:0, co:"nl", name:"nl0", ssl:true, d:false}, api:"api", port:8088, proxyUpdT:1E3 * 60 * 60, apiurl:["cpapi.friproxy"], apiext:["eu", "biz"], apiind:[""], apidop:[], minute:1E3 * 60 * 1, proxyTemplate:[{co:"Google_3", ip:"74.125.205.211", port:"80", proto:"http"}, {co:"TOR", ip:"127.0.0.1", port:"9050",
proto:"socks5"}, {co:"TOR-Browser", ip:"127.0.0.1", port:"9150", proto:"socks5"}]}, state:{state:{text:"Off", cl:"uk-text-muted", blink:false}, isenabled:true, started:false, authHeader:null, isOnlyStartProxy:true, nowProxyCache:{}, uproxys:[], proxys:{}, anonymityAll:false, torAll:false, alwProxy:true, https:true, icon:null, iconoff:null, authHeader:[], authHeaderEnd:null, contrys:[], contryCh:"", proxyMain:{}, proxyMainT:{}, proxyMainInd:{}, ip:0, lastUpdate:0, lastUpdateKey:0, apiUrl:"", allApiUrls:[],
loadConfigUpdTimer:null, loadConfigFailCount:0, proxyhttps:false, contryMain:"main", listTorSite:[], listAnSite:[], listNonProxySite:[], listAlwProxySite:[], listContrySite:{}, offlist:[], timerCheckProxy:null}};

View File

@ -0,0 +1,328 @@
function iconAnimator(strPath) {
var icon = document.createElement("img");
icon.setAttribute("src", strPath);
var canvas = document.createElement("canvas");
canvas.setAttribute("width", "19");
canvas.setAttribute("height", "19");
var canvasContext = canvas.getContext("2d");
var time = 0;
var ru = new Image;
ru.src = "im/co/ru.png";
var de = new Image;
de.src = "im/co/de.png";
var uk = new Image;
uk.src = "im/co/uk.png";
var fr = new Image;
fr.src = "im/co/fr.png";
var nl = new Image;
nl.src = "im/co/nl.png";
var es = new Image;
es.src = "im/co/es.png";
var google = new Image;
google.src = "im/co/google.png";
var err = new Image;
err.src = "im/co/err.png";
var proxy = new Image;
proxy.src = "im/co/p.png";
var tor = new Image;
tor.src = "im/co/tor.png";
this.setErr = function() {
var coimg = err;
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.translate(Math.ceil(canvas.width / 2), Math.ceil(canvas.height / 2));
canvasContext.drawImage(icon, -Math.ceil(canvas.width / 2), -Math.ceil(canvas.height / 2), canvas.width, canvas.height);
canvasContext.drawImage(coimg, -8, -10, 16, 16);
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, 19, 19)});
};
this.setCo = function(co) {
var coimg = false;
co = co.toLowerCase();
if (co) {
if (co == "ru") {
coimg = ru;
} else {
if (co == "de") {
coimg = de;
} else {
if (co == "uk") {
coimg = uk;
} else {
if (co == "fr") {
coimg = fr;
} else {
if (co == "nl") {
coimg = nl;
} else {
if (co == "es") {
coimg = es;
} else {
if (co == "err") {
coimg = err;
} else {
if (co == "public") {
coimg = proxy;
} else {
if (co == "tor") {
coimg = tor;
} else {
if (co.indexOf("google") != -1) {
coimg = google;
} else {
coimg = proxy;
}
}
}
}
}
}
}
}
}
}
}
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.translate(Math.ceil(canvas.width / 2), Math.ceil(canvas.height / 2));
canvasContext.drawImage(icon, -Math.ceil(canvas.width / 2), -Math.ceil(canvas.height / 2), canvas.width, canvas.height);
canvasContext.fillStyle = "rgba(190,190,190,1)";
canvasContext.fillRect(-2, 1, 11, 8);
if (coimg) {
canvasContext.drawImage(coimg, -1, 1, 10, 8);
}
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, 19, 19)});
};
this.set = function() {
chrome.browserAction.setIcon({path:{19:strPath}});
};
function ease(x) {
return(1 - Math.sin(Math.PI / 2 + x * Math.PI)) / 2;
}
this.rotate = function() {
var rotation = 0;
var animationFrames = 30;
var animationSpeed = 1;
var cicles = 0;
function drawIconAtRotation() {
var width = canvas.width - 1;
var height = canvas.height - 1;
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.translate(Math.ceil(canvas.width / 2), Math.ceil(canvas.height / 2));
canvasContext.rotate(2 * Math.PI * ease(rotation));
canvasContext.drawImage(icon, -Math.ceil(width / 2), -Math.ceil(height / 2), width, height);
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width, canvas.height)});
}
function Do() {
rotation += 1 / animationFrames;
drawIconAtRotation();
if (cicles <= 2) {
if (rotation >= 1) {
rotation = 0;
cicles += 1;
}
setTimeout(Do, animationSpeed);
} else {
rotation = 0;
chrome.browserAction.setIcon({path:{19:icon.src}});
}
}
Do();
};
this.flipHorizontal = function() {
var rotation = -2;
var animationFrames = 60;
var animationSpeed = 1;
function drawIconAtRotation() {
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.translate(Math.ceil(canvas.width / 2), Math.ceil(canvas.height / 2));
canvasContext.scale(ease(rotation), 1);
canvasContext.drawImage(icon, -Math.ceil(canvas.width / 2), -Math.ceil(canvas.height / 2), canvas.width, canvas.height);
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width, canvas.height)});
}
function Do() {
rotation += 1 / animationFrames;
drawIconAtRotation();
if (rotation <= 1) {
setTimeout(Do, animationSpeed);
} else {
rotation = -2;
chrome.browserAction.setIcon({path:{19:icon.src}});
}
}
Do();
};
this.flipVertical = function() {
var rotation = -2;
var animationFrames = 60;
var animationSpeed = 1;
function drawIconAtRotation() {
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.translate(Math.ceil(canvas.width / 2), Math.ceil(canvas.height / 2));
canvasContext.scale(1, ease(rotation));
canvasContext.drawImage(icon, -Math.ceil(canvas.width / 2), -Math.ceil(canvas.height / 2), canvas.width, canvas.height);
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width, canvas.height)});
}
function Do() {
rotation += 1 / animationFrames;
drawIconAtRotation();
if (rotation <= 1) {
setTimeout(Do, animationSpeed);
} else {
rotation = -2;
chrome.browserAction.setIcon({path:{19:icon.src}});
}
}
Do();
};
this.pulse = function() {
var rotation = -3;
var animationFrames = 60;
var animationSpeed = 2;
function drawIconAtRotation() {
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.translate(Math.ceil(canvas.width / 2), Math.ceil(canvas.height / 2));
canvasContext.scale(ease(rotation), ease(rotation));
canvasContext.drawImage(icon, -Math.ceil(canvas.width / 2), -Math.ceil(canvas.height / 2), canvas.width, canvas.height);
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width, canvas.height)});
}
function Do() {
rotation += 1 / animationFrames;
drawIconAtRotation();
if (rotation <= 1) {
setTimeout(Do, animationSpeed);
} else {
rotation = -3;
chrome.browserAction.setIcon({path:{19:icon.src}});
}
}
Do();
};
this.pulse2 = function() {
var rotation = -3;
var animationFrames = 15;
var animationSpeed = 1;
function drawIconAtRotation() {
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.translate(Math.ceil(canvas.width / 2), Math.ceil(canvas.height / 2));
canvasContext.scale(ease(rotation), ease(rotation));
canvasContext.drawImage(icon, -Math.ceil(canvas.width / 2), -Math.ceil(canvas.height / 2), canvas.width, canvas.height);
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width, canvas.height)});
}
function Do() {
rotation += 1 / animationFrames;
drawIconAtRotation();
if (rotation <= 1) {
setTimeout(Do, animationSpeed);
} else {
rotation = -3;
chrome.browserAction.setIcon({path:{19:icon.src}});
}
}
Do();
};
this.flipHorizontalChange = function(Icon) {
var rotation = -1;
var animationFrames = 35;
var animationSpeed = 7;
var i = 0;
var newIcon = document.createElement("img");
newIcon.setAttribute("src", Icon);
function drawIconAtRotation() {
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.translate(Math.ceil(canvas.width / 2), Math.ceil(canvas.height / 2));
canvasContext.scale(rotation, 1);
if (rotation > 0) {
canvasContext.drawImage(newIcon, -Math.ceil(canvas.width / 2), -Math.ceil(canvas.height / 2), canvas.width, canvas.height);
} else {
canvasContext.drawImage(icon, -Math.ceil(canvas.width / 2), -Math.ceil(canvas.height / 2), canvas.width, canvas.height);
}
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width, canvas.height)});
}
function Do() {
rotation += 1 / animationFrames;
drawIconAtRotation();
i++;
if (rotation <= 1) {
setTimeout(Do, animationSpeed);
} else {
rotation = -1;
chrome.browserAction.setIcon({path:{19:newIcon.src}});
icon = newIcon;
}
}
Do();
};
this.slideRightChange = function(Icon) {
var rotation = 0;
var animationFrames = 60;
var animationSpeed = 10;
var newIcon = document.createElement("img");
newIcon.setAttribute("src", Icon);
function drawIconAtRotation() {
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width + canvas.width, canvas.height);
var position = canvas.width * rotation;
canvasContext.translate(position, 0);
canvasContext.drawImage(icon, 0, 0, canvas.width, canvas.height);
canvasContext.drawImage(newIcon, -canvas.width, 0, canvas.width, canvas.height);
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width, canvas.height)});
}
function Do() {
drawIconAtRotation();
rotation += 1 / animationFrames;
if (rotation <= 1) {
setTimeout(Do, animationSpeed);
} else {
rotation = 0;
chrome.browserAction.setIcon({path:{19:newIcon.src}});
icon = newIcon;
}
}
Do();
};
this.slideLeftChange = function(Icon) {
var rotation = 0;
var animationFrames = 60;
var animationSpeed = 10;
var newIcon = document.createElement("img");
newIcon.setAttribute("src", Icon);
function drawIconAtRotation() {
canvasContext.save();
canvasContext.clearRect(0, 0, canvas.width + canvas.width, canvas.height);
var position = canvas.width * rotation;
canvasContext.translate(position, 0);
canvasContext.drawImage(icon, 0, 0, canvas.width, canvas.height);
canvasContext.drawImage(newIcon, canvas.width, 0, canvas.width, canvas.height);
canvasContext.restore();
chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width, canvas.height)});
}
function Do() {
drawIconAtRotation();
rotation -= 1 / animationFrames;
if (rotation >= -1) {
setTimeout(Do, animationSpeed);
} else {
rotation = 0;
chrome.browserAction.setIcon({path:{19:newIcon.src}});
icon = newIcon;
}
}
Do();
};
}
;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,170 @@
(function($) {
$.fn.ddslick = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else {
if (typeof method === "object" || !method) {
return methods.init.apply(this, arguments);
} else {
$.error("Method " + method + " does not exists.");
}
}
};
var methods = {}, defaults = {data:[], keepJSONItemsOnTop:false, width:260, height:null, background:"#eee", selectText:"", defaultSelectedIndex:null, truncateDescription:true, imagePosition:"left", showSelectedHTML:true, clickOffToClose:true, onSelected:function() {
}}, ddSelectHtml = '<div class="dd-select"><input class="dd-selected-value" type="hidden" /><a class="dd-selected"></a><span class="dd-pointer dd-pointer-down"></span></div>', ddOptionsHtml = '<ul class="dd-options" style=""></ul>', ddslickCSS = '<style id="css-ddslick" type="text/css">' + ".dd-select{ border-radius:3px; border:solid 1px #ccc; position:relative; cursor:pointer;}" + ".dd-desc { color:#aaa; display:block; overflow: hidden; font-weight:normal; line-height: 1.4em; }" + ".dd-selected{line-height: 14px; font-size:14px; overflow:hidden; display:block; padding:3px 5px 3px 5px; font-weight:bold;}" +
".dd-pointer{ width:0; height:0; position:absolute; right:5px; top:50%; margin-top:-3px;}" + ".dd-pointer-down{ border:solid 5px transparent; border-top:solid 5px #000; }" + ".dd-pointer-up{border:solid 5px transparent !important; border-bottom:solid 5px #000 !important; margin-top:-8px;}" + ".dd-options{ border:solid 1px #ccc; border-top:none; list-style:none; box-shadow:0px 1px 5px #ddd; display:none; position:absolute; z-index:2000; margin:0; padding:0;background:#fff; overflow:auto;}" + ".dd-option{ line-height: 16px; font-size:12px; padding:10px; display:block; border-bottom:solid 1px #ddd; overflow:hidden; text-decoration:none; color:#333; cursor:pointer;-webkit-transition: all 0.25s ease-in-out; -moz-transition: all 0.25s ease-in-out;-o-transition: all 0.25s ease-in-out;-ms-transition: all 0.25s ease-in-out; }" +
".dd-options > li:last-child > .dd-option{ border-bottom:none;}" + ".dd-option:hover{ background:#ddd; color:#000;}" + ".dd-selected-description-truncated { text-overflow: ellipsis; white-space:nowrap; }" + ".dd-option-selected { background:#f6f6f6; }" + ".dd-option-image, .dd-selected-image { vertical-align:middle; float:left; margin-right:5px; max-width:64px;}" + ".dd-image-right { float:right; margin-right:15px; margin-left:5px;}" + "a.dd-option {text-decoration: none;}" + ".dd-container{ position:relative;}\u200b .dd-selected-text { font-weight:bold}\u200b</style>";
if ($("#css-ddslick").length <= 0) {
$(ddslickCSS).appendTo("head");
}
methods.init = function(options) {
var options = $.extend({}, defaults, options);
return this.each(function() {
var obj = $(this), data = obj.data("ddslick");
if (!data) {
var ddSelect = [], ddJson = options.data;
obj.find("option").each(function() {
var $this = $(this), thisData = $this.data();
ddSelect.push({text:$.trim($this.text()), value:$this.val(), selected:$this.is(":selected"), description:thisData.description, ico:thisData.ico, imageSrc:thisData.imagesrc});
});
if (options.keepJSONItemsOnTop) {
$.merge(options.data, ddSelect);
} else {
options.data = $.merge(ddSelect, options.data);
}
var original = obj, placeholder = $('<div id="' + obj.attr("id") + '"></div>');
obj.replaceWith(placeholder);
obj = placeholder;
obj.addClass("dd-container").append(ddSelectHtml).append(ddOptionsHtml);
var ddSelect = obj.find(".dd-select"), ddOptions = obj.find(".dd-options");
ddOptions.css({width:options.width});
ddSelect.css({width:options.width, background:options.background});
obj.css({width:options.width});
if (options.height != null) {
ddOptions.css({height:options.height, overflow:"auto"});
}
$.each(options.data, function(index, item) {
if (item.selected) {
options.defaultSelectedIndex = index;
}
ddOptions.append("<li>" + '<a class="dd-option">' + (item.value ? ' <input class="dd-option-value" type="hidden" value="' + item.value + '" />' : "") + (item.imageSrc ? ' <img class="dd-option-image' + (options.imagePosition == "right" ? " dd-image-right" : "") + '" src="' + item.imageSrc + '" />' : "") + (item.ico ? '<i class="uk-text-bold uk-icon-' + item.ico + '"></i>' : "") + (item.text ? ' <label class="dd-option-text">' + item.text + "</label>" : "") + (item.description ? ' <small class="dd-option-description dd-desc">' +
item.description + "</small>" : "") + "</a>" + "</li>");
});
var pluginData = {settings:options, original:original, selectedIndex:-1, selectedItem:null, selectedData:null};
obj.data("ddslick", pluginData);
if (options.selectText.length > 0 && options.defaultSelectedIndex == null) {
obj.find(".dd-selected").html(options.selectText);
} else {
var index = options.defaultSelectedIndex != null && options.defaultSelectedIndex >= 0 && options.defaultSelectedIndex < options.data.length ? options.defaultSelectedIndex : 0;
selectIndex(obj, index);
}
obj.find(".dd-select").on("click.ddslick", function() {
open(obj);
});
obj.find(".dd-option").on("click.ddslick", function() {
selectIndex(obj, $(this).closest("li").index());
});
if (options.clickOffToClose) {
ddOptions.addClass("dd-click-off-close");
obj.on("click.ddslick", function(e) {
e.stopPropagation();
});
$("body").on("click", function() {
$(".dd-click-off-close").slideUp(50).siblings(".dd-select").find(".dd-pointer").removeClass("dd-pointer-up");
});
}
}
});
};
methods.select = function(options) {
return this.each(function() {
if (options.index) {
selectIndex($(this), options.index);
}
});
};
methods.open = function() {
return this.each(function() {
var $this = $(this), pluginData = $this.data("ddslick");
if (pluginData) {
open($this);
}
});
};
methods.close = function() {
return this.each(function() {
var $this = $(this), pluginData = $this.data("ddslick");
if (pluginData) {
close($this);
}
});
};
methods.destroy = function() {
return this.each(function() {
var $this = $(this), pluginData = $this.data("ddslick");
if (pluginData) {
var originalElement = pluginData.original;
$this.removeData("ddslick").unbind(".ddslick").replaceWith(originalElement);
}
});
};
function selectIndex(obj, index) {
var pluginData = obj.data("ddslick");
var ddSelected = obj.find(".dd-selected"), ddSelectedValue = ddSelected.siblings(".dd-selected-value"), ddOptions = obj.find(".dd-options"), ddPointer = ddSelected.siblings(".dd-pointer"), selectedOption = obj.find(".dd-option").eq(index), selectedLiItem = selectedOption.closest("li"), settings = pluginData.settings, selectedData = pluginData.settings.data[index];
obj.find(".dd-option").removeClass("dd-option-selected");
selectedOption.addClass("dd-option-selected");
pluginData.selectedIndex = index;
pluginData.selectedItem = selectedLiItem;
pluginData.selectedData = selectedData;
if (settings.showSelectedHTML) {
ddSelected.html((selectedData.ico ? '<i class="uk-text-bold uk-icon-' + selectedData.ico + '"></i>' : "") + (selectedData.imageSrc ? '<img class="dd-selected-image' + (settings.imagePosition == "right" ? " dd-image-right" : "") + '" src="' + selectedData.imageSrc + '" />' : "") + (selectedData.text ? '<label class="dd-selected-text">' + selectedData.text + "</label>" : "") + (selectedData.description ? '<small class="dd-selected-description dd-desc' + (settings.truncateDescription ? " dd-selected-description-truncated" :
"") + '" >' + selectedData.description + "</small>" : ""));
} else {
ddSelected.html(selectedData.text);
}
ddSelectedValue.val(selectedData.value);
pluginData.original.val(selectedData.value);
obj.data("ddslick", pluginData);
close(obj);
adjustSelectedHeight(obj);
if (typeof settings.onSelected == "function") {
settings.onSelected.call(this, pluginData);
}
}
function open(obj) {
var $this = obj.find(".dd-select"), ddOptions = $this.siblings(".dd-options"), ddPointer = $this.find(".dd-pointer"), wasOpen = ddOptions.is(":visible");
$(".dd-click-off-close").not(ddOptions).slideUp(50);
$(".dd-pointer").removeClass("dd-pointer-up");
if (wasOpen) {
ddOptions.slideUp("fast");
ddPointer.removeClass("dd-pointer-up");
} else {
ddOptions.slideDown("fast");
ddPointer.addClass("dd-pointer-up");
}
adjustOptionsHeight(obj);
}
function close(obj) {
obj.find(".dd-options").slideUp(50);
obj.find(".dd-pointer").removeClass("dd-pointer-up").removeClass("dd-pointer-up");
}
function adjustSelectedHeight(obj) {
var lSHeight = obj.find(".dd-select").css("height");
var descriptionSelected = obj.find(".dd-selected-description");
var imgSelected = obj.find(".dd-selected-image");
if (descriptionSelected.length <= 0 && imgSelected.length > 0) {
}
}
function adjustOptionsHeight(obj) {
obj.find(".dd-option").each(function() {
var $this = $(this);
var lOHeight = $this.css("height");
var descriptionOption = $this.find(".dd-option-description");
var imgOption = obj.find(".dd-option-image");
if (descriptionOption.length <= 0 && imgOption.length > 0) {
$this.find(".dd-option-text").css("lineHeight", lOHeight);
}
});
}
})(jQuery);

View File

@ -0,0 +1,18 @@
$.fn.scrollTo = function(target, options, callback) {
if (typeof options == "function" && arguments.length == 2) {
callback = options;
options = target;
}
var settings = $.extend({scrollTarget:target, offsetTop:130, duration:500, easing:"swing"}, options);
return this.each(function() {
var scrollPane = $(this);
var scrollTarget = typeof settings.scrollTarget == "number" ? settings.scrollTarget : $(settings.scrollTarget);
var scrollY = typeof scrollTarget == "number" ? scrollTarget : scrollTarget.offset().top + scrollPane.scrollTop() - parseInt(settings.offsetTop);
scrollPane.animate({scrollTop:scrollY}, parseInt(settings.duration), settings.easing, function() {
if (typeof callback == "function") {
callback.call(this);
}
});
});
};

View File

@ -0,0 +1,46 @@
nl.drew.cp.lang = function() {
var lang = {};
lang.s = {"en":{}, "ru":{}};
lang.user = "";
lang.chrome = "";
lang.init = function() {
if (nl.drew.cp.ls.isset("lang")) {
nl.drew.cp.lang.user = nl.drew.cp.ls.get("lang", false);
}
};
lang.l = function(m) {
var nowLang = this.getLang();
if (typeof nl.drew.cp.lang.s[nowLang] == "undefined") {
nowLang = "en";
if (typeof nl.drew.cp.lang.s[nowLang] == "undefined") {
return "not found iteam";
}
}
if (typeof nl.drew.cp.lang.s[nowLang][m] == "undefined") {
nowLang = "en";
if (typeof nl.drew.cp.lang.s[nowLang][m] == "undefined") {
return "not found iteam";
}
}
return nl.drew.cp.lang.s[nowLang][m];
};
lang.getLang = function() {
if (nl.drew.cp.lang.user) {
return nl.drew.cp.lang.user;
}
var chromeLang = chrome.i18n.getUILanguage();
if (chromeLang.substr(2).toLowerCase() == "en") {
return "en";
} else {
if (chromeLang.substr(2).toLowerCase() == "ru") {
return "ru";
}
}
};
lang.setLang = function(l) {
nl.drew.cp.lang.user = l;
nl.drew.cp.ls.set("lang", l, false);
};
return lang;
}();

View File

@ -0,0 +1,260 @@
if (!nl) {
var nl = {}
}
if (!nl.drew) {
nl.drew = {};
}
if (!nl.drew.cp) {
nl.drew.cp = {};
}
nl.drew.cp.lib = function() {
var lib = {};
lib.l = function(m) {
return chrome.i18n.getMessage(m);
};
lib.checkProxyUrl = function(addr) {
var ipSplit = addr.split(/\:/g);
if (typeof ipSplit[1] != "undefined") {
if (ipSplit[1] < 65535 && ipSplit[1] > 0) {
if (this.isipv4(ipSplit[0]) || this.isipv6(ipSplit[0])) {
return{ip:ipSplit[0], port:ipSplit[1]};
}
var purl;
if ((purl = this.parseUrl(ipSplit[0])) != false || (purl = this.parseUrl("http://" + ipSplit[0])) != false) {
return{ip:purl.host, port:ipSplit[1]};
}
}
}
return false;
};
lib.isipv4 = function(addr) {
if (/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(addr)) {
return true;
}
return false;
};
lib.isipv6 = function(addr) {
var ipSplit = addr.split(/\]:/g);
if (typeof ipSplit[1] != "undefined") {
if (ipSplit[1] < 65535 && ipSplit[1] > 0) {
ipSplit = ipSplit[0].split(/\[/g);
if (typeof ipSplit[1] != "undefined") {
return/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i.test(ipSplit[1]);
}
}
}
return false;
};
lib.ReqJson = function(url, timeout, onSuccess, onError, onTimeout, type, data) {
if (!type) {
type = "GET";
}
if (!data) {
data = null;
}
var xhr = new XMLHttpRequest;
xhr.onabort = function() {
onError("abort");
};
xhr.ontimeout = function() {
onTimeout("onTimeout");
};
xhr.onerror = function() {
onError(xhr.status + " " + xhr.statusText);
};
xhr.onload = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
onSuccess(xhr.response);
} else {
onError(xhr.status);
}
}
};
try {
xhr.open(type, url, true);
} catch (e) {
return;
}
if (type == "POST") {
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
xhr.timeout = timeout;
try {
xhr.send(data);
} catch (e) {
return;
}
};
lib.urlvalid = new RegExp("^" + "(?:(?:https?|ftp)://)" + "(?:\\S+(?::\\S*)?@)?" + "(?:" + "(?!(?:10|127)(?:\\.\\d{1,3}){3})" + "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" + "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" + "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" + "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" + "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" + "|" + "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" + "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" + ")" + "(?::\\d{2,5})?" + "(?:/\\S*)?" + "$", "i");
lib.debug = function(mess) {
if (nl.drew.cp.config.isDebug) {
if (typeof mess != "number" && typeof mess != "string") {
mess = JSON.stringify(mess);
}
console.log(mess);
}
return nl.drew.cp.config.isDebug;
};
lib.clone = function(obj) {
if (obj == null || typeof obj != "object") {
return obj;
}
var temp = {};
for (var key in obj) {
temp[key] = nl.drew.cp.lib.clone(obj[key]);
}
return temp;
};
lib.time = function() {
return parseInt((new Date).getTime() / 1E3);
};
lib.timems = function() {
return parseInt((new Date).getTime());
};
lib.parseUrl = function(url) {
if (!nl.drew.cp.lib.urlvalid.test(url)) {
return false;
}
try {
var purl = new URL(url);
} catch (e) {
return false;
}
if (purl.protocol == "http:" || purl.protocol == "https:") {
purl.allow = true;
} else {
purl.allow = false;
}
return nl.drew.cp.lib.clone(purl);
};
lib.generatePW = function(c) {
var i, s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", pw = "";
if (!c) {
c = 16;
}
for (i = 0;i < c;i++) {
pw += s.charAt(Math.random() * 61);
}
return pw;
};
lib.sIncrease = function(i, ii) {
if (i > ii) {
return 1;
} else {
if (i < ii) {
return-1;
} else {
return 0;
}
}
};
lib.sDecrease = function(i, ii) {
if (i > ii) {
return-1;
} else {
if (i < ii) {
return 1;
} else {
return 0;
}
}
};
lib.naturalSort = function(array, extractor) {
var splitters = array.map(makeSplitter);
var sorted = splitters.sort(compareSplitters);
return sorted.map(function(splitter) {
return splitter.item;
});
function makeSplitter(item) {
return new Splitter(item);
}
function Splitter(item) {
var index = 0;
var from = 0;
var parts = [];
var completed = false;
this.item = item;
var key = typeof extractor === "function" ? extractor(item) : item;
this.key = key;
this.count = function() {
return parts.length;
};
this.part = function(i) {
while (parts.length <= i && !completed) {
next();
}
return i < parts.length ? parts[i] : null;
};
function next() {
if (index < key.length) {
while (++index) {
var currentIsDigit = isDigit(key.charAt(index - 1));
var nextChar = key.charAt(index);
var currentIsLast = index === key.length;
var isBorder = currentIsLast || xor(currentIsDigit, isDigit(nextChar));
if (isBorder) {
var partStr = key.slice(from, index);
parts.push(new Part(partStr, currentIsDigit));
from = index;
break;
}
}
} else {
completed = true;
}
}
function Part(text, isNumber) {
this.isNumber = isNumber;
this.value = isNumber ? Number(text) : text;
}
}
function compareSplitters(sp1, sp2) {
var i = 0;
do {
var first = sp1.part(i);
var second = sp2.part(i);
if (null !== first && null !== second) {
if (xor(first.isNumber, second.isNumber)) {
return first.isNumber ? -1 : 1;
} else {
var comp = compare(first.value, second.value);
if (comp != 0) {
return comp;
}
}
} else {
return compare(sp1.count(), sp2.count());
}
} while (++i);
function compare(a, b) {
return a < b ? -1 : a > b ? 1 : 0;
}
}
function xor(a, b) {
return a ? !b : b;
}
function isDigit(chr) {
var code = charCode(chr);
return code >= charCode("0") && code <= charCode("9");
function charCode(ch) {
return ch.charCodeAt(0);
}
}
};
lib.quickquickInArray = function(it, arr) {
var i;
while (i = arr.shift()) {
if (i.host == it) {
return i;
}
}
return false;
};
lib.isNumeric = function(obj) {
return typeof obj != "array" && obj - parseFloat(obj) + 1 >= 0;
};
return lib;
}();

View File

@ -0,0 +1,212 @@
if (!nl) {
var nl = {}
}
if (!nl.drew) {
nl.drew = {};
}
if (!nl.drew.cp) {
nl.drew.cp = {};
}
nl.drew.cp.ls = function() {
var ls = {};
ls.isset = function(key) {
if (typeof localStorage[key] != "undefined") {
return true;
} else {
return false;
}
};
ls.get = function(key, enc) {
if (localStorage.getItem(key) !== null) {
if (enc) {
var denc = XXTEA.decrypt(localStorage.getItem(key), enc);
if (denc) {
return JSON.parse(Utf8.decode(denc));
} else {
return "";
}
} else {
return JSON.parse(localStorage.getItem(key));
}
} else {
return null;
}
};
ls.set = function(key, val, enc) {
val = JSON.stringify(val);
if (enc) {
val = XXTEA.encrypt(Utf8.encode(val), enc);
}
localStorage.setItem(key, val);
};
ls.del = function(key) {
localStorage.removeItem(key);
};
ls.getAll = function() {
ret = {};
Object.each(localStorage, function(value, host) {
try {
ret[host] = JSON.parse(value);
} catch (e) {
}
});
return ret;
};
return ls;
}();
var delta = 2654435769;
function longArrayToString(data, includeLength) {
var length = data.length, n = length - 1 << 2;
if (includeLength) {
var m = data[length - 1];
if (m < n - 3 || m > n) {
return null;
}
n = m;
}
for (var i = 0;i < length;++i) {
data[i] = String.fromCharCode(data[i] & 255, data[i] >>> 8 & 255, data[i] >>> 16 & 255, data[i] >>> 24 & 255);
}
if (includeLength) {
return data.join("").substring(0, n);
} else {
return data.join("");
}
}
function stringToLongArray(string, includeLength) {
var length = string.length;
var result = [];
for (var i = 0;i < length;i += 4) {
result[i >> 2] = string.charCodeAt(i) | string.charCodeAt(i + 1) << 8 | string.charCodeAt(i + 2) << 16 | string.charCodeAt(i + 3) << 24;
}
if (includeLength) {
result[result.length] = length;
}
return result;
}
var XXTEA = {encrypt:function(string, key) {
if (string == "") {
return "";
}
var v = stringToLongArray(string, true), k = stringToLongArray(key, false), n = v.length - 1, z = v[n], y = v[0], mx, e, p, q = Math.floor(6 + 52 / (n + 1)), sum = 0;
if (k.length < 4) {
k.length = 4;
}
while (0 <= --q) {
sum = sum + delta & 4294967295;
e = sum >>> 2 & 3;
for (p = 0;p < n;++p) {
y = v[p + 1];
mx = (z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z);
z = v[p] = v[p] + mx & 4294967295;
}
y = v[0];
mx = (z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z);
z = v[n] = v[n] + mx & 4294967295;
}
return longArrayToString(v, false);
}, decrypt:function(string, key) {
if (string == "") {
return "";
}
var v = stringToLongArray(string, false);
var k = stringToLongArray(key, false);
if (k.length < 4) {
k.length = 4;
}
var n = v.length - 1;
var z = v[n - 1], y = v[0];
var mx, e, p, q = Math.floor(6 + 52 / (n + 1)), sum = q * delta & 4294967295;
while (sum != 0) {
e = sum >>> 2 & 3;
for (p = n;p > 0;--p) {
z = v[p - 1];
mx = (z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z);
y = v[p] = v[p] - mx & 4294967295;
}
z = v[n];
mx = (z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z);
y = v[0] = v[0] - mx & 4294967295;
sum = sum - delta & 4294967295;
}
return longArrayToString(v, true);
}};
var Base64 = {};
Base64.code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
Base64.encode = function(str, utf8encode) {
utf8encode = typeof utf8encode == "undefined" ? false : utf8encode;
var o1, o2, o3, bits, h1, h2, h3, h4, e = [], pad = "", c, plain, coded;
var b64 = Base64.code;
plain = utf8encode ? Utf8.encode(str) : str;
c = plain.length % 3;
if (c > 0) {
while (c++ < 3) {
pad += "=";
plain += "\x00";
}
}
for (c = 0;c < plain.length;c += 3) {
o1 = plain.charCodeAt(c);
o2 = plain.charCodeAt(c + 1);
o3 = plain.charCodeAt(c + 2);
bits = o1 << 16 | o2 << 8 | o3;
h1 = bits >> 18 & 63;
h2 = bits >> 12 & 63;
h3 = bits >> 6 & 63;
h4 = bits & 63;
e[c / 3] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
}
coded = e.join("");
coded = coded.slice(0, coded.length - pad.length) + pad;
return coded;
};
Base64.decode = function(str, utf8decode) {
str = str.replace(/\n/gm, "");
utf8decode = typeof utf8decode == "undefined" ? false : utf8decode;
var o1, o2, o3, h1, h2, h3, h4, bits, d = [], plain, coded;
var b64 = Base64.code;
coded = utf8decode ? Utf8.decode(str) : str;
for (var c = 0;c < coded.length;c += 4) {
h1 = b64.indexOf(coded.charAt(c));
h2 = b64.indexOf(coded.charAt(c + 1));
h3 = b64.indexOf(coded.charAt(c + 2));
h4 = b64.indexOf(coded.charAt(c + 3));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >>> 16 & 255;
o2 = bits >>> 8 & 255;
o3 = bits & 255;
d[c / 4] = String.fromCharCode(o1, o2, o3);
if (h4 == 64) {
d[c / 4] = String.fromCharCode(o1, o2);
}
if (h3 == 64) {
d[c / 4] = String.fromCharCode(o1);
}
}
plain = d.join("");
return utf8decode ? Utf8.decode(plain) : plain;
};
var Utf8 = {};
Utf8.encode = function(strUni) {
var strUtf = strUni.replace(/[\u0080-\u07ff]/g, function(c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(192 | cc >> 6, 128 | cc & 63);
});
strUtf = strUtf.replace(/[\u0800-\uffff]/g, function(c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(224 | cc >> 12, 128 | cc >> 6 & 63, 128 | cc & 63);
});
return strUtf;
};
Utf8.decode = function(strUtf) {
var strUni = strUtf.replace(/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, function(c) {
var cc = (c.charCodeAt(0) & 15) << 12 | (c.charCodeAt(1) & 63) << 6 | c.charCodeAt(2) & 63;
return String.fromCharCode(cc);
});
strUni = strUni.replace(/[\u00c0-\u00df][\u0080-\u00bf]/g, function(c) {
var cc = (c.charCodeAt(0) & 31) << 6 | c.charCodeAt(1) & 63;
return String.fromCharCode(cc);
});
return strUni;
};

View File

@ -0,0 +1,184 @@
(function($, undefined) {
var pluginName = "switcher";
var defaults = {className:"switcher", selected:null, language:"en", disabled:null, style:"default", copy:{en:{yes:"yes", no:"no"}, fr:{yes:"oui", no:"non"}}};
function Plugin(element, options) {
this.input = element;
this.container = null;
this.settings = $.extend({}, defaults, $(element).data(), options);
this._defaults = defaults;
this._name = pluginName;
this.init();
}
$.extend(Plugin.prototype, {init:function() {
this.buildHtml(this.input, this.settings);
this.bindEvents(this.container, this.settings);
}, buildHtml:function(input, settings) {
var self = this;
var $input = $(input);
$input.wrap('<div class="' + settings.className + " " + settings.style + '"></div>');
$input.after('<div class="content clearfix">' + '<div class="slider"></div>' + '<span class="text textYes"></span>' + '<span class="text textNo"></span>' + "</div>");
this.container = $($input).parent("." + settings.className)[0];
self.setLanguage(settings.language);
self.setValue(settings.selected);
self.setDisabled(settings.disabled);
}, bindEvents:function(container, settings) {
var self = this;
var $container = $(container);
var $input = $container.find("input");
$container.on("click", function(e) {
if (settings.disabled) {
return;
}
if ($input.attr("type") == "radio") {
self.setValue(true);
} else {
if ($container.closest("label").length) {
self.setValue($input.prop("checked"));
} else {
self.setValue(!$input.prop("checked"));
}
}
});
$container.on("swipeleft", function() {
if (settings.disabled) {
return;
}
self.setValue(false);
});
$container.on("swiperight", function() {
if (settings.disabled) {
return;
}
self.setValue(true);
});
}, setValue:function(val) {
var self = this;
var $input = $(self.input);
var $container = $(self.container);
if (val === null) {
if ($input.attr("type") == "radio") {
val = typeof $input.filter(":checked").val() !== "undefined";
} else {
val = $input.prop("checked");
}
}
if (typeof val != "boolean") {
return console.log("The parameter need to be true or false as a boolean");
}
self.settings.selected = val;
$input.prop("checked", val).trigger("change");
if ($input.attr("type") == "radio") {
var name = $input.attr("name");
var $inputGroup = $('input[name="' + name + '"]');
var $containerGroup = $inputGroup.parent("." + self.settings.className);
if (val === true) {
$containerGroup.removeClass("is-active");
$inputGroup.prop("checked", false);
$container.addClass("is-active");
$input.prop("checked", true);
}
} else {
if (val === true) {
$container.addClass("is-active");
} else {
$container.removeClass("is-active");
}
}
}, setDisabled:function(val) {
var self = this;
var $input = $(self.input);
var $container = $(self.container);
if (val === null) {
if ($input.attr("disabled")) {
val = true;
} else {
val = false;
}
}
if (typeof val != "boolean") {
return console.log("The parameter need to be true or false as a boolean");
}
self.settings.disabled = val;
if (val === true) {
$container.addClass("is-disabled");
} else {
$container.removeClass("is-disabled");
}
}, setLanguage:function(language) {
var self = this;
var $container = $(self.container);
self.settings.language = language;
$container.find(".textYes").text(self.settings.copy[language].yes);
$container.find(".textNo").text(self.settings.copy[language].no);
}, getLanguage:function(callback) {
var self = this;
return callback(self.settings.language);
}, importLanguage:function(languageObj) {
var self = this;
self.settings.copy = languageObj;
}});
$.fn[pluginName] = function(options) {
var args = Array.prototype.slice.call(arguments, 1);
this.each(function() {
var $item = $(this);
var instance = $item.data("plugin_" + pluginName);
if (!instance) {
$item.data("plugin_" + pluginName, new Plugin(this, options));
} else {
if (typeof options === "string") {
instance[options].apply(instance, args);
}
}
});
return this;
};
var startX = 0;
var startY = 0;
var moving = false;
var threshold = 30;
function onTouchEnd() {
this.removeEventListener("touchmove", onTouchMove);
this.removeEventListener("touchend", onTouchEnd);
moving = false;
}
function onTouchMove(e) {
e.preventDefault();
if (moving) {
var x = e.touches[0].pageX;
var y = e.touches[0].pageY;
var dx = startX - x;
var dy = startY - y;
var direction = null;
if (Math.abs(dx) >= threshold) {
direction = dx > 0 ? "left" : "right";
} else {
if (Math.abs(dy) >= threshold) {
direction = dy > 0 ? "down" : "up";
}
}
if (direction) {
onTouchEnd.call(this);
$(this).trigger("swipe", direction).trigger("swipe" + direction);
}
}
}
function onTouchStart(e) {
if (e.touches.length == 1) {
startX = e.touches[0].pageX;
startY = e.touches[0].pageY;
moving = true;
this.addEventListener("touchmove", onTouchMove, false);
this.addEventListener("touchend", onTouchEnd, false);
}
}
function setup() {
this.addEventListener && this.addEventListener("touchstart", onTouchStart, false);
}
$.event.special.swipe = {setup:setup};
$.each(["left", "up", "down", "right"], function() {
$.event.special["swipe" + this] = {setup:function() {
$(this).on("swipe", $.noop);
}};
});
})($);

View File

@ -0,0 +1,290 @@
nl.drew.cp.popup.api = function() {
var api = {};
api.setapi = function() {
nl.drew.cp.popup.portToExt = chrome.runtime.connect({name:"popup"});
nl.drew.cp.popup.portToExt.onMessage.addListener(function(msg) {
if (typeof msg.param != "undefined") {
if (msg.param == "https") {
} else {
if (msg.param == "uproxy") {
if (typeof msg.val == "undefined" && typeof msg.val.uproxy == "undefined") {
return null;
}
var list = msg.val.uproxy;
list.sort(function(i, ii) {
if (i.host > ii.host) {
return-1;
} else {
if (i.host < ii.host) {
return 1;
} else {
return 0;
}
}
});
var len = list.length;
nl.drew.cp.popup.uproxys.listShow(list, msg.val.template, nl.drew.cp.popup.pagenumuproxy, len);
if (len > 10) {
var pagination = $.UIkit.pagination("#proxytable2", {items:len, itemsOnPage:nl.drew.cp.popup.listOnPage, displayedPages:3, edges:2});
pagination.on("uk.pagination.select", function(e, pageIndex) {
nl.drew.cp.popup.pagenumuproxy = pageIndex;
nl.drew.cp.popup.uproxys.listShow(list, pageIndex, len);
});
}
} else {
if (msg.param == "lists") {
if (typeof msg.val == "undefined") {
return null;
}
var list = msg.val;
var hostScroll = msg.host;
nl.drew.cp.popup.lists.listShow(list, nl.drew.cp.popup.pagenum, hostScroll);
} else {
if (msg.param == "globalalwproxy") {
if (typeof msg.val == "undefined") {
return null;
}
if (!nl.drew.cp.popup.globalalwproxySW) {
nl.drew.cp.popup.globalalwproxySW = $("#globalalwproxy").switcher({style:"short", selected:msg.val, disabled:false});
nl.drew.cp.popup.main.globalalwproxychangeset(nl.drew.cp.popup.globalalwproxySW);
} else {
if ($("#globalalwproxy").prop("checked") != msg.val) {
nl.drew.cp.popup.globalalwproxySW.switcher("setValue", msg.val);
}
}
} else {
if (msg.param == "tor") {
if (msg.val.all != null) {
if (!nl.drew.cp.popup.torAllSW) {
nl.drew.cp.popup.torAllSW = $("#torall").switcher({style:"short", selected:msg.val.all, disabled:false});
nl.drew.cp.popup.main.torchangeset(nl.drew.cp.popup.torAllSW);
} else {
if (typeof msg.val.all != "undefined") {
if ($("#torall").prop("checked") != msg.val.all) {
nl.drew.cp.popup.torAllSW.switcher("setValue", msg.val.all);
}
}
}
}
if (msg.val.site != null) {
if (!nl.drew.cp.popup.torSiteSW) {
nl.drew.cp.popup.torSiteSW = $("#torsite").switcher({style:"short", selected:msg.val.site, disabled:false});
nl.drew.cp.popup.main.torsitechangeset(nl.drew.cp.popup.torSiteSW);
} else {
if (typeof msg.val.site != "undefined") {
if ($("#torsite").prop("checked") != msg.val.site) {
nl.drew.cp.popup.torSiteSW.switcher("setValue", msg.val.site);
}
}
}
}
} else {
if (msg.param == "anonymity") {
if (msg.val.all != null) {
if (!nl.drew.cp.popup.anonymityallSW) {
nl.drew.cp.popup.anonymityallSW = $("#anonymityall").switcher({style:"short", selected:msg.val.all, disabled:false});
nl.drew.cp.popup.main.anonymitychangeset(nl.drew.cp.popup.anonymityallSW);
} else {
if (typeof msg.val.all != "undefined") {
if ($("#anonymityall").prop("checked") != msg.val.all) {
nl.drew.cp.popup.anonymityallSW.switcher("setValue", msg.val.all);
}
}
}
}
if (msg.val.site != null) {
if (nl.drew.cp.popup.host != msg.val.host) {
return;
}
if (!nl.drew.cp.popup.anonymitysiteSW) {
nl.drew.cp.popup.anonymitysiteSW = $("#anonymitysite").switcher({style:"short", selected:msg.val.site, disabled:false});
nl.drew.cp.popup.main.anonymitysitechangeset(nl.drew.cp.popup.anonymitysiteSW);
} else {
if (typeof msg.val.site != "undefined") {
if ($("#anonymitysite").prop("checked") != msg.val.site) {
nl.drew.cp.popup.anonymitysiteSW.switcher("setValue", msg.val.site);
}
}
}
}
} else {
if (msg.param == "isenabled") {
if (!nl.drew.cp.popup.onoffSW) {
nl.drew.cp.popup.onoffSW = nl.drew.cp.popup.onoffUI.switcher({style:"default", selected:msg.val, language:"en", disabled:false, copy:{en:{yes:nl.drew.cp.lang.l("msgOn"), no:nl.drew.cp.lang.l("msgOff")}}});
nl.drew.cp.popup.main.changeset();
} else {
if (typeof msg.val != "undefined") {
if (nl.drew.cp.popup.onoffUI.prop("checked") != msg.val) {
nl.drew.cp.popup.onoffSW.switcher("setValue", msg.val);
}
}
}
} else {
if (msg.param == "state") {
var state = $("#state");
nl.drew.cp.popup.lib.blinkStop(state);
if (typeof msg.val != "undefined" && msg.val.text) {
state.removeClass("uk-text-muted uk-text-danger uk-text-success uk-text-warning");
state.text(msg.val.text);
if (typeof msg.val.cl != "undefined" && msg.val.cl) {
state.addClass(msg.val.cl);
}
if (typeof msg.val.blink != "undefined" && msg.val.blink) {
nl.drew.cp.popup.lib.blinkStart(state);
}
$("#state-wrap").css("visibility", "visible");
}
} else {
if (msg.param == "mainproxy") {
var mainproxy = $("#mainproxy");
var mainproxyco = $("#mainproxyco");
var mainproxycotext = $("#mainproxycotext div");
var enc = "";
var activetab = 0;
mainproxy.empty();
mainproxyco.empty();
mainproxycotext.empty();
mainproxy.html(nl.drew.cp.lang.l("proxyOff"));
if (typeof msg.val != "undefined" && msg.val && typeof msg.val.name != "undefined" && msg.val.name) {
if (typeof msg.val.ssl != "undefined" && msg.val.ssl) {
enc = '<div class="uk-text-small cp-os-light"><span class="cp-os"><i class="uk-icon-check-circle uk-text-success"></i> spdy</span> over ssl/tls encryption</div>';
}
if (msg.val.co != "unknown" || !msg.val.allow) {
mainproxy.html("<b>" + msg.val.name + "</b>" + enc);
} else {
mainproxy.append('<div class="uk-text-small cp-os-light">' + msg.val.name + "</div>");
}
if (msg.val.co != "unknown" && msg.val.allow) {
activetab = 1;
} else {
$("#sitetab").addClass("uk-disabled");
activetab = 0;
}
if (msg.val.co.length == 2) {
mainproxyco.html('<img src="im/co/' + msg.val.co + '.png">');
} else {
if (msg.val.co == "public") {
mainproxyco.html('<img src="im/co/p.png">');
} else {
mainproxyco.html('<img src="im/co/unknown.png">');
}
}
if (msg.val.co != "unknown") {
mainproxycotext.text(msg.val.co);
}
}
if (typeof msg.val != "undefined" && msg.val && typeof msg.val.host != "undefined" && msg.val.host) {
activetab = 1;
}
if (!nl.drew.cp.popup.switcher) {
nl.drew.cp.popup.switcher = $.UIkit.switcher("#maintabs", {connect:"#configproxy", animation:"fade", active:activetab});
nl.drew.cp.popup.switcher.on("uk.switcher.show", function(event, area) {
if (area[0].id == "liststab") {
$("#listtable").html('<tr><td><i class="uk-icon-spinner uk-icon-spin"></i></td></tr>');
nl.drew.cp.popup.portToExt.postMessage({msg:"get", param:"lists"});
} else {
if (area[0].id == "userprotab") {
$("#proxytable").html('<tr><td><i class="uk-icon-spinner uk-icon-spin"></i></td></tr>');
nl.drew.cp.popup.portToExt.postMessage({msg:"get", param:"uproxy"});
} else {
nl.drew.cp.popup.portToExt.postMessage({msg:"get", param:"contrys", val:{}});
}
}
});
}
} else {
if (msg.param == "contrys") {
var flags = $(".cp-flags");
if (typeof msg.val != "undefined" && msg.val.contrys.length > 0) {
nl.drew.cp.popup.contrys = msg.val.contrys.slice();
flags.show();
nl.drew.cp.popup.lib.buildFlags("flags-all", msg.val.contrys, msg.val.uproxys, msg.val.contrymain);
if (nl.drew.cp.popup.host == msg.val.host) {
nl.drew.cp.popup.lib.buildFlags("flags-site", msg.val.contrys, msg.val.uproxys, msg.val.contrysite, msg.val.host);
}
} else {
flags.children(".cp-flags-content").empty();
flags.hide();
}
$(".uk-icon-spinner").remove();
$("body").css("min-width", "500px").css("min-height", "330px");
$("#main").css("display", "block");
} else {
if (msg.param == "anonymitynow") {
var anonymitynow, tornow;
if (typeof msg.val == "undefined") {
anonymitynow = false;
tornow = false;
} else {
anonymitynow = msg.val[0];
tornow = msg.val[1];
}
var hideip = $("#hideip");
var hideiptext = $("#hideiptext div");
hideip.empty();
hideiptext.empty();
if (tornow) {
hideip.html('<img src="im/onion.png" />');
hideiptext.text("TOR");
} else {
if (anonymitynow) {
hideip.html('<img src="im/hide.png" />');
hideiptext.text("hide ip");
}
}
} else {
if (msg.param == "nonproxyalwproxy") {
if (nl.drew.cp.popup.host != msg.val.host) {
return;
}
var nonproxy;
var alwproxy;
if (typeof msg.val.nonproxy == "undefined") {
nonproxy = false;
} else {
nonproxy = msg.val.nonproxy > -1;
}
if (typeof msg.val.alwproxy == "undefined") {
alwproxy = false;
} else {
alwproxy = msg.val.alwproxy > -1;
}
if (!nl.drew.cp.popup.nonproxySW) {
nl.drew.cp.popup.nonproxySW = $("#nonproxy").switcher({style:"short", selected:nonproxy});
nl.drew.cp.popup.main.nonproxychangeset(nl.drew.cp.popup.nonproxySW);
} else {
if ($("#nonproxy").prop("checked") != nonproxy) {
nl.drew.cp.popup.nonproxySW.switcher("setValue", nonproxy);
}
}
if (!nl.drew.cp.popup.alwproxySW) {
nl.drew.cp.popup.alwproxySW = $("#alwproxy").switcher({style:"short", selected:alwproxy});
nl.drew.cp.popup.main.alwproxychangeset(nl.drew.cp.popup.alwproxySW);
} else {
if ($("#alwproxy").prop("checked") != alwproxy) {
nl.drew.cp.popup.alwproxySW.switcher("setValue", alwproxy);
}
}
if (nonproxy && !alwproxy) {
$("#sitedopsetting").hide();
} else {
$("#sitedopsetting").show();
}
}
}
}
}
}
}
}
}
}
}
}
}
}
});
};
return api;
}();

Some files were not shown because too many files have changed in this diff Show More