A FireFox Hack: Search the current site with Google
Google lets users search within a single domain by using the syntax"site:" followed the domain. On its Search Features page, Google gives this example:
I extended this concept so that it can be used with the Google search bar in FireFox to search the current site with the syntax "site:this". Here's two screen shots to show how it works (click to make the picture bigger):

I inserted this code into the file 'nsSearchService.js' right after line 734. (This file is located inside FireFox's components folder on your local machine.) The beauty of this technique is that it could be applied in other ways. For example, users could preface a search with "images" to conduct a Google Image Search from the search bar in FireFox.
I believe the solution I propose above is the fastest and most direct way to integrate "search this site" functionality into FireFox. Nonetheless, it bears mention that similar solutions exist; in the form of a separate search engine or a custom bookmark/search via the location bar or even a special button. In addition, Google's Advanced Toolbar for Firefox enables users to search within the current site. However, a special button is required; there's no syntax that I know of to streamline this process.
*** Note: code revised June 11, 2008 ***
Here's how you'd find admission information on the Stanford University site:
I extended this concept so that it can be used with the Google search bar in FireFox to search the current site with the syntax "site:this". Here's two screen shots to show how it works (click to make the picture bigger):

I inserted this code into the file 'nsSearchService.js' right after line 734. (This file is located inside FireFox's components folder on your local machine.) The beauty of this technique is that it could be applied in other ways. For example, users could preface a search with "images" to conduct a Google Image Search from the search bar in FireFox.
I believe the solution I propose above is the fastest and most direct way to integrate "search this site" functionality into FireFox. Nonetheless, it bears mention that similar solutions exist; in the form of a separate search engine or a custom bookmark/search via the location bar or even a special button. In addition, Google's Advanced Toolbar for Firefox enables users to search within the current site. However, a special button is required; there's no syntax that I know of to streamline this process.
*** Note: code revised June 11, 2008 ***

2 Comments:
Hey I think your idea's awesome but I was wondering if you could give me some help.
When I added the code to line 734 and type "site:this" to the google search bar, all google did was search the site 'this'.
I thought that I might be adding the code after the wrong line...
for me line 734 reads: " * Creates an engineURL object, which holds the query URL and all parameters."
Any idea what's wrong?
Thanks so much.
ewanog:
I guess the line numbers vary slightly depending on your version of FF and operating system. The site:this hack should go after this chunk of code:
// Custom search parameters. These are only available to app-shipped search
// engines.
if (aEngine._isInAppDir) {
value = value.replace(MOZ_PARAM_LOCALE, getLocale());
value = value.replace(MOZ_PARAM_DIST_ID, distributionID);
value = value.replace(MOZ_PARAM_OFFICIAL, MOZ_OFFICIAL);
}
You might wish to simply backup your current nsSearchService.js file by saving it with a new name and insert this file in its place:
http://www.room117.com/nsSearchService.js
That should work.
Hope this helps.
Post a Comment
Links to this post:
Create a Link
<< Home