mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
Add webpack-like comments for better perception
This commit is contained in:
parent
70796c2e31
commit
e7e9aa3319
|
@ -225,29 +225,40 @@
|
||||||
cook(pacData, pacMods = mandatory()) {
|
cook(pacData, pacMods = mandatory()) {
|
||||||
|
|
||||||
return pacMods.ifNoMods ? pacData : pacData + `${ kitchenStartsMark }
|
return pacMods.ifNoMods ? pacData : pacData + `${ kitchenStartsMark }
|
||||||
;+function(global) {
|
/******/
|
||||||
"use strict";
|
/******/;+function(global) {
|
||||||
|
/******/ "use strict";
|
||||||
const originalFindProxyForURL = FindProxyForURL;
|
/******/
|
||||||
global.FindProxyForURL = function(url, host) {
|
/******/ const originalFindProxyForURL = FindProxyForURL;
|
||||||
${function() {
|
/******/ global.FindProxyForURL = function(url, host) {
|
||||||
|
/******/
|
||||||
|
${
|
||||||
|
function() {
|
||||||
|
|
||||||
let res = pacMods.ifProhibitDns ? `
|
let res = pacMods.ifProhibitDns ? `
|
||||||
global.dnsResolve = function(host) { return null; };
|
/******/
|
||||||
` : '';
|
/******/ global.dnsResolve = function(host) { return null; };
|
||||||
|
/******/
|
||||||
|
/******/` : '';
|
||||||
if (pacMods.ifProxyHttpsUrlsOnly) {
|
if (pacMods.ifProxyHttpsUrlsOnly) {
|
||||||
|
|
||||||
res += `
|
res += `
|
||||||
if (!url.startsWith("https")) {
|
/******/
|
||||||
return "DIRECT";
|
/******/ if (!url.startsWith("https")) {
|
||||||
}
|
/******/ return "DIRECT";
|
||||||
`;
|
/******/ }
|
||||||
|
/******/
|
||||||
|
/******/ `;
|
||||||
}
|
}
|
||||||
res += `
|
res += `
|
||||||
const directIfAllowed = ${pacMods.ifProxyOrDie ? '""/* Not allowed. */' : '"; DIRECT"'};`;
|
/******/
|
||||||
|
/******/ const directIfAllowed = ${pacMods.ifProxyOrDie ? '""/* Not allowed. */' : '"; DIRECT"'};
|
||||||
|
/******/`;
|
||||||
if (pacMods.filteredCustomsString) {
|
if (pacMods.filteredCustomsString) {
|
||||||
res += `
|
res += `
|
||||||
const filteredCustomProxies = "; ${pacMods.filteredCustomsString}";`;
|
/******/
|
||||||
|
/******/ const filteredCustomProxies = "; ${pacMods.filteredCustomsString}";
|
||||||
|
/******/`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ifIncluded = pacMods.included && pacMods.included.length;
|
const ifIncluded = pacMods.included && pacMods.included.length;
|
||||||
|
@ -256,41 +267,41 @@
|
||||||
|
|
||||||
if (ifExceptions) {
|
if (ifExceptions) {
|
||||||
res += `
|
res += `
|
||||||
|
/******/
|
||||||
/* EXCEPTIONS START */
|
/******/ /* EXCEPTIONS START */
|
||||||
const dotHost = '.' + host;
|
/******/ const dotHost = '.' + host;
|
||||||
const isHostInDomain = (domain) => dotHost.endsWith('.' + domain);
|
/******/ const isHostInDomain = (domain) => dotHost.endsWith('.' + domain);
|
||||||
const domainReducer = (maxWeight, [domain, ifIncluded]) => {
|
/******/ const domainReducer = (maxWeight, [domain, ifIncluded]) => {
|
||||||
|
/******/
|
||||||
if (!isHostInDomain(domain)) {
|
/******/ if (!isHostInDomain(domain)) {
|
||||||
return maxWeight;
|
/******/ return maxWeight;
|
||||||
}
|
/******/ }
|
||||||
const newWeightAbs = domain.length;
|
/******/ const newWeightAbs = domain.length;
|
||||||
if (newWeightAbs < Math.abs(maxWeight)) {
|
/******/ if (newWeightAbs < Math.abs(maxWeight)) {
|
||||||
return maxWeight;
|
/******/ return maxWeight;
|
||||||
}
|
/******/ }
|
||||||
return newWeightAbs*(ifIncluded ? 1 : -1);
|
/******/ return newWeightAbs*(ifIncluded ? 1 : -1);
|
||||||
|
/******/
|
||||||
};
|
/******/ };
|
||||||
|
/******/
|
||||||
const excWeight = ${JSON.stringify(Object.entries(pacMods.exceptions))}.reduce( domainReducer, 0 );
|
/******/ const excWeight = ${JSON.stringify(Object.entries(pacMods.exceptions))}.reduce( domainReducer, 0 );
|
||||||
if (excWeight !== 0) {
|
/******/ if (excWeight !== 0) {
|
||||||
if (excWeight < 0) {
|
/******/ if (excWeight < 0) {
|
||||||
// Never proxy it!
|
/******/ // Never proxy it!
|
||||||
return "DIRECT";
|
/******/ return "DIRECT";
|
||||||
}
|
/******/ }
|
||||||
// Always proxy it!
|
/******/ // Always proxy it!
|
||||||
${ pacMods.filteredCustomsString
|
${ pacMods.filteredCustomsString
|
||||||
? `return filteredCustomProxies + directIfAllowed;`
|
? `/******/ return filteredCustomProxies + directIfAllowed;`
|
||||||
: '/* No custom proxies -- continue. */'
|
: '/******/ /* No custom proxies -- continue. */'
|
||||||
}
|
}
|
||||||
}
|
/******/ }
|
||||||
/* EXCEPTIONS END */
|
/******/ /* EXCEPTIONS END */
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
res += `
|
res += `
|
||||||
const pacScriptProxies = originalFindProxyForURL(url, host)${
|
/******/ const pacScriptProxies = originalFindProxyForURL(url, host)${
|
||||||
pacMods.ifProxyOrDie ? '.replace(/DIRECT/g, "")' : ' + directIfAllowed'
|
/******/ pacMods.ifProxyOrDie ? '.replace(/DIRECT/g, "")' : ' + directIfAllowed'
|
||||||
};`;
|
};`;
|
||||||
if(
|
if(
|
||||||
!pacMods.ifUseSecureProxiesOnly &&
|
!pacMods.ifUseSecureProxiesOnly &&
|
||||||
|
@ -298,17 +309,17 @@
|
||||||
pacMods.ifUsePacScriptProxies
|
pacMods.ifUsePacScriptProxies
|
||||||
) {
|
) {
|
||||||
return res + `
|
return res + `
|
||||||
return pacScriptProxies + directIfAllowed;`;
|
/******/ return pacScriptProxies + directIfAllowed;`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res + `
|
return res + `
|
||||||
let pacProxyArray = pacScriptProxies.split(/(?:\\s*;\\s*)+/g).filter( (p) => p );
|
/******/ let pacProxyArray = pacScriptProxies.split(/(?:\\s*;\\s*)+/g).filter( (p) => p );
|
||||||
const ifNoProxies = pacProxyArray${pacMods.ifProxyOrDie ? '.length === 0' : '.every( (p) => /^DIRECT$/i.test(p) )'};
|
/******/ const ifNoProxies = pacProxyArray${pacMods.ifProxyOrDie ? '.length === 0' : '.every( (p) => /^DIRECT$/i.test(p) )'};
|
||||||
if (ifNoProxies) {
|
/******/ if (ifNoProxies) {
|
||||||
// Directs only or null, no proxies.
|
/******/ // Directs only or null, no proxies.
|
||||||
return "DIRECT";
|
/******/ return "DIRECT";
|
||||||
}
|
/******/ }
|
||||||
return ` +
|
/******/ return ` +
|
||||||
function() {
|
function() {
|
||||||
|
|
||||||
if (!pacMods.ifUsePacScriptProxies) {
|
if (!pacMods.ifUsePacScriptProxies) {
|
||||||
|
@ -323,7 +334,8 @@
|
||||||
|
|
||||||
}() + `${pacMods.filteredCustomsString ? 'filteredCustomProxies + ' : ''}directIfAllowed;`; // Without DIRECT you will get 'PROXY CONN FAILED' pac-error.
|
}() + `${pacMods.filteredCustomsString ? 'filteredCustomProxies + ' : ''}directIfAllowed;`; // Without DIRECT you will get 'PROXY CONN FAILED' pac-error.
|
||||||
|
|
||||||
}()}
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user