From 661a2a436bfac1bb1d4f3b235d1bf26b00135d00 Mon Sep 17 00:00:00 2001 From: hackademix Date: Thu, 28 Mar 2019 12:35:52 +0100 Subject: Chromium-compatible popup closure handling. --- src/bg/popupHandler.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/bg/popupHandler.js (limited to 'src/bg/popupHandler.js') diff --git a/src/bg/popupHandler.js b/src/bg/popupHandler.js new file mode 100644 index 0000000..b893174 --- /dev/null +++ b/src/bg/popupHandler.js @@ -0,0 +1,17 @@ +browser.runtime.onConnect.addListener(port => { + if (port.name === "noscript.popup") { + let pendingReload = false; + let tabId = -1; + port.onMessage.addListener(m => { + if ("pendingReload" in m) { + tabId = m.tabId; + pendingReload = m.pendingReload; + } + }); + port.onDisconnect.addListener(() => { + if (pendingReload) { + browser.tabs.reload(tabId); + } + }); + } +}); -- cgit v1.2.3