Skip to content

Instantly share code, notes, and snippets.

@amosbird
Last active December 14, 2022 02:19
Show Gist options
  • Save amosbird/4da9eab5f3ea9322bfb1a69cd5aa57ec to your computer and use it in GitHub Desktop.
Save amosbird/4da9eab5f3ea9322bfb1a69cd5aa57ec to your computer and use it in GitHub Desktop.
pac
var direct = 'DIRECT';
var http_proxy = 'PROXY 127.0.0.1:12639';
var gfwed_list = [
"oa.com",
"woa.com",
"oa.tencent.com",
];
var gfwed = {};
for (var i = 0; i < gfwed_list.length; i += 1) {
gfwed[gfwed_list[i]] = true;
}
function host2domain(host) {
var dotpos = host.lastIndexOf(".");
if (dotpos === -1)
return host;
// Find the second last dot
dotpos = host.lastIndexOf(".", dotpos - 1);
if (dotpos === -1)
return host;
return host.substring(dotpos + 1);
};
function FindProxyForURL(url, host) {
return gfwed[host2domain(host)] ? http_proxy : direct;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment