开发者

Attach listener to AJAX event via chrome extension

开发者 https://www.devze.com 2023-03-25 00:48 出处:网络
I want to attach a listener to a AJAX update, so that I can reload my chrome extension. Right now if a user clicks and goes to another section of the site that is loaded via AJAX the extension doesn\'

I want to attach a listener to a AJAX update, so that I can reload my chrome extension. Right now if a user clicks and goes to another section of the site that is loaded via AJAX the extension doesn't show up. This site is not my site, so I don't control the AJAX updating. 开发者_C百科Thanks!


You can't listen to ajax requests (without using experimental api), but you can listen to DOMSubtreeModified event that fires whenever DOM is modified:

document.addEventListener("DOMSubtreeModified", function(event){
        //something on the page has changed
});

Just need to be careful as there might be hundreds of such events firing in seconds when big chunk of page is modified. Might need to implement some delay.

0

精彩评论

暂无评论...
验证码 换一张
取 消