diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/13-http-lib.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/13-http-lib.js index 4fbe0ec..6444844 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/13-http-lib.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/13-http-lib.js @@ -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)) ); }, diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js index c230b12..92341a1 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js @@ -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 && diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js index 78b3ef4..54edc3b 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js @@ -170,7 +170,7 @@ ' Блокировка определяется по доменному имени,' + ' для некоторых провайдеров есть автоопредление.' + '
Страница проекта.', - + order: 0, pacUrls: ['https://antizapret.prostovpn.org/proxy.pac'], }, Антицензорити: { @@ -179,6 +179,7 @@ ' Блокировка определятся по доменному имени или IP адресу.' + ' Работает на switch-ах.
' + ' Страница проекта.', + 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: 'Антизапрет', diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/choose-pac-provider/index.html b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/choose-pac-provider/index.html index 0095dcb..971ad0a 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/choose-pac-provider/index.html +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/choose-pac-provider/index.html @@ -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; diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/choose-pac-provider/index.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/choose-pac-provider/index.js index 1ee073f..4c93d34 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/choose-pac-provider/index.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/choose-pac-provider/index.js @@ -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) || ''} str ); const ifValid = ifValidArr.every( diff --git a/extensions/chromium/runet-censorship-bypass/src/templates-data.js b/extensions/chromium/runet-censorship-bypass/src/templates-data.js index 7b686c6..fcc5a73 100644 --- a/extensions/chromium/runet-censorship-bypass/src/templates-data.js +++ b/extensions/chromium/runet-censorship-bypass/src/templates-data.js @@ -1,7 +1,7 @@ 'use strict'; const commonContext = { - version: '0.26', + version: '0.27', }; exports.contexts = {};