Skip to content

Instantly share code, notes, and snippets.

@thuongtin
Last active June 27, 2023 04:43
Show Gist options
  • Save thuongtin/d56a56791b85b9fd799300122a80ab89 to your computer and use it in GitHub Desktop.
Save thuongtin/d56a56791b85b9fd799300122a80ab89 to your computer and use it in GitHub Desktop.
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
}("+auto switch", {
"+auto switch": function(url, host, scheme) {
"use strict";
if (/(?:^|\.)medium\.com$/.test(host)) return "+proxy";
if (/(?:^|\.)medium\.build$/.test(host)) return "+proxy";
if (/^medium\.com$/.test(host)) return "+proxy";
if (/^tokenizedhq\.com$/.test(host)) return "+proxy";
if (/^medium\.build$/.test(host)) return "+proxy";
if (/(?:^|\.)uxdesign\.cc$/.test(host)) return "+proxy";
return "DIRECT";
},
"+proxy": function(url, host, scheme) {
"use strict";
if (/^127\.0\.0\.1$/.test(host) || /^::1$/.test(host) || /^localhost$/.test(host)) return "DIRECT";
return "PROXY 164.92.118.78:3128";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment