This commit is contained in:
Ilya Ig. Petrov 2017-02-05 15:17:59 +00:00
parent 5af9458eae
commit fda42ee307
9 changed files with 66 additions and 53 deletions

View File

@ -1,24 +1,33 @@
module.exports = {
"extends": ["airbnb"],
"env": {
"browser": true,
"webextensions": true,
"es6": true
extends: ['google'],
env: {
browser: true,
webextensions: true,
es6: true
},
"globals": {
"chrome": true
globals: {
chrome: true
},
"parserOptions": {
"sourceType": "script",
"ecmaVersion": 2017,
"ecmaFeatures": {
"impliedStrict": false
parserOptions: {
sourceType: 'script',
ecmaVersion: 2017,
ecmaFeatures: {
impliedStrict: false
}
},
"rules": {
"strict": ["error", "global"],
"no-console": "off",
"padded-blocks": "off",
"require-jsdoc": "off"
}
rules: {
strict: ['error', 'global'],
'no-console': 'off',
'padded-blocks': 'off',
'require-jsdoc': 'off',
// Taken from airbnb:
'max-len': ['error', 100, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
},
};

View File

@ -11,9 +11,6 @@
"license": "GPLv3",
"devDependencies": {
"eslint": "^3.15.0",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0"
"eslint-config-google": "^0.7.1"
}
}

View File

@ -102,7 +102,7 @@
}
localStorage.setItem(key, JSON.stringify(value));
}
};
},

View File

@ -20,7 +20,7 @@
const m = (str.match(ipRe) || []).filter( (c) => c );
const port = m.length > 1 ? m.pop() : false;
return { ifMatched: m.length, port: port };
return {ifMatched: m.length, port: port};
};
@ -57,9 +57,9 @@
const _createHostObj = function _addHostObj(hostStr) {
return (privates._strToHostObj[hostStr] = { host: hostStr });
return (privates._strToHostObj[hostStr] = {host: hostStr});
}
};
const _getHostObj = function _getHostObj(hostStr) {
@ -186,16 +186,16 @@
console.log('Canonized hosts/ips:', hostSet.size + '/' + ipSet.size);
return [ipSet, hostSet];
}
};
const self = window.apis.ipToHost = {
window.apis.ipToHost = {
persist() {
console.log('Persisting ipToHost...', privates);
const ipToHost = {};
for( const ip of Object.keys(privates._ipToHostObj) ) {
ipToHost[ ip ] = privates._ipToHostObj[ ip ].host;
ipToHost[ip] = privates._ipToHostObj[ip].host;
}
_state(ip2host, ipToHost);
@ -247,7 +247,12 @@
console.log('Update all:', hostArr);
const promises = hostArr.map(
(hostStr) => new Promise( (resolve) => this._addAsync(hostStr, (...args) => resolve(args) ) )
(hostStr) => new Promise(
(resolve) => this._addAsync(
hostStr,
(...args) => resolve(args)
)
)
);
Promise.all( promises ).then( (cbsRes) => {

View File

@ -85,7 +85,7 @@
const pacMods = getCurrentConfigs();
return Object.keys(configs).reduce((arr, key) => {
const conf = configs[key]
const conf = configs[key];
if(typeof(conf.index) === 'number') {
arr[conf.index] = conf;
conf.value = pacMods[key];
@ -144,7 +144,7 @@
this.excluded = [];
for(const host of Object.keys(this.exceptions)) {
if (this.exceptions[host]) {
this.included.push(host)
this.included.push(host);
} else {
this.excluded.push(host);
}
@ -320,7 +320,7 @@
return cb(null, res, ...warns);
}
const hosts = par.map( (ps) => ps.split(/\s+/)[1] )
const hosts = par.map( (ps) => ps.split(/\s+/)[1] );
window.apis.ipToHost.replaceAllAsync(
hosts,
(...args) => cb(...args, ...warns)
@ -355,7 +355,7 @@
}
const pacMods = getCurrentConfigs();
pac.data = pacKitchen.cook( pac.data, pacMods );
originalSet({ value: details.value }, (/* No args. */) => {
originalSet({value: details.value}, (/* No args. */) => {
kitchenState(ifIncontinence, null);
cb && cb();

View File

@ -26,7 +26,6 @@
const chromified = window.utils.chromified;
const checkChromeError = window.utils.checkChromeError;
const clarify = window.apis.errorsLib.clarify;
const clarifyThen = window.apis.errorsLib.clarifyThen;
const Warning = window.apis.errorsLib.Warning;
@ -332,7 +331,7 @@
}
const warns = pacWarns;
if (ipsErr) {
warns.push(ipsErr)
warns.push(ipsErr);
}
this.pushToStorageAsync(
(pushErr) => cb(pacErr || pushErr, null, ...warns)

View File

@ -144,11 +144,6 @@
)
);
};
const isInsideTabWithIp = function isInsideTabWithIp(requestDetails) {
};
const onRequest = function onRequest(requestDetails) {

View File

@ -75,7 +75,11 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
return document.getElementById(id);
};
const checkChosenProvider = () => currentProviderRadio().checked = true;
const checkChosenProvider = () => {
currentProviderRadio().checked = true;
};
const showErrors = (err, ...warns) => {
@ -227,14 +231,14 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
const currentTab = await new Promise(
(resolve) => chrome.tabs.query(
{ active: true, currentWindow: true },
{active: true, currentWindow: true},
([tab]) => resolve(tab)
)
);
const ifInsideOptions = !currentTab || currentTab.url.startsWith('chrome://extensions/?options=');
if (ifInsideOptions) {
document.documentElement.classList.add('if-options-page')
document.documentElement.classList.add('if-options-page');
}
// EXCEPTIONS PANEL
@ -347,7 +351,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
excEditor.dataset.moveCursorTo = nu;
window.setTimeout(moveCursorIfNeeded, 0);
}
};
const originalHost = excEditor.value.trim();
const ifInit = !event;
@ -525,7 +529,7 @@ HTTPS foobar.com:3143;
HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''}</textarea>`;
li.querySelector('textarea').onkeyup = function() {
this.dispatchEvent(new Event('change', { 'bubbles': true }));
this.dispatchEvent( new Event('change', {'bubbles': true}) );
};
}
@ -555,14 +559,14 @@ HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''}</tex
.split(/\s*[;\n\r]+\s*/g)
.filter( (str) => str )
.every(
(str) =>
/^(?:DIRECT|(?:(?:HTTPS?|PROXY|SOCKS(?:4|5)?)\s+\S+))$/g
.test(str)
)
(str) =>
/^(?:DIRECT|(?:(?:HTTPS?|PROXY|SOCKS(?:4|5)?)\s+\S+))$/g
.test(str)
);
if (!ifValid) {
return showErrors(new TypeError(
'Неверный формат своих прокси. Свертесь с <a href="https://rebrand.ly/ac-own-proxy" data-in-bg="true">документацией</a>.'
))
));
}
oldMods[customProxyStringKey] = taVal;
} else {
@ -575,7 +579,11 @@ HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''}</tex
'Применяем настройки...',
(cb) => pacKitchen.keepCookedNowAsync(oldMods, cb),
'Настройки применены.',
() => { document.getElementById('apply-mods').disabled = true; }
() => {
document.getElementById('apply-mods').disabled = true;
}
);
};