How to track DOM change in chrome extension?

前端 未结 2 1616
别跟我提以往
别跟我提以往 2020-12-31 01:06

I am writing a chrome extension where I want to fetch all the images exist on a page but some of the images load after some time (may be through ajax) which I could not fetc

2条回答
  •  失恋的感觉
    2020-12-31 01:53

    You can use document.addEventListener with the DOMNodeInserted event. Your callback will have to check each node insertion to see if it is the type of node you are looking for. Something like the following should work.

    function nodeInsertedCallback(event) {
        console.log(event);
    };
    document.addEventListener('DOMNodeInserted', nodeInsertedCallback);
    

提交回复
热议问题