Missing required property 'tabId'

Viewed 254

In the background.js I have a listener that is supposed to check if the page is fully loaded and then run a content script:

console.log('background.js started');
chrome.webNavigation.onCompleted.addListener(function(tab) {
  chrome.scripting.executeScript({
        target: { tabId: tab.Id, allFrames: true },
        files: ['findname.js'],
      });
    console.log('script execution started')
});

But it returns an error:

Error at parameter 'injection': Error at property 'target': Missing required property 'tabId'

I've tried to solve this by creating a variable "tabId" and assigning it with the id of the active tab. The best thing I've found for this is

const tabId = chrome.tabs.get(tabId);

but it doesn't work either.

I'll appreciate your help!

0 Answers
Related