Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda