开发者

Chrome extension adding controls after post back?

I'm writing an extension to modify search results on my school's website adding more information to each returned result. However, when the search page executes a search and the search results are dynamically added to the page, elements added to the page by my extension are removed.

As a simple debug, I added a button next to the search button to click after the search happens, but the act of searching removes my button.

I didn't write the page I'm addi开发者_JS百科ng to, the school has written that in ASP.Net.

How can my extension affect search results after a dynamic post back?


First you would need to find some element on the page that is tied to search results and which presence indicates that search results are ready for processing (lets say it is <div id="search-results">). Then you can listen to DOMSubtreeModified to catch when this element is getting created:

var processed = false;
document.addEventListener("DOMSubtreeModified", function(event){
        if(!processed && document.getElementById("search-results")) {
                processed = true;

                //process
        }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜