If you want to do it on the router for a network of machines, the trick is to redirect all HTTP traffic through a dedicated box running the proxy. Pretend this machine is 10.0.2.15.
First, ensure that that machine's traffic gets through normally and isn't redirected to itself:
iptables -t nat -A PREROUTING -s 10.0.2.15 -j ACCEPT
Then, redirect all HTTP traffic on your network (say, 10.0.2.0/24) through that machine:
Apparently you can't just run the script with node and point your browser's http proxy to 8080. I suppose transparent proxy and http proxies act differently?
https://github.com/gcr/proxies/blob/master/rotating-proxy.js