Skip to content

Instantly share code, notes, and snippets.

@martzuk
Created March 3, 2015 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martzuk/3d8edc458560055cc559 to your computer and use it in GitHub Desktop.
Save martzuk/3d8edc458560055cc559 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 (/broadcasthe\.net$/.test(host)) return "+lhr01";
if (/passthepopcorn\.me$/.test(host)) return "+lhr01";
return "DIRECT";
},
"+lhr01": function(url, host, scheme) {
"use strict";
if (host === "[::1]" || host === "localhost" || host === "127.0.0.1") return "DIRECT";
switch (scheme) {
case "http":
return "PROXY x.x.x:3128";
default:
return "DIRECT";
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment