开发者

Attach listener to AJAX event via chrome extension

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜