I'm working on a Chrome extension that requires me to intercept the document.write function (Note: I am using content script). I'm using the method here: http://sitr.us/2012/09/04/monkey-patching-document-write.html But it's not working correctly. This is what I have right now:
(function() {
var originalWrite = document.write;
alert("checkpoint 1");
document.write = function() {
alert("checkpoint 2");
//secret stuff here
return Function.prototype.apply.call(
originalWrite, document, arguments);
}
})();
However, the "checkpoint 2" alert inside my hook never gets called when I call document.write on a web page. What am I doing wrong?