I have an electron app that opens a browser window with a certain web page. Now, I want to execute some javascript on that page as the very first thing. But whatever I try, it always seems to run after some other JS on the web page I open.
I tried some events like did-start-loading, e.g.:
window.webContents.on('did-start-loading', () => {
window.webContents.executeJavaScript("console.log('test');");
})
And by putting it directly after the loadUrl:
window.loadURL(url);
window.webContents.executeJavaScript(`console.log('test');`);
But in both cases test gets logged after some other javascript has ran on the page.