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

190
Views
Is there a way for browser.tabs.sendMessage to all tabs?

Currently, I have this in my background script:

function disable(tabs) {
    for (var i = 0; i < tabs.length; ++i) {
        browser.tabs.sendMessage(tabs[i].id, {
        command: "Disable"
        });
    }
}

else if (e.target.classList.contains("disable")) {
    browser.tabs.query({})
    .then(disable)
}

I have this in my content script:

(function () {
    
    if (window.hasRun) {
    return;
  }
    window.hasRun = true;

    function disableHelper() {
        clearInterval(Interval1)
        console.log("Helper has been disabled")
    }
        
    browser.runtime.onMessage.addListener((message) => {
        if (message.command === "Blah") {
            var Interval1 = setInterval(changeToHelper, 15000);
            Interval1;
        } else if (message.command === "Disable") {
        disableHelper();
        }
    });
                        
})();

I have permissions set to only run this on sites with specified URLs and it works when the tab is in focus/active.

However, if I click "Disable" within my popup on another tab that is not part of the permissions it won't Disable properly on the desired tab.

Is there a way to 'sendMessage' to all tabs regardless if they're in focus/active?

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!