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

225
Vistas
Can you track what caused a mutation record with MutationObserver?

I am working on a Google Chrome extension and have something like the following code below. While there is nothing wrong with the code below there is a slight issue I am having trouble resolving.

I'm using this code to detect if the reports-content class was changed from losing focus on an input control or if a timer was the action that caused the change.

The problem is, I only want to do something if the change was the result of losing focus on the input control and NOT the timer.

I want to do this so I can loop through different inputs and only try new inputs once the 'reports-content' has updated with new data.

The 'timer' is outside my control since it's on a third party website (tradingview.com), which happens to be using React framework in case that is important. Every-time the price changes it will detect as a mutation to the object I'm checking, which is not a bug, that is good that it does that, but I need to be able to discern which mutation was caused from that (timer/event/change), and which came from the input control losing focus.

enter image description here

Below is an example of the two mutation records I currently see, one caused by the event and the other the timer or (price change noticed event).

enter image description here

Below this is an example of what the reports-content looks like.

enter image description here

//When the DOM is ready set the mutation listner.
$(document).ready(function(){
    console.log("JQuery Ready");

    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(record => {
            var recordTarget = record.target;
            
            if(record.addedNodes.length>0){
                if(recordTarget.classList.contains("reports-content")){
                    console.log(recordTarget);
                    console.log(record);
                };
            }
                    
        });
    });

    //Use mutation observer on 'body' to wait for the existence of the .reports-content class node
    var target = $('body')[0];
    var config = {
        childList:true,
        subtree: true
    };
    observer.observe(target, config);
});
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