summaryrefslogtreecommitdiff
path: root/src/bg/popupHandler.js
blob: b8931744d2a25281346c1d0d656764001516d3df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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);
      }
    });
  }
});