I'm trying to access the DOM inside the webview. I understand I need to use IPC, but with the following code which is in the same file, one accesses the parent and one accesses the webview.
Preload.js (using preload
property of webview
)
setInterval(() => {
console.log(document.querySelector('.player')); // shows in webview
}, 1000);
ipcRenderer.on('ppause', () => {
console.log(document); // shows in main window
});
index.js
window.webContents.once('dom-ready', () => {
globalShortcut.register('MediaPlayPause', () => {
window.webContents.send('ppause');
});
});
I want to be able to access the webview DOM (such as in the setInterval function), but I can't seem to figure it out.