browser-base icon indicating copy to clipboard operation
browser-base copied to clipboard

Cant find renderer containing a view instance

Open giuliodz opened this issue 4 years ago • 2 comments
trafficstars

I would like to access the HTML structure of a given View. Views in the main process are organized by a View-Manager. I would like to access the document containing the HTML of a displayed webpage, but I don't know in what file I can request that.

giuliodz avatar Mar 09 '21 19:03 giuliodz

You can manipulate a renderer process DOM by either using webContents.executeJavaScript or sending an IPC message to the webContents and change some HTML in the preload script.

sentialx avatar Mar 09 '21 20:03 sentialx

Objective I am not trying to manipulate it, but I am trying to retrieve the DOM contained in each of the pages (tab) in the main window.

Premise As far as I understood the code, the different views are added and deleted to the main browserWindow by the ViewManager class.

What I tried If iterate over these views and send an ipc message requesting the body of each view's document, I can only respond to that message in the view preload script, which is view-preload.ts. From there, every time I try to return the full document of the view which requested it with ipcRenderer('send-document', document.innerHTML) I am always returning the same DOM, which corresponds to the focused view's document.

Question How can I try to collect all the DOMs from every view in view-manager ( not only the current one )?

giuliodz avatar Mar 09 '21 23:03 giuliodz