I am writing an overlay UI for one application using Greasemonkey, injecting JS to a page.
Now I have issue to hook on some ajax calls that runs on the webpage. However, the page is generating console logs, informing that content is fully loaded. My question is:
In plain javascript, is there a possibility of reading console output generated by completely different script?
function blackBox(){
//this is generating come console output.
//this runs on code layer I have no access to.
}
function readConsole(){
//read console record by record
if(console.msg == "something I want"){
doSomething();
}
}
Thanks in advance :)
console.logto record prints as well as print? I've never tried that, but it should work.var print = console.log; console.log = function(msg) { print("Altered!: " + msg); } console.log("Some message");console.login a variablecland define a global arrayar. Then redefineconsole.logto first push the message toarand then usecvto output normally. This should happen before the function from which you want to capture output. After the function ends, execute your code to search the message from the arrayar.