A Greasemonkey Script that inserts a Google Site Search form into every page
I often find myself wanting to use google to search within a site I’m visiting. My current method is to navigate to the search box in firefox (cmd-k) and type “site:domain-of-site search-term”. That’s a bit painful so I finally got around to creating a greasemonkey script to make it easier. Install the script from the userscripts site.
Once installed, you can hit ctrl-9 on any page (except google, that’d be crazy) and a search form will appear at the top of the page ready for you to type into.
The simplest thing is to type your search term and tap enter to view the google results. However, it’s often useful to restrict your search to more than just the domain of the site (I might want to search for things I’ve said in twitter, site:twitter.com/chrisroos, for example) so there’s a drop down list of url components that you can use to restrict which areas of the site you want to search. Pressing escape within any of the fields in the search form will hide it again.
A previous version of this script would display the search form at the top of each page all the time. That didn’t play nice with absolutely positioned elements already in the page though, hence my decision to only show it when you actually need it. There’s still work to do (one of the main problems is that the search form will currently be inserted into every frame on a page, including iframes) but I think it’s useful enough to get out there.