0

I am developing a Chrome Extension using Manifest V3, and I need to transcribe speech to a Google Document. I am currently using a service-worker.js to authenticate to Google using chrome.identity.getAuthToken, and I am communicating with my main.js via a port using port.postMessage(). However, I am experiencing performance and complexity issues with this approach. How should I continue doing the communication, with the current sw, to create another js file or it doesn't matter?

VladTbk321
  • 73
  • 8
  • What is `main.js` is it part of a popup, a content script ? – Titus Mar 20 '23 at 16:30
  • Yeah is a content script with the main logic – VladTbk321 Mar 20 '23 at 16:52
  • 1
    As far as I know, in MV3, you can only make API requests (AJAX) calls from the background service worker. Also, port connections work a bit different in MV3. I think you should keep the current approach but you may need to change it to `chrome.runtime.onMessage.addListener(..)` and `chrome.runtime.sendMessage(..)` instead of a port connection. I think port connection can be disconnected unexpectedly where as, `chrome.runtime.sendMessage(..)`, will start the service worker. – Titus Mar 20 '23 at 17:18

0 Answers0