Consider this scenario where a BrowserWindow
is set up with specific security settings, including enabling the webviewTag: true
for project requirements.
let webPrefs = {
plugins: false,
nodeIntegration: false,
nodeIntegrationInWorker: false,
webviewTag: true,
sandbox: true,
enableRemoteModule: false,
contextIsolation: true,
disableBlinkFeatures: "Auxclick",
webSecurity: true
};
let winOpts = {
...
show: true,
webPreferences: webPrefs
};
...
win = new BrowserWindow(winOpts);
const view = new BrowserView(winOpts);
win.setBrowserView(view);
...
view.webContents.loadURL("https://example.com").then(result => {
....
});
Suppose the website example.com
has a <form>
with various <input>
fields for user input.
Users will interact by typing text into these <input>
fields.
The goal is to extract the 'manually filled' text from these <input>
fields without the ability to modify the webpage.
While webContents.executeJavaScript()
can initiate actions, extracting the actual input values to the main
process remains unclear.
(Filling out forms from the main process can be achieved using the mentioned function.)
How can we accomplish this task?