使用下面这个函数可以达到域名通配符的效果,对指定的域名应用代理
代码
var autoproxy_host = {
"*.zoro.com":1,
"*.facebook.net":1,
"*.facebook.com":1,
"*.google.com":1
}
function FindProxyForURL(url, host) {
var lastPos;
var host_tmp = host;
var prefix = '*.';
do {
if (autoproxy_host.hasOwnProperty(host_tmp)) {
return 'PROXY 127.0.0.1:1080';
}
lastPos = host.indexOf('.') + 1;
host = host.slice(lastPos);
host_tmp = prefix.concat(host);
} while (lastPos >= 1);
return 'DIRECT';
}