Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
How to retrieve the active tab ID on my content script?

In my manifest file I have both tabs and activeTab permssion. I'm trying to obtain the current tab id from my content script, here is what I'm doing:

  console.log("here");
  browser.tabs.getCurrent()
    .then(getTab)
    .catch(reportTabError);
    function reportTabError(error) {
      console.error(`Could not process: ${error}`);
    }       
    function getTab(tabInfo){
      console.log("here 2"); //this never fires
      window.currentTabId = tabInfo.id;
    }

I also did a different version, same result:

  console.log("here");
  browser.tabs.query({currentWindow: true, active: true})
    .then(getTab)
    .catch(reportTabError);
    function reportTabError(error) {
      console.error(`Could not process: ${error}`);
    }       
    function getTab(tabInfo){
      console.log(tabInfo.id); //this never fires
      //window.currentTabId = tabInfo.id;
    }

The overall idea is to store the active tab IDs for a possible future update. What I want to achieve is to eventually notify all open tabs that the user changed the settings in the option page, and to update the interface loaded in the tabs accordingly.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda