0

I am building a Chrome Extension that does Speech to Text into a Google Document. I was using service-worker at first to log in the user but as of now (because in the service-worker I had the ID and the token of the current user) I wanted also to post the incoming data. I was doing this with a fetch request, and everything worked but then I started adding more and more variables it stopped working. I noticed that while adding some random variables let's say

let x = 'x';
let y = 'y';
let z = 'z';
let foo = 'bar';

.When the extension starts, I should get in DevTools a confirmation that the communication port is created:

if (port.name === 'main-port') {
        console.log(
            'Connection established from content script:',
            port.sender.tab.id
        );

and the ID of the user from auth function:

chrome.tabs.onUpdated.addListener(async (tabId, currState, tab) => {
                if (
                    currState.status == 'complete' &&
                    tab.status == 'complete' &&
                    tab.url != undefined
                ) {
                    if (tab.url.includes('https://docs.google.com/document')) {
                        myDocumentID = tab.url.substr(35, 44); // gets current docs
                        chrome.identity.getAuthToken({ interactive: true }, (token) => {
                            if (chrome.runtime.lastError || !token) {
                                console.log(`${JSON.stringify(chrome.runtime.lastError)}`);
                                return;
                            }
                            myToken = token;
                            console.log(myDocumentID);
                        });
                    }
                }
            });

Yet with adding those random variables I only got the confirmation that connection was established. Why that could happen?

isherwood
  • 58,414
  • 16
  • 114
  • 157
VladTbk321
  • 73
  • 8

0 Answers0