Skip to content

Instantly share code, notes, and snippets.

@lsongdev
Last active October 25, 2017 07:57
Show Gist options
  • Select an option

  • Save lsongdev/8142c43a5096730c0a745f5507dcee44 to your computer and use it in GitHub Desktop.

Select an option

Save lsongdev/8142c43a5096730c0a745f5507dcee44 to your computer and use it in GitHub Desktop.
// Powered by proxy.lsong.org
var proxy = [
{ type: 'SOCKS5', proxy: 'gateway.lsong.org:1080' },
{ type: 'SOCKS' , proxy: 'gateway.lsong.org:1080' },
'DIRECT'
].map(function(p){
if(typeof p === 'string') return p;
return [ p.type, p.proxy ].join(' ');
}).join('; ');
var rules = [
// github
"github.com",
"github.io",
"githubusercontent.com",
// npmjs.org
"npmjs.com",
"en25.com",
"cdn.optimizely.com",
// twitter
"twitter.com",
"api.twitter.com",
"twimg.com",
// facebook
"facebook.com",
"facebook.net",
"fb.com",
"fb.me",
"fbcdn.net",
"fbsbx.com",
// facebook messager
"m.me",
"messenger.com",
// instagram
"instagram.com",
// google
"goo.gl",
"google.com",
"google.com.hk",
// youtube
"youtu.be",
"youtube.com",
"yt.be",
"ytimg.com",
// telegram
"t.me",
"telegram.me",
"telegram.org",
".telegramdownload.com",
// stackoverflow
"stackoverflow.com"
];
function FindProxyForURL(url, host) {
for(var i in rules){
var rule = rules[i];
if(~url.indexOf(rule)) return proxy;
}
return 'DIRECT';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment