change-notification

How can I be notified when an element is added to the page?

筅森魡賤 提交于 2019-11-25 23:49:17
问题 I want a function of my choosing to run when a DOM element is added to the page. This is in the context of a browser extension, so the webpage runs independently of me and I cannot modify its source. What are my options here? I guess that, in theory, I could just use setInterval() to continually search for the element\'s presence and perform my action if the element is there, but I need a better approach. 回答1: Warning! This answer is now outdated. DOM Level 4 introduced MutationObserver,