The PAC file is simply a Javascript function function FindProxyForURL(url, host) {}
that gets the URL of the resource being fetched and returns a string specifying which proxy to use (or DIRECT
for no proxy at all) for that resource.
All browser requests go through the function, regardless of the protocol.
In that function block, you should be able to query the current time and make a decision on which proxy to return.
For instance:
function FindProxyForURL(url, host) {
// If URL has no dots in host name, send traffic direct.
if (isPlainHostName(host)) return "DIRECT";
// Known local Top Level Domains are direct
if(/\.(local|lcl|domain|grp|localdomain)(\:\d+)?($|\/)/i.test(url))
return "DIRECT";
// Split traffic depending on the time
var dTime = new Date();
var hours = dTime.getHours();
if (hours < 12) {
// From midnight to lunchtime, use Proxy A
// which is a standard HTTP proxy on port 8080
return "PROXY proxyA.example.com:8080"
} else {
// From lunchtime to midnight, use Proxy B
// which is a Socks5 proxy on port 777
return "SOCKS5 proxyB.example.com:777"
}
}