Add executeJavaScript method to WebContents

This commit is contained in:
softworkz
2023-09-24 16:36:49 +02:00
parent a15db713ad
commit 73a3e331dc
3 changed files with 42 additions and 0 deletions

View File

@@ -65,6 +65,12 @@ module.exports = (socket) => {
}
});
});
socket.on('webContents-executeJavaScript', async (id, code, userGesture = false) => {
const result = await getWindowById(id).webContents.executeJavaScript(code, userGesture);
electronSocket.emit('webContents-executeJavaScript-completed', result);
});
socket.on('webContents-getUrl', function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-getUrl' + id, browserWindow.webContents.getURL());

View File

@@ -74,6 +74,11 @@ export = (socket: Socket) => {
});
});
socket.on('webContents-executeJavaScript', async (id, code, userGesture = false) => {
const result = await getWindowById(id).webContents.executeJavaScript(code, userGesture);
electronSocket.emit('webContents-executeJavaScript-completed', result);
});
socket.on('webContents-getUrl', function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-getUrl' + id, browserWindow.webContents.getURL());