Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!