Skip to content

Instantly share code, notes, and snippets.

@teslatronic
Created August 26, 2014 15:11
Show Gist options
  • Save teslatronic/4222759e2cacfdb00a48 to your computer and use it in GitHub Desktop.
Save teslatronic/4222759e2cacfdb00a48 to your computer and use it in GitHub Desktop.
A PAC file that picks a random proxy from a list
/*
By Daan Rijks (daanrijks@gmail.com).
Idea & Inititative: Niels Meijer (niels.meijer@leerling.ig.nl)
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
(http://creativecommons.org/licenses/by-nc-sa/4.0/)
*/
var hosts = ""; // HTTP proxies go here, in the format host:port separated by a single space.
function FindProxyForURL(url, host)
{
var hostsArray = hosts.split(" ");
var randomIndex = Math.floor((Math.random() * hostsArray.length));
return "PROXY " + hostsArray[randomIndex] + "; DIRECT"; // DIRECT makes the browser use no proxy if the chosen proxy doesn't work
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment