How do I remove what appears to be malicious cached javascript?
Sounds like a DNS changer of sorts.
could maybe try running a scan with clamXav if your not too familiar with what files are legit and what ones are malicious.

where I found the dodgy DNSchanger file and instal.pkg
~/Library/Internet Plug-Ins
/Library/Receipts

Only clearing the cached files wont get rid of malware. It might only do half the job.

Here are some links, feel free to use them.. or not. :)

http://www.howtogeek.com/howto/38793/how-to-switch-mac-os-x-to-use-opendns-or-google-dns/ - When trouble shooting the issue, I noticed that the auto DNS settings in sys prefs were different to what our routers DNS address was.

Open DNS address:    208.67.222.222 &amp; 208.67.220.220
google DNS addres:   8.8.8.8 &amp; 8.8.4.4

http://www.macupdate.com/app/mac/15850/clamxav/ - read up on some of the user feedback before you try.


bottom line is - be aware of what your are accepting and installing on your machine.