X-Git-Url: https://git.r.bdr.sh/rbdr/junction/blobdiff_plain/3f2e36eabf1494ac60a3cf533d3db86d25a6cc39..00ad5f1d98951ed9ab84cd28e8467bb3911497a1:/extension/content_script.js?ds=sidebyside diff --git a/extension/content_script.js b/extension/content_script.js index c344bd9..0c7012b 100644 --- a/extension/content_script.js +++ b/extension/content_script.js @@ -26,6 +26,11 @@ const internals = { console.error(error.stack || error); }, + connect() { + internals.port = chrome.runtime.connect({ name: "content" }); + internals.port.onMessage.addListener(internals.onMessage); + }, + async joinAudioCall({ currentUrl, tada }) { try { const mediaStream = await startMedia(); @@ -56,7 +61,7 @@ const internals = { shouldCreateOffer, mediaStream, onOffer: (data) => socket.emit("relayOffer", data), - socket + socket, }); playTada(); }); @@ -84,8 +89,10 @@ const internals = { }, }; -internals.port = chrome.runtime.connect({ name: "content" }); -internals.port.onMessage.addListener(internals.onMessage); +internals.connect(); +chrome.runtime.onConnect.addListener(() => { + internals.connect(); +}); console.debug("Content Script Loaded");