Skip to content

Instantly share code, notes, and snippets.

@laocoi
Forked from teslatronic/random_proxy.pac
Created July 29, 2024 09:23
Show Gist options
  • Save laocoi/12a6729d706a773937c2cc2f959cbbc5 to your computer and use it in GitHub Desktop.
Save laocoi/12a6729d706a773937c2cc2f959cbbc5 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