Ideally, don't. Doing this blindly will break a lot of web pages, especially ones which make heavy use of AJAX. (Because your inserted strings will end up in places where they will cause errors, like JSON responses.)
If you must, the term for what you're trying to do is "transparent proxying". Squid supports this: http://wiki.squid-cache.org/SquidFaq/InterceptionProxy