mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2025-10-29 15:07:42 +03:00
Refactor exception editor behavior, change mods desc
This commit is contained in:
parent
5644fcfbd8
commit
5af9458eae
|
|
@ -1,8 +1,5 @@
|
|||
module.exports = {
|
||||
"extends": ["google"],
|
||||
"plugins": [
|
||||
//"hapi"
|
||||
],
|
||||
"extends": ["airbnb"],
|
||||
"env": {
|
||||
"browser": true,
|
||||
"webextensions": true,
|
||||
|
|
@ -23,6 +20,5 @@ module.exports = {
|
|||
"no-console": "off",
|
||||
"padded-blocks": "off",
|
||||
"require-jsdoc": "off"
|
||||
//"hapi/hapi-scope-start": ["warn"]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,12 +10,10 @@
|
|||
"author": "Ilya Ig. Petrov",
|
||||
"license": "GPLv3",
|
||||
"devDependencies": {
|
||||
"eslint": "^3.11.1",
|
||||
"eslint-config-airbnb": "^13.0.0",
|
||||
"eslint-config-google": "^0.7.1",
|
||||
"eslint-plugin-hapi": "^4.0.0",
|
||||
"eslint": "^3.15.0",
|
||||
"eslint-config-airbnb": "^14.0.0",
|
||||
"eslint-plugin-import": "^2.2.0",
|
||||
"eslint-plugin-jsx-a11y": "^2.2.3",
|
||||
"eslint-plugin-react": "^6.7.1"
|
||||
"eslint-plugin-jsx-a11y": "^3.0.2",
|
||||
"eslint-plugin-react": "^6.9.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,18 @@
|
|||
(res) => {
|
||||
|
||||
const textCb =
|
||||
(err) => res.text().then( (text) => cb(err, text), cb );
|
||||
(err) => {
|
||||
|
||||
console.log('Reading response as text...');
|
||||
res.text().then(
|
||||
(text) => {
|
||||
console.log('Calling CB...');
|
||||
cb(err, text);
|
||||
},
|
||||
cb
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
const status = res.status;
|
||||
if ( !( status >= 200 && status < 300 || status === 304 ) ) {
|
||||
|
|
|
|||
|
|
@ -116,10 +116,12 @@
|
|||
'https://dns.google.com/resolve?type=' + type + '&name=' + host,
|
||||
(err, res) => {
|
||||
|
||||
console.log('After GET...');
|
||||
if (res) {
|
||||
try {
|
||||
console.log('Parsing JSON...');
|
||||
res = JSON.parse(res);
|
||||
console.log('Json parsed.');
|
||||
console.log('JSON parsed.');
|
||||
if (err || res.Status) {
|
||||
const msg = ['Answer', 'Comment', 'Status']
|
||||
.filter( (prop) => res[prop] )
|
||||
|
|
@ -222,7 +224,7 @@
|
|||
|
||||
getIpsFor(hostStr, (err, ips, ...warns) => {
|
||||
|
||||
console.log('IPS', ips, err);
|
||||
console.log('Got IPs + err?:', ips, err);
|
||||
if (!err) {
|
||||
this._purgeOldIpsForSync(hostStr);
|
||||
// Object may be shared, string can't.
|
||||
|
|
@ -233,7 +235,6 @@
|
|||
console.log(privates._ipToHostObj[ip], privates._ipToHostObj);
|
||||
}
|
||||
}
|
||||
console.log('PP', privates._ipToHostObj);
|
||||
return cb(err, null, ...warns);
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
ifProxyHttpsUrlsOnly: {
|
||||
dflt: false,
|
||||
label: 'проксировать только HTTP<em>S</em>-сайты',
|
||||
desc: 'Проксировать только сайты, доступные по шифрованному протоколу httpS. Прокси и провайдер смогут видеть только адреса проксируемых HTTP<em>S</em>-сайтов, но не их содержимое. Используйте, если вы не доверяете прокси-серверам ваш HTTP-трафик. Разумеется, что с этой опцией разблокировка HTTP-сайтов работать не будет.',
|
||||
desc: 'Проксировать только сайты, доступные по шифрованному протоколу HTTP<em>S</em>. Прокси и провайдер смогут видеть только адреса проксируемых HTTP<em>S</em>-сайтов, но не их содержимое. Используйте, если вы не доверяете прокси-серверам ваш HTTP-трафик. Разумеется, что с этой опцией разблокировка HTTP-сайтов работать не будет.',
|
||||
index: 0,
|
||||
},
|
||||
ifUseSecureProxiesOnly: {
|
||||
|
|
@ -140,7 +140,6 @@
|
|||
|
||||
this.included = this.excluded = undefined;
|
||||
if (this.ifMindExceptions && this.exceptions) {
|
||||
console.log('Exceptions:', this.exceptions);
|
||||
this.included = [];
|
||||
this.excluded = [];
|
||||
for(const host of Object.keys(this.exceptions)) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
}
|
||||
em {
|
||||
font-style: normal;
|
||||
border-bottom: 1px solid black;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* COMMON 1 */
|
||||
|
|
@ -227,7 +227,8 @@
|
|||
.desc:hover .tooltip {
|
||||
display: block;
|
||||
}
|
||||
.tooltip a {
|
||||
.tooltip a,
|
||||
.tooltip em {
|
||||
color: white;
|
||||
}
|
||||
.desc .tooltip:after {
|
||||
|
|
@ -377,7 +378,6 @@
|
|||
</section>
|
||||
<section data-for="acc-exc" class="hidden-for-options-page">
|
||||
|
||||
|
||||
<div>Проксировать указанный сайт?</div>
|
||||
<div id="exc-address">
|
||||
<span>*.</span><input placeholder="navalny.com" list="exc-list" name="browser" id="exc-editor" style=""/>
|
||||
|
|
|
|||
|
|
@ -258,24 +258,25 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
|
||||
};
|
||||
|
||||
const ifProxyHtml = '✔';
|
||||
const ifNotProxyHtml = '✘';
|
||||
const ifAutoHtml = '🔄';
|
||||
const ifProxyLabel = '✔';
|
||||
const ifNotProxyLabel = '✘';
|
||||
const ifAutoLabel = '🔄';
|
||||
|
||||
const addOption = function addOption(host, yesNoUndefined) {
|
||||
|
||||
const opt = document.createElement('option');
|
||||
// `value` may be changed for hiding line in the tooltip.
|
||||
opt.value = host;
|
||||
opt.dataset.host = host;
|
||||
switch(yesNoUndefined) {
|
||||
case true:
|
||||
opt.innerHTML = ifProxyHtml;
|
||||
opt.label = ifProxyLabel;
|
||||
break;
|
||||
case false:
|
||||
opt.innerHTML = ifNotProxyHtml;
|
||||
opt.label = ifNotProxyLabel;
|
||||
break;
|
||||
default:
|
||||
opt.innerHTML = ifAutoHtml;
|
||||
opt.label = ifAutoLabel;
|
||||
}
|
||||
const editorHost = excEditor.value.trim();
|
||||
if (host === editorHost) {
|
||||
|
|
@ -283,6 +284,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
} else {
|
||||
excList.appendChild(opt);
|
||||
}
|
||||
return opt;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -318,7 +320,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
|
||||
};
|
||||
|
||||
excEditor.onclick = excEditor.oninput = function(event) {
|
||||
const renderExceptions = function renderExceptions(event) {
|
||||
|
||||
// If triangle button on right of datalist input clicked.
|
||||
|
||||
|
|
@ -326,13 +328,10 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
const ifClick = event && event.type === 'click';
|
||||
|
||||
{
|
||||
const minIndentFromRightInPx = 15;
|
||||
if( ifClick
|
||||
&& !this.selectionStart && !this.selectionStart
|
||||
&& event.x > this.getBoundingClientRect().right - minIndentFromRightInPx
|
||||
) {
|
||||
ifTriangleClicked = true;
|
||||
}
|
||||
const maxIndentFromRightInPx = 15;
|
||||
ifTriangleClicked = ifClick
|
||||
&& !excEditor.selectionStart && !excEditor.selectionStart
|
||||
&& event.x > excEditor.getBoundingClientRect().right - maxIndentFromRightInPx;
|
||||
}
|
||||
|
||||
const setInputValue = (newValue) => {
|
||||
|
|
@ -343,55 +342,86 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
}
|
||||
// See bug in my comment to http://stackoverflow.com/a/32394157/521957
|
||||
// First click on empty input may be still ignored.
|
||||
const nu = this.selectionStart + newValue.length - this.value.length;
|
||||
this.value = newValue;
|
||||
const nu = excEditor.selectionStart + newValue.length - excEditor.value.length;
|
||||
excEditor.value = newValue;
|
||||
excEditor.dataset.moveCursorTo = nu;
|
||||
window.setTimeout(moveCursorIfNeeded, 0);
|
||||
|
||||
}
|
||||
|
||||
const host = this.value.trim();
|
||||
const originalHost = excEditor.value.trim();
|
||||
const ifInit = !event;
|
||||
setInputValue(ifTriangleClicked ? '' : (host || (ifInit ? '' : ' ')));
|
||||
thisAuto.checked = true;
|
||||
const currentHost = ifTriangleClicked ? '' : (originalHost || (ifInit ? '' : ' '));
|
||||
setInputValue(currentHost);
|
||||
|
||||
let exactOpt = false;
|
||||
let editedOpt = false;
|
||||
excList.childNodes.forEach(
|
||||
(opt) => {
|
||||
|
||||
if(opt.innerHTML === ifAutoHtml) {
|
||||
return opt.remove();
|
||||
unhideOpt(opt);
|
||||
|
||||
if(opt.label === ifAutoLabel) {
|
||||
editedOpt = opt;
|
||||
return;
|
||||
}
|
||||
const ifExactMatch = opt.dataset.host === host;
|
||||
if (!ifExactMatch) {
|
||||
return unhideOpt(opt);
|
||||
if (opt.dataset.host === originalHost) {
|
||||
exactOpt = opt;
|
||||
}
|
||||
exactOpt = opt;
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
this.parentNode.classList.remove(noClass, yesClass);
|
||||
if(exactOpt) {
|
||||
if(ifTriangleClicked) {
|
||||
unhideOpt(exactOpt);
|
||||
} else {
|
||||
hideOpt(exactOpt);
|
||||
if(exactOpt.innerHTML === ifProxyHtml) {
|
||||
thisYes.checked = true;
|
||||
this.parentNode.classList.add(yesClass);
|
||||
} else {
|
||||
thisNo.checked = true;
|
||||
this.parentNode.classList.add(noClass);
|
||||
thisAuto.checked = true;
|
||||
excEditor.parentNode.classList.remove(noClass, yesClass);
|
||||
|
||||
if (ifTriangleClicked || !originalHost) {
|
||||
// Show all opts.
|
||||
if (editedOpt) {
|
||||
const ifBackspaced = !originalHost && editedOpt.value.length < 3;
|
||||
if (ifBackspaced) {
|
||||
editedOpt.remove();
|
||||
}
|
||||
}
|
||||
} else if (ifTriangleClicked && host) {
|
||||
addOption(host, undefined);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (editedOpt) {
|
||||
hideOpt(editedOpt);
|
||||
}
|
||||
|
||||
if (!exactOpt) {
|
||||
if(editedOpt) {
|
||||
const ifExact = editedOpt.dataset.host === originalHost;
|
||||
if(ifExact) {
|
||||
return true;
|
||||
}
|
||||
// Not exact! Update!
|
||||
editedOpt.remove();
|
||||
}
|
||||
editedOpt = addOption(originalHost, undefined);
|
||||
if (!ifClick) {
|
||||
// New value was typed -- don't show tooltip.
|
||||
hideOpt(editedOpt);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Exact found!
|
||||
hideOpt(exactOpt);
|
||||
if(exactOpt.label === ifProxyLabel) {
|
||||
thisYes.checked = true;
|
||||
excEditor.parentNode.classList.add(yesClass);
|
||||
} else {
|
||||
thisNo.checked = true;
|
||||
excEditor.parentNode.classList.add(noClass);
|
||||
}
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
excEditor.onclick = excEditor.oninput = renderExceptions;
|
||||
|
||||
if (currentTab && !currentTab.url.startsWith('chrome')) {
|
||||
excEditor.value = new URL(currentTab.url).hostname;
|
||||
} else {
|
||||
|
|
@ -405,7 +435,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
for(const host of Object.keys(pacMods.exceptions || {}).sort()) {
|
||||
addOption(host, pacMods.exceptions[host]);
|
||||
}
|
||||
excEditor.oninput(); // Colorize input.
|
||||
renderExceptions(); // Colorize input.
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -452,8 +482,9 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
(opt) => opt.dataset.host === host && opt.remove()
|
||||
);
|
||||
fixUi();
|
||||
// Window may be closed before this line executes.
|
||||
console.log(excEditor, excEditor.oninput);
|
||||
excEditor.oninput();
|
||||
renderExceptions();
|
||||
|
||||
}
|
||||
);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 434 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user