We have written a PAC script that blocklists certain domains and whitelists others. We went to Settings > Network > Wi-Fi (the network we are using), then clicked on Details, and under Proxies, we added the PAC file URL in the Automatic Proxy Configuration section.
We tried hosting the PAC file both on localhost and on a separate HTTP server.
After saving the settings, we tested several URLs. The blocking and allowing behavior works correctly in all browsers except Safari.
Below is the PAC script we are using for your reference. The script works as expected in browsers other than Safari.
This is how the PAC script URL looks:
http://localhost:31290/proxy.pac
function FindProxyForURL(url, host) {
var blacklist = new Set(["facebook.com", "deepseek.com"]);
var b_list = [...blacklist];
for (let i = 0; i < b_list.length; i++) {
let ele = b_list[i] + "*";
if (shExpMatch(host, ele) || shExpMatch(url, ele)) {
return "PROXY localhost:8086";
}
}
if (isIPBlocked(whitelist_subnet, hostIP)) {
return "PROXY localhost:8087";
}
if (isIPBlocked(blacklist_subnet, hostIP)) {
return "PROXY localhost:8086";
}
return "PROXY localhost:8080";
}