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

118
Visualizações
MutationObserver not working if tab not focused

I am working on a chrome extension and i have a problem with MutationObserver, not sure if i am missing something or it's the normal behavior. The observer works when i am on the chrome tab which uses the mutation i receive messages when changes happens normal, but when i am not on tab, either i am on another tab or another window nothing happens until i comeback to the tab where i use mutation.

exemple let's say i use stackoverflow.com on a tab where i observe mutation all good i get the changes then i keep my tab open and i switch to another tab, the mutations stopped working like if the dom doesn't update when i am on another tab till i comeback.

window.onload = () => {


  console.log("init observer");

  let mutationBinaryObserver = new MutationObserver(function (mutations) {
    mutations.forEach(function (mutation) {
      if (
        mutation.target &&
        mutation.target.className &&
        typeof mutation.target.className === "string" &&
        mutation.target.className.indexOf("dialog-subtitle-badge") >= 0
      ) {
        getChatMessages();
      }
    });
  });
});

Thanks for your help and advice, my goal is to be using my computer and receiving updates from a tab on chrome even if i am not focusing it.

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