Skip to content

Instantly share code, notes, and snippets.

@amorphobia
Last active November 11, 2021 06:19
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 amorphobia/0c114495eaf52a5e3f417cfcedceed6f to your computer and use it in GitHub Desktop.
Save amorphobia/0c114495eaf52a5e3f417cfcedceed6f 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 (/^192\.168\.2\.10$/.test(host)) return "+proxy";
if (/^192\.168\.2\.1$/.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 "SOCKS5 127.0.0.1:65500; SOCKS 127.0.0.1:65500";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment