I overwrote the document.write with the following code:
var elementToWrite = null;
document.write = function () {
if (elementToWrite != null) {
elementToWrite.append([].concat.apply([], arguments).join(''));
}
};
Now I just have to set the elementToWrite variable with some element from jQuery, this actually broke a few things but nothing I can't fix from application code