Skip to content

Instantly share code, notes, and snippets.

@chenshaoju
Last active May 18, 2018 11:24
Show Gist options
  • Save chenshaoju/52c7555acc65ec98423f to your computer and use it in GitHub Desktop.
Save chenshaoju/52c7555acc65ec98423f to your computer and use it in GitHub Desktop.
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