Thursday 24 September 2020

How to override native function with Puppeteer

Normally I would do it with

await page.evaluateOnNewDocument(my_js_code);

where my_js_code is something like:

Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", ...

But the problem is that after that the code becomes visible

console.log(HTMLCanvasElement.prototype.toBlob.toString());

With the native function the code is not visible, toString returns [native code], not the actual code

So, is there a way I can override a function at a deeper level with Pupeteer?



from How to override native function with Puppeteer

No comments:

Post a Comment