How can I run code on a BrowserView before loadUrl in Electron?

I’m trying to set the local storage and cookies of a website before it loads, under the hood.
I am able to do it from the preload but it starts running only when you call loadUrl, which means it could result in a race condition.
Same goes with executeJavascript.

Is there a way to have code execution in the BrowserView context, but guarantee it runs before the website loads?
Delaying/blocking the loadUrl could work as well.

Leave a Comment