FWIW, this is how early ad blockers worked. Proxomatron (I ran it under Wine!), and Internet Junkbuster. We didn't have TLS back then, though.