]> git.r.bdr.sh - rbdr/junction/blobdiff - extension/junction.js
Add new RTC code
[rbdr/junction] / extension / junction.js
index a662f6c8f612150cca9843e57262e613e9ea7075..889e23f975dfdd3dccb9ce7dd081367fe33023e8 100644 (file)
@@ -2,6 +2,7 @@ const internals = {
 
   promisesSupported: !!(window.browser),
   port: null,
 
   promisesSupported: !!(window.browser),
   port: null,
+  currentUrl: null,
 
   icons: {
     call: {
 
   icons: {
     call: {
@@ -31,6 +32,7 @@ const internals = {
     port.postMessage({
       action: 'joinAudioCall',
       data: {
     port.postMessage({
       action: 'joinAudioCall',
       data: {
+        currentUrl: internals.currentUrl,
         tada: internals.getRoot().runtime.getURL('sounds/tada.wav')
       }
     });
         tada: internals.getRoot().runtime.getURL('sounds/tada.wav')
       }
     });
@@ -48,6 +50,7 @@ const internals = {
   onDisconnect() {
     internals.getRoot().browserAction.setBadgeText({ text: '' }, () => {});
     internals.setIcon('call');
   onDisconnect() {
     internals.getRoot().browserAction.setBadgeText({ text: '' }, () => {});
     internals.setIcon('call');
+    internals.currentUrl = null;
     internals.port = null;
     internals.getRoot().browserAction.enable();
   },
     internals.port = null;
     internals.getRoot().browserAction.enable();
   },
@@ -57,13 +60,19 @@ const internals = {
     internals.getRoot().browserAction.disable();
     const activeTabs = await internals.getActiveTabs();
 
     internals.getRoot().browserAction.disable();
     const activeTabs = await internals.getActiveTabs();
 
-      const execution = await internals.getRoot().tabs.executeScript(activeTabs[0].id, {
-        file: '/content_script.js'
-      });
+    internals.currentUrl = activeTabs[0].url;
+    const execution = await internals.getRoot().tabs.executeScript(activeTabs[0].id, {
+      file: '/build/content_script.js'
+    }, () => {
 
 
-      if (!execution || !execution[0]) {
+      if (internals.getRoot().runtime.lastError) {
         internals.onDisconnect();
       }
         internals.onDisconnect();
       }
+    });
+
+    if (execution && !execution[0]) {
+      internals.onDisconnect();
+    }
   }
   ,
 
   }
   ,
 
@@ -105,7 +114,7 @@ const internals = {
       return internals.getRoot().tabs.query(query);
     }
 
       return internals.getRoot().tabs.query(query);
     }
 
-    return new Promise((resolve, reject) => {
+    return new Promise((resolve) => {
 
       internals.getRoot().tabs.query(query, (tabs) => {
 
 
       internals.getRoot().tabs.query(query, (tabs) => {