Take the 2-minute tour ×

Hi I'm writing a chrome extension to inject information into google search results. The only problem is that searching is now done through ajax instead of http. This means my code is only being executed once. This is a problem because my script needs to render on each new page. The only way to make it work is by refreshing the page manually (automatic refresh is possible? but ugly).

How can I alert my code to execute anytime google tries to search or fecth the next page of results?

share|improve this question
add comment

2 Answers

You might need to hook in a javascript for the search button to make it call your code as well as the AJAX code to do the Google search. You would have to search the DOM for the button and change the onClick action. Remember to call the original action! :)

share|improve this answer
add comment

Ancient question but...

I accomplished this using 'window.onhashchange'. Whenever Google search results are updated, the URL is adjusted to contain the new queries. I parse the URL every time it changes, whether visiting a new page or a hash change (generally the result of AJAX), check if it's a google search result page, then do my thing.

See also: On - window.location.hash - change?

share|improve this answer
add comment

Your Answer


