Skip to content

Instantly share code, notes, and snippets.

@teruo41
Last active October 18, 2024 05:39
Show Gist options
  • Save teruo41/1b0e533e9f7fadf29dd99e0adbf872d6 to your computer and use it in GitHub Desktop.
Save teruo41/1b0e533e9f7fadf29dd99e0adbf872d6 to your computer and use it in GitHub Desktop.
function FindProxyForURL (url, host) {
if (isPlainHostName (host)) return "DIRECT";
else {
const direct = "DIRECT";
const work = "SOCKS 127.0.0.1:10080; DIRECT";
const personal = "SOCKS5 127.0.0.1:10081; DIRECT";
const secure = "SOCKS 127.0.0.1:10082; DIRECT";
// personal services should be accessed directly
if (shExpMatch(host, "youtube.com") || shExpMatch(host, "*.youtube.com")) return personal;
if (shExpMatch(host, "x.com") || shExpMatch(host, "*.x.com")) return personal;
if (shExpMatch(host, "facebook.com") || shExpMatch(host, "*.facebook.com")) return personal;
if (shExpMatch(host, "feedly.com") || shExpMatch(host, "*.feedly.com")) return personal;
if (shExpMatch(host, "amazon.co.jp") || shExpMatch(host, "*.amazon.co.jp")) return personal;
if (shExpMatch(host, "amazon.com") || shExpMatch(host, "*.amazon.com")) return personal;
if (shExpMatch(host, "tver.jp") || shExpMatch(host, "*.tver.jp")) return personal;
// work
if (shExpMatch(host, "192.168.35.45")) return work;
if (shExpMatch(host, "192.168.35.51")) return work;
if (shExpMatch(host, "ieee.org") || shExpMatch(host, "*.ieee.org")) return work;
if (shExpMatch(host, "acm.org") || shExpMatch(host, "*.acm.org")) return work;
if (shExpMatch(host, "nature.com") || shExpMatch(host, "*.nature.com")) return work;
if (shExpMatch(host, "aps.org") || shExpMatch(host, "*.aps.org")) return work;
if (shExpMatch(host, "science.org") || shExpMatch(host, "*.science.org")) return work;
if (shExpMatch(host, "rakko.tools") || shExpMatch(host, "*.rakko.tools")) return work;
if (shExpMatch(host, "speedtest.net") || shExpMatch(host, "*.speedtest.net")) return work;
if (shExpMatch(host, "ku-portal.kyushu-u.ac.jp")) return work;
// otherwise choose secure
return secure;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment