Skip to content

Instantly share code, notes, and snippets.

@asasuou
Forked from teslatronic/random_proxy.pac
Created October 2, 2015 12:49
Show Gist options
  • Save asasuou/b954a00afbc5c684c69b to your computer and use it in GitHub Desktop.
Save asasuou/b954a00afbc5c684c69b to your computer and use it in GitHub Desktop.
A PAC file that picks a random proxy from a list
/*
By Daan Rijks ([email protected]).
Idea & Inititative: Niels Meijer ([email protected])
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