Access DOM from webview in Electron atom

Is it possible to clear the html of the webview element in the Atom desktop development tool, I try to access the DOM, but I get nothing, I tried document.links in the console at runtime, but I get empty properties and objects instead?

 window.onresize = doLayout;
 var isLoading = false;

onload = function() {
var webview = document.querySelector('webview');
doLayout();

var t = webview.executeJavaScript("console.log(document.links);");

document.querySelector('#back').onclick = function() {
webview.goBack();
};

<object is="browserplugin" type="application/browser-plugin" id="browser-plugin-1" style="flex: 1 1 auto;"></object>
+4
source share
1 answer

console.log webview, . document.querySelector('webview').openDevTools() ( , - src, ). . . , - , -, webContents . IPC.

, , DOM -, preload script. script - JS API- node.js , DOM. executeJavaScript , preload .

, 1) devtools webview, 2) preload script webview, DOM, 3) - IPC: https://github.com/ccnokes/electron-tutorials/tree/master/preload-scripts

+3

Source: https://habr.com/ru/post/1654600/


All Articles