mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
0.27: Add own-sites-own-proxies-only mode
This commit is contained in:
parent
554a26c0cc
commit
ae9e7b7471
|
@ -15,7 +15,10 @@
|
|||
cb = mandatory()
|
||||
) {
|
||||
|
||||
const wasModified = new Date(0).toUTCString();
|
||||
if (url.startsWith('data:')) {
|
||||
return cb(null, false);
|
||||
}
|
||||
const wasModifiedIn1970 = new Date(0).toUTCString();
|
||||
const notModifiedCode = 304;
|
||||
fetch(url, {
|
||||
method: 'HEAD',
|
||||
|
@ -28,10 +31,10 @@
|
|||
null,
|
||||
res.status === notModifiedCode ?
|
||||
false :
|
||||
(res.headers.get('Last-Modified') || wasModified)
|
||||
(res.headers.get('Last-Modified') || wasModifiedIn1970)
|
||||
);
|
||||
},
|
||||
errorsLib.clarifyThen(checkCon, (err) => cb(err, wasModified))
|
||||
errorsLib.clarifyThen(checkCon, (err) => cb(err, wasModifiedIn1970))
|
||||
);
|
||||
|
||||
},
|
||||
|
|
|
@ -185,22 +185,53 @@
|
|||
`;
|
||||
}
|
||||
|
||||
if (pacMods.included && pacMods.included.length) {
|
||||
const ifIncluded = pacMods.included && pacMods.included.length;
|
||||
const ifExcluded = pacMods.excluded && pacMods.excluded.length;
|
||||
const ifExceptions = ifIncluded || ifExcluded;
|
||||
|
||||
if (ifExceptions) {
|
||||
res += `
|
||||
if ( ${JSON.stringify(pacMods.included)}.some( (included) => host.endsWith(included) ) ) {
|
||||
return "${pacMods.filteredCustomsString}; DIRECT";
|
||||
const dotHost = '.' + host;
|
||||
const isHostInDomain = (domain) => dotHost.endsWith('.' + domain);
|
||||
const domainReducer = (maxWeight, [domain, ifIncluded]) => {
|
||||
|
||||
if (!isHostInDomain(domain)) {
|
||||
return maxWeight;
|
||||
}
|
||||
const newWeightAbs = domain.length;
|
||||
if (newWeightAbs < Math.abs(maxWeight)) {
|
||||
return maxWeight;
|
||||
}
|
||||
return newWeightAbs*(ifIncluded ? 1 : -1);
|
||||
|
||||
};
|
||||
|
||||
const excWeight = ${JSON.stringify(Object.entries(pacMods.exceptions))}.reduce( domainReducer, 0 );
|
||||
if (excWeight !== 0) {
|
||||
if (excWeight > 0) {
|
||||
return "${pacMods.filteredCustomsString}; DIRECT";
|
||||
} else {
|
||||
return "DIRECT";
|
||||
}
|
||||
}
|
||||
`;
|
||||
}
|
||||
/*
|
||||
if (ifIncluded) {
|
||||
res += `
|
||||
if (${JSON.stringify(pacMods.included)}.some(isHostInDomain)) {
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
if (pacMods.excluded && pacMods.excluded.length) {
|
||||
if (ifExcluded) {
|
||||
res += `
|
||||
if ( ${JSON.stringify(pacMods.excluded)}.some( (excluded) => host.endsWith(excluded) ) ) {
|
||||
if (${JSON.stringify(pacMods.excluded)}.some(isHostInDomain)) {
|
||||
return "DIRECT";
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
*/
|
||||
if(
|
||||
!pacMods.ifUseSecureProxiesOnly &&
|
||||
!pacMods.filteredCustomsString &&
|
||||
|
|
|
@ -170,7 +170,7 @@
|
|||
' Блокировка определяется по доменному имени,' +
|
||||
' для некоторых провайдеров есть автоопредление.' +
|
||||
' <br/> <a href="https://antizapret.prostovpn.org">Страница проекта</a>.',
|
||||
|
||||
order: 0,
|
||||
pacUrls: ['https://antizapret.prostovpn.org/proxy.pac'],
|
||||
},
|
||||
Антицензорити: {
|
||||
|
@ -179,6 +179,7 @@
|
|||
' Блокировка определятся по доменному имени или IP адресу.' +
|
||||
' Работает на switch-ах. <br/>' +
|
||||
' <a href="https://rebrand.ly/ac-anticensority">Страница проекта</a>.',
|
||||
order: 1,
|
||||
|
||||
/*
|
||||
Don't use in system configs! Because Windows does poor caching.
|
||||
|
@ -197,6 +198,20 @@
|
|||
// Google Drive (0.17):
|
||||
'\x68\x74\x74\x70\x73\x3a\x2f\x2f\x64\x72\x69\x76\x65\x2e\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\x6d\x2f\x75\x63\x3f\x65\x78\x70\x6f\x72\x74\x3d\x64\x6f\x77\x6e\x6c\x6f\x61\x64\x26\x69\x64\x3d\x30\x42\x2d\x5a\x43\x56\x53\x76\x75\x4e\x57\x66\x30\x54\x44\x46\x52\x4f\x47\x35\x46\x62\x55\x39\x4f\x64\x44\x67'], // eslint-disable-line max-len
|
||||
},
|
||||
onlyOwnSites: {
|
||||
label: 'Только свои сайты и свои прокси',
|
||||
desc: 'Проксируются только добавленные вручную сайты через СВОИ вручную добавленные прокси или через локальный Tor.',
|
||||
order: 99,
|
||||
pacUrls: [
|
||||
'data:application/x-ns-proxy-autoconfig,' + escape('function FindProxyForURL(){ return "DIRECT"; }'),
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
getSortedEntriesForProviders() {
|
||||
|
||||
return Object.entries(this.pacProviders).sort((entryA, entryB) => entryA[1].order - entryB[1].order);
|
||||
|
||||
},
|
||||
|
||||
_currentPacProviderKey: 'Антизапрет',
|
||||
|
|
|
@ -290,9 +290,14 @@
|
|||
input:checked ~ .label-container .update-button {
|
||||
visibility: inherit;
|
||||
}
|
||||
#none:checked + label {
|
||||
label[for="onlyOwnSites"] + .update-button {
|
||||
display: none;
|
||||
}
|
||||
#none:checked ~ .label-container label {
|
||||
color: red;
|
||||
}
|
||||
|
||||
|
||||
#update-message {
|
||||
white-space: nowrap;
|
||||
margin-top: 0.5em;
|
||||
|
|
|
@ -177,9 +177,8 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
const ul = document.querySelector('#list-of-providers');
|
||||
const _firstChild = ul.firstChild;
|
||||
for(
|
||||
const providerKey of Object.keys(antiCensorRu.pacProviders).sort()
|
||||
const [providerKey, provider] of antiCensorRu.getSortedEntriesForProviders()
|
||||
) {
|
||||
const provider = antiCensorRu.getPacProvider(providerKey);
|
||||
const li = document.createElement('li');
|
||||
li.classList.add('info-row', 'hor-flex');
|
||||
li.innerHTML = `
|
||||
|
@ -583,7 +582,7 @@ HTTPS 11.22.33.44:8080;">${conf.value || localStorage.getItem(uiRaw) || ''}</tex
|
|||
if (oldMods[customProxyStringKey] !== false) {
|
||||
const ifValidArr = taVal
|
||||
.trim()
|
||||
.replace(/#.*$/mg)
|
||||
.replace(/#.*$/mg, '')
|
||||
.split(/\s*[;\n\r]+\s*/g)
|
||||
.filter( (str) => str );
|
||||
const ifValid = ifValidArr.every(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const commonContext = {
|
||||
version: '0.26',
|
||||
version: '0.27',
|
||||
};
|
||||
|
||||
exports.contexts = {};
|
||||
|
|
Loading…
Reference in New Issue
Block a user