That's a tricky one. I haven't tested this, but I think you should be able to listen for the 'load' event on each of the script elements that you inject, and patch document.write differently each time.
Let me know how you get on! I plan on doing something like this soon for some of my sites that have AdSense (another document.write culprit).
I just pushed up a class I've been using to do this to github. It's a little rough around the edges, but works in Firefox and IE. I've trialed with the AddThis. http://github.com/joshduck/Injector.js
Let me know how you get on! I plan on doing something like this soon for some of my sites that have AdSense (another document.write culprit).