Search code examples
pythonseleniumgoogle-chromedevtools

How to find and read injected script using addScriptToEvaluateOnNewDocument in Browser?


I am using a addScriptToEvaluateOnNewDocument to inject a JS into a browser page.

I know that this script will be executed before the page loads.

Is it possible to see that script in the browser? For example I expected it to be in Chromes DevTools below "Sources", but couldn't find anything there.


Solution

  • Adding the following line at the end of the script made it possible:

    //# sourceURL=browsertools://custom/filename.js