]> git.r.bdr.sh - rbdr/junction/blobdiff - extension/junction.js
Upload state
[rbdr/junction] / extension / junction.js
index 776096927473e635738e8577f8988675b7e9645e..1d5f8a50b26c5ef8546f43245ba771862fac0aa2 100644 (file)
@@ -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({