/* * Handy proxy auto configuration script to proxy * requsts via your UK server. * * @author Bonstio (proxy at bonstio.net) */ function FindProxyForURL(url, hostname) { // Websites to proxy. var UK_HOSTS = [ 'bbc', 'iplayer', 'inskinad.com']; var SSH_CLIENT = 'bert:8123'; var DIRECT = 'DIRECT'; var SOCKS_PROXY = 'SOCKS ' + SSH_CLIENT + ';' + DIRECT; // Default to direct. var proxy = DIRECT; if (url.indexOf('useProxy=true') >= 0) { // Use proxy if specified in URL e.g. www.somewebsite.com?useProxy proxy = SOCKS_PROXY; } else { // See if the current website is on the proxy list. for (var i=0, host; host = UK_HOSTS[i]; i++) { if (url.indexOf(host) >= 0) { proxy = SOCKS_PROXY; break; } } } // Log some debug info out if requested. if (url.indexOf('debugProxy=true') >= 0) { // alert does not flash up a JS alert box but logs to the // JS console in this case. alert('Using proxy "' + proxy + '" for url ' + url + ' with host ' + hostname); } return proxy; }