From 0ba33b755943e55ca164b9a8dab2d9046b974d64 Mon Sep 17 00:00:00 2001 From: Kaguya <46781337+true-zero@users.noreply.github.com> Date: Wed, 3 Feb 2021 11:25:17 +0000 Subject: [PATCH 1/5] Update consts.js --- src/consts.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/consts.js b/src/consts.js index 38fa3f3..f9f7f0f 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.load.url", windowEventWebContentsExecutedJavaScript: "window.event.web.contents.executed.javascript", + windowEventWebContentsSetProxy: "window.event.web.contents.set.proxy", windowEventUpdatedCustomOptions: "window.event.updated.custom.options" }, targetIds: { From ec0fb830758384bb417c70bfb535430d8c8c10e0 Mon Sep 17 00:00:00 2001 From: Kaguya <46781337+true-zero@users.noreply.github.com> Date: Wed, 3 Feb 2021 11:25:53 +0000 Subject: [PATCH 2/5] Update index.js --- index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 8555315..7d22360 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ + // @ts-check 'use strict' @@ -267,6 +268,12 @@ 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 +284,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({proxyRules: json.proxy}) + .then(() => client.write(json.targetID, consts.eventNames.windowEventWebContentsSetProxy)); + }); break; } }); From cfc30ce7978f0055ed10fed8df5358d67c90cce9 Mon Sep 17 00:00:00 2001 From: Kaguya <46781337+true-zero@users.noreply.github.com> Date: Thu, 4 Feb 2021 16:08:53 +0000 Subject: [PATCH 3/5] Update consts.js --- src/consts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consts.js b/src/consts.js index f9f7f0f..d8b9720 100644 --- a/src/consts.js +++ b/src/consts.js @@ -118,7 +118,7 @@ module.exports = { windowEventShow: "window.event.show", windowEventUnmaximize: "window.event.unmaximize", windowEventUnresponsive: "window.event.unresponsive", - windowEventLoadedUrl: "window.event.load.url", + 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" From e69c845716296adef0b40630983a6c7a36ba3b4e Mon Sep 17 00:00:00 2001 From: Kaguya <46781337+true-zero@users.noreply.github.com> Date: Thu, 4 Feb 2021 16:13:28 +0000 Subject: [PATCH 4/5] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7d22360..375af49 100644 --- a/index.js +++ b/index.js @@ -292,7 +292,7 @@ function onReady () { break; case consts.eventNames.windowCmdWebContentsSetProxy: elements[json.targetID].webContents.session.clearAuthCache().then(() => { - elements[json.targetID].webContents.session.setProxy({proxyRules: json.proxy}) + elements[json.targetID].webContents.session.setProxy(json.proxy) .then(() => client.write(json.targetID, consts.eventNames.windowEventWebContentsSetProxy)); }); break; From a8783fd2b04981ecc5b3b8901734e7918f34bb0a Mon Sep 17 00:00:00 2001 From: Kaguya <46781337+true-zero@users.noreply.github.com> Date: Thu, 4 Feb 2021 20:29:22 +0000 Subject: [PATCH 5/5] Update index.js --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index 375af49..d2736bf 100644 --- a/index.js +++ b/index.js @@ -273,7 +273,6 @@ function onReady () { client.write(json.targetID, consts.eventNames.windowEventLoadedUrl); }); break; - case consts.eventNames.windowCmdWebContentsCloseDevTools: elements[json.targetID].webContents.closeDevTools() break;