Tuesday, July 30, 2024

Deprecation Listener added for a 'DOMSubtreeModified' mutation event. Support for this event type has been removed, and this event will no longer be fired. See chromestatus com/feature/5083947249172480 for more information.

[Deprecation] Listener added for a 'DOMSubtreeModified' mutation event. Support for this event type has been removed, and this event will no longer be fired. See https://chromestatus.com/feature/5083947249172480 for more information. 

old code
 $('.lg-map-text').bind("DOMSubtreeModified", function () {

           if ($('.lg-map-text').text() != "") {

                var getHtml = $('.lg-map-text');

              var state = getHtml["0"].children[1].value;

               if (state != undefined) {

                    GetDescription(state);

                    $('html, body').animate({

                        scrollTop: $('.whitesec').offset().top

                    }, 800

            );

                }

           }

        });


new changes 

// Function to be called when the mutation is observed

function onMutation(mutationsList, observer) {

    // Iterate through all mutations

    for (let mutation of mutationsList) {

        // Check if the mutation is a change to the text content

        if (mutation.type === 'childList' || mutation.type === 'subtree') {

            // Check if the element has text content

            if ($('.lg-map-text').text() != "") {

                var getHtml = $('.lg-map-text');

                var state = getHtml[0].children[1].value;

                if (state != undefined) {

                    GetDescription(state);

                    $('html, body').animate({

                        scrollTop: $('.whitesec').offset().top

                    }, 800);

                }

            }

        }

    }

}


// Select the target node

var targetNode = document.querySelector('.lg-map-text');


// Create a new MutationObserver instance and pass the callback function

var observer = new MutationObserver(onMutation);


// Options for the observer (which mutations to observe)

var config = { childList: true, subtree: true };


// Start observing the target node for configured mutations

observer.observe(targetNode, config);