X-Git-Url: https://git.r.bdr.sh/rbdr/junction/blobdiff_plain/5685e249653cae8c2ba97c0c59c45e3221d8ffa2..650c5f155e98dc8428ab617a535541736c9dd08f:/extension/junction.js?ds=inline diff --git a/extension/junction.js b/extension/junction.js index 7760969..1d5f8a5 100644 --- a/extension/junction.js +++ b/extension/junction.js @@ -1,6 +1,6 @@ const internals = { promisesSupported: !!window.browser, - injectedScript: false, + injectedScript: {}, port: null, currentUrl: null, @@ -62,24 +62,26 @@ const internals = { const activeTabs = await internals.getActiveTabs(); internals.currentUrl = activeTabs[0].url; - if (!internals.injectedScript) { + const id = activeTabs[0].id; + if (!internals.injectedScript[id]) { const execution = await internals.getRoot().tabs.executeScript( activeTabs[0].id, { file: "/build/content_script.js", }, () => { - internals.injectedScript = true; + internals.injectedScript[id] = true; }, ); - } else { - internals.getRoot().tabs.connect(activeTabs[0].id) - } - if (execution && !execution[0]) { - internals.onDisconnect(); + if (execution && !execution[0]) { + internals.onDisconnect(); + } + } else { + internals.getRoot().tabs.connect(activeTabs[0].id); } }, + hangUp() { internals.getRoot().browserAction.disable(); internals.port.postMessage({