If you want to listen to DOM Mutations then you can use the Mutation Observer.
const observer = new MutationObserver((mutations) => { mutations.forEach(function(mutation) { for (let i = 0; i < mutation.addedNodes.length; i++) { // i.e., nodeList console.log(mutation.addedNodes[i]); // You can perform your actions here. } }); }); observer.observe(document.body, { childList: true, subtree: true, attributes: false, characterData: false, });