Chrome extension to parse Google results doesn't work

前端 未结 2 1457
不知归路
不知归路 2020-12-07 03:43

I\'ve been experimenting with the Chrome extensions mechanism, and been trying to write an extension that would manipulate Google results (add comments, screenshots, favicon

2条回答
  •  清歌不尽
    2020-12-07 04:12

    I just wrote an extension that manipulates Google search results. It seems the issue is that the results are almost always fetched via AJAX. I used MutationObserver to periodically check for changes in the results. There are two types of Google Search pages (which I have encountered thus far): Standard and Google Instant. For standard pages, you need to observe the body element (you can use selector "#gsr"), but for Google Instant, you can just look for the containing DIV ("#search"). You will want to observe childList and subtree mutations.

    (Edited per @ExpertSystem's comments)

提交回复
热议问题