mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-14 12:47:57 +00:00
Add executeJavaScript method to WebContents
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user