diff options
Diffstat (limited to 'src/bg')
-rw-r--r-- | src/bg/main.js | 2 | ||||
-rw-r--r-- | src/bg/popupHandler.js | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/bg/main.js b/src/bg/main.js index 8ff2d55..667be28 100644 --- a/src/bg/main.js +++ b/src/bg/main.js @@ -49,7 +49,7 @@ // no embedder to answer us } log("STARTED"); - + await include("/bg/popupHandler.js"); }; let Commands = { 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); + } + }); + } +}); |