diff --git a/index.js b/index.js index 8555315..d2736bf 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ + // @ts-check 'use strict' @@ -267,6 +268,11 @@ function onReady () { case consts.eventNames.windowCmdShow: elements[json.targetID].show() break; + case consts.eventNames.windowCmdLoadUrl: + elements[json.targetID].loadURL(json.url, {}).then(() => { + client.write(json.targetID, consts.eventNames.windowEventLoadedUrl); + }); + break; case consts.eventNames.windowCmdWebContentsCloseDevTools: elements[json.targetID].webContents.closeDevTools() break; @@ -277,11 +283,17 @@ function onReady () { elements[json.targetID].unmaximize() break; case consts.eventNames.windowCmdUpdateCustomOptions: - windowOptions[json.targetID] = json.windowOptions - client.write(json.targetID, consts.eventNames.windowEventUpdatedCustomOptions, json.windowOptions) + client.write(json.targetID, consts.eventNames.windowEventUpdatedCustomOptions, json.windowOptions); break; case consts.eventNames.windowCmdWebContentsExecuteJavascript: - elements[json.targetID].webContents.executeJavaScript(json.code).then(() => client.write(json.targetID, consts.eventNames.windowEventWebContentsExecutedJavaScript)); + elements[json.targetID].webContents.executeJavaScript(json.code) + .then(() => client.write(json.targetID, consts.eventNames.windowEventWebContentsExecutedJavaScript)); + break; + case consts.eventNames.windowCmdWebContentsSetProxy: + elements[json.targetID].webContents.session.clearAuthCache().then(() => { + elements[json.targetID].webContents.session.setProxy(json.proxy) + .then(() => client.write(json.targetID, consts.eventNames.windowEventWebContentsSetProxy)); + }); break; } }); diff --git a/src/consts.js b/src/consts.js index 38fa3f3..d8b9720 100644 --- a/src/consts.js +++ b/src/consts.js @@ -93,11 +93,13 @@ module.exports = { windowCmdSetBounds: "window.cmd.set.bounds", windowCmdRestore: "window.cmd.restore", windowCmdShow: "window.cmd.show", + windowCmdLoadUrl: "window.cmd.load.url", windowCmdUnmaximize: "window.cmd.unmaximize", windowCmdUpdateCustomOptions: "window.cmd.update.custom.options", windowCmdWebContentsCloseDevTools: "window.cmd.web.contents.close.dev.tools", windowCmdWebContentsOpenDevTools: "window.cmd.web.contents.open.dev.tools", windowCmdWebContentsExecuteJavascript: "window.cmd.web.contents.execute.javascript", + windowCmdWebContentsSetProxy: "window.cmd.web.contents.set.proxy", windowEventBlur: "window.event.blur", windowEventClosed: "window.event.closed", windowEventDidFinishLoad: "window.event.did.finish.load", @@ -116,7 +118,9 @@ module.exports = { windowEventShow: "window.event.show", windowEventUnmaximize: "window.event.unmaximize", windowEventUnresponsive: "window.event.unresponsive", + windowEventLoadedUrl: "window.event.loaded.url", windowEventWebContentsExecutedJavaScript: "window.event.web.contents.executed.javascript", + windowEventWebContentsSetProxy: "window.event.web.contents.set.proxy", windowEventUpdatedCustomOptions: "window.event.updated.custom.options" }, targetIds: {