語法:
function FindProxyForURL(url,host) {
// Convert hostname to lower case.
tmp = host.toLowerCase();
host = tmp;
// Process specific rules first. Run UltraSurf (9666), Freegate_F3 (8580), Garden (8081) or GPass.
if ((host == "www.pandora.com") ||
(host == "video.cgi.cbs.com") ||
(host == "www.grandcentral.com")
) return "PROXY 127.0.0.1:9666; PROXY 127.0.0.1:8580; PROXY 127.0.0.1:8081; DIRECT";
// Bypass https, ftp and mms.
tmp = url.substring(0,5);
protocol = tmp.toLowerCase()
if (protocol != "http:") {
// alert ("Bypass " + url);
return "DIRECT";
}
// Setup default proxy
proxy = "PROXY proxy.hinet.net:80; DIRECT";
// Process specific rules first.
if (dnsDomainIs(host, ".cn") ||
dnsDomainIs(host, ".hk") ||
dnsDomainIs(host, ".jp")
) return proxy;
// Process speedy or private connections. Do not conflic with other rules.
if (dnsDomainIs(host, ".tw") ||
dnsDomainIs(host, ".cc") ||
dnsDomainIs(host, ".org") ||
dnsDomainIs(host, ".net") ||
dnsDomainIs(host, ".google.com") ||
dnsDomainIs(host, ".gmail.com") ||
dnsDomainIs(host, ".yahoo.com") ||
dnsDomainIs(host, ".yimg.com") ||
dnsDomainIs(host, ".live.com") ||
dnsDomainIs(host, ".msn.com") ||
dnsDomainIs(host, ".hotmail.com") ||
dnsDomainIs(host, ".microsoft.com") ||
dnsDomainIs(host, ".flickr.com") ||
dnsDomainIs(host, ".ebay.com") ||
dnsDomainIs(host, ".taobao.com") ||
dnsDomainIs(host, ".mobile01.com") ||
dnsDomainIs(host, ".5i01.com") ||
dnsDomainIs(host, ".shopping01.com") ||
dnsDomainIs(host, ".dd-wrt.com") ||
dnsDomainIs(host, ".openwrt.org") ||
dnsDomainIs(host, ".wl500g.info") ||
dnsDomainIs(host, ".hinet.net")
) return "DIRECT";
// Safely checking local IP address spaces.
// Do not include the "g" flag in the IP regex expression
if ((host.substring(0,1) == "1") ||
(host.substring(0,1) == "2")
) {
reip = /^\d+\.\d+\.\d+\.\d+$/;
if (reip.test(host)) {
// if (shExpMatch(host, "/^\d+\.\d+\.\d+\.\d+$/")) {
// if (isInNet(host, "192.168.0.0", "255.255.0.0") ||
// isInNet(host, "172.16.0.0", "255.240.0.0") ||
// isInNet(host, "10.0.0.0", "255.0.0.0") ||
// isInNet(host, "169.254.0.0", "255.255.0.0")
if (shExpMatch(host, "192.168.*") ||
shExpMatch(host, "172.16.*") ||
shExpMatch(host, "10.*") ||
shExpMatch(host, "224.*") ||
shExpMatch(host, "232.*") ||
shExpMatch(host, "233.*") ||
shExpMatch(host, "239.*") ||
shExpMatch(host, "169.254.*") ||
(host == "127.0.0.1")
) return "DIRECT";
}
}
// Check plain hostname and localhost
if (isPlainHostName(host) ||
// (host == "localhost") ||
shExpMatch(host, "localhost.*")
) return "DIRECT";
// alert ("Proxy alert!");
return proxy;
} // End of fuction
// Set "proxy.hinet.net:80" for Hinet users
// Set "proxy.seed.net.tw:8080" for Seednet users
// Copyleft: www.pczone.com.tw
// http://www.pczone.com.tw/thread/6/post/20756/1002231/#post1002231
// Reference: http://www.returnproxy.com/proxypac/
// Firefox: file:///c:/proxy.pac
// IE: file://c:/proxy.pac
以上原則是FIFO, 先吻合先執行, 請參考 "
書籤