My ISP, injects JavaScript code into every website I visit. Is there a way to filter all incoming traffic in OS X and remove that injected code?


That will be incredibly hard. It would be far easier to establish a VPN connection to get out from under the offending hostile network.

If you can ensure SSL connections and the network isn’t a very strong state actor, you might get pretty good immunization / isolation from that sort of tampering.

Barring that, keep the OS updates as far as possible as Apple continues to enhance security and privacy and this sort of attack leaves you extremely vulnerable to snooping, security risks and data leakage from the sites you enter data.