Hack #57. Remember Recent Google Searches
Track what you search for and which search results you follow.
Google recently added yet another beta service: My Search History (http://www.google.com/searchhistory/). In a nutshell, you log into your Google account, and My Search History remembers which keywords you search for and which search results you end up following. A nice idea, but it has some limitations that disappointed me when I tried it. My Search History isn't immediately available on the Google home page. Also, clicking a previous search simply reexecutes the search, instead of actually taking me to the result I followed last time. How is that useful? I remember what I searched for; what I want to know is what I found!
This hack lets me do what I had hoped the "My Search History" tool would do.
The Code
This user script runs on all Google pages. The code itself breaks down into three distinct parts:
The
SavedSearchesfunction and associated prototype methods are used to create a persistent array—i.e., anArrayclass that saves its data to the Firefox preferences database.The
getCurrentSearchText,addCurrentSearch,clearSavedSearches, andinjectRecentSearchesfunctions handle the basic operations of the script. Whenever you execute a Google search, the script adds your keywords to its persistent array, and then alters the search results page to include a list of your recent searches.The
trackClickfunction is where the real magic happens. On search result pages, we register ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access