I want to wrap console functions like below.
const realLog = console.log;
console.log = function (){
myFunction(arguments);
realLog(arguments);
}
The problem is content scripts run in an isolated environment, so I can't redefine console.log. Since there is no event for console.log, though can use error for errors, I can't reach page's console.log messages.
To prevent prospective XY problem I want to read console messages, from a web extension, without removing them from console. I can use content, background, action script etc. It doesn't matter, since I can use messaging to pass between them.
It's possible because there is an extension built on this.
I looked at other posts, they didn't help.