Works when other scripts override document.write

Similar to #150 but for 2.0