Skip to content

Instantly share code, notes, and snippets.

@sric0880
Created June 6, 2019 16:01
Show Gist options
  • Save sric0880/16d500b232ef57f42e93a961afe5f380 to your computer and use it in GitHub Desktop.
Save sric0880/16d500b232ef57f42e93a961afe5f380 to your computer and use it in GitHub Desktop.
代理pac文件
function isMatchProxy(url, pattern) {
try {
return new RegExp(pattern.replace('.', '\\.')).test(url);
} catch (e) {
return false;
}
}
function FindProxyForURL(url, host) {
var Proxy = 'PROXY 127.0.0.1:10800';
var list = [
'google.com',
'googledrive.com',
'google-analytics.com',
'ytimg.com',
'googleapis.com',
'googleusercontent.com',
'gstatic.com',
'virustotal.com',
'maniaplanet.com',
'whatsmyuseragent.com'
];
for(var i=0, l=list.length; i<l; i++) {
if (isMatchProxy(url, list[i])) {
return Proxy;
}
}
return 'DIRECT';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment