2019-03-08 23:53:25 +00:00
|
|
|
const { ipcRenderer, webFrame } = require('electron');
|
|
|
|
|
|
|
|
if (process.isMainFrame) {
|
|
|
|
// https://github.com/electron/electron/issues/17252
|
|
|
|
ipcRenderer.on('executeJavaScriptInFrame', (event, frameRoutingId, code, responseId) => {
|
|
|
|
const frame = webFrame.findFrameByRoutingId(frameRoutingId);
|
|
|
|
if (!frame) {
|
|
|
|
throw new Error(`Can't find frame for routing ID ${frameRoutingId}`);
|
|
|
|
}
|
2019-04-30 14:08:33 +00:00
|
|
|
frame.executeJavaScript(code, false).then(result => {
|
2019-03-08 23:53:25 +00:00
|
|
|
event.sender.send(`executeJavaScriptInFrame_${responseId}`, result);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|