Simple custom searches in Opera
Even before Opera became my primary browser, it was my research browser, mainly because of its power and customizability in searching when compared with other browsers. With version 2.0, Firefox is finally beginning to catch up to Opera in terms of advanced searching features, but Opera 9.0 is still the easiest browser in which to set up these advanced searching features. And with the possibility of putting an "enable proxy servers" checkbox in Opera's main window, it only takes one click and a couple keystrokes to perform an advanced search on subscription-only sites via a proxy server, making it an ideal browser for conducting academic research.
Here's how to set up a custom search in Opera: go to a site which you search frequently, right-click (Ctrl-click on a Mac) on the search box, and click on "Create search..." In the dialog box that comes up, enter a name for the search, and, if you want to enable it as a keyword search from the address bar, enter a short keyword, ideally one or two letters that you'll find easy to remember. If you like, you can also check the box to designate any of your custom sites as your default search engine, replacing Google as the default in the search bar. Clicking OK will create your custom search.
You can use your new custom search in one of two ways: select it from the drop-down menu of the search bar, or type the keyword in the address bar followed by a space and the term you want to search. For example, if you created a custom search for newsforge.com, with the keyword
nf opera 9.0 in the address bar to search for NewsForge articles on Opera 9.0.
If your custom search does not work, double-check the search URL for your custom search under the "Search" tab of the Opera preferences menu. Occasionally, I have found that Opera does not detect the correct URL format for a site. If this is the case, perform a search on the site, and copy the URL from the address bar of the results page. Then you can edit your custom search in Opera preferences: paste in the URL from the results page, replacing the search term in the URL with
%s. For example, when searching newsforge.com for "Opera," the results page contains the URL:
which is the proper URL for your custom search.
Advanced custom searches in Opera
The real power of custom searches comes in performing advanced (or "refined") searches. For example, I have four custom search bars for my university library, which search by author, title, keyword, and call number, respectively. I also frequently search JSTOR, an online host to PDF articles from a number of academic print journals. I thus created a search bar for JSTOR which searches by author, and which is limited to journals in my discipline. These, and other, search customizations are great time-savers for my research.
Obtaining the URL for an advanced search is just like the above procedure for finding a regular search URL: perform an advanced search on a site you visit frequently, take the URL of the results page, and substitute
%s for the search terms in the URL. For example, performing a title search at the Yale Library for Sweet Anticipation (a great new book on musical cognition by David Huron) yields the following URL:
Replacing the search terms with
This URL can then be used to create a new custom search under the "Search" tab in Opera Preferences.
You can even use the advanced search features of a standard search engine to generate powerful custom searches for sites which do not support advanced search features. For example, my personal site does not have any built-in search capabilities. However, using Google's "Advanced Search," I search Google's database for "bartok," limiting the results to my domain, shaffermusic.com, and PDF documents only. With the search term removed, I obtain the following search URL:
which I can use to search only the PDF documents on my site, in spite of the fact that my site does not have that functionality built into it. While such a search is limited to the site information in Google's database, this is still a valuable tool for sites which have little or no native search support.
Custom searches in Firefox
Firefox 2.0, currently in beta, introduces an address-bar keyword search similar to that of Opera. This is the most convenient custom search capability in Firefox, and it is also the easiest to set up.
To create a custom keyword search, right-click on the search box on the desired Web site, and click "Add a Keyword for this Search..." In the dialog box that comes up, enter a name and a keyword, and specify a bookmark location for it. You then use it the same way as the Opera custom search: in the address bar, type they keyword followed by the search term (i.e.
nf firefox to search newsforge.com for articles on Firefox). If there are errors with the automatic URL, or if you want to create an advanced custom search, go to "Organize Bookmarks...", where you can create or edit a keyword-search bookmark just as you would in Opera preferences. I personally find it awkward that the searches are treated as special bookmarks in Firefox, especially since accidentally clicking on "Yale Library Author Search" instead of "Yale Library" in my bookmarks calls up an error page. But if you are careful to keep your search bookmarks separate from your regular bookmarks, this should not be much of an issue.
You may desire, however, to create a custom search bar for Firefox. This is your only custom searching option in Firefox 1.5, and in Firefox 2.0, search bars can be equipped with search suggestions, which appear while you're typing in search terms for a site. Creating a custom search bar requires some coding, but armed with a template, it requires little more than entering a custom search URL and a title. Here is a template for a Firefox 1.x search plugin:
<input name="" user="">
The custom search's URL should be broken up into three parts which are inserted into the template: 1) the URL for the search function (usually the page with the search box, but occasionally a separate script), 2) the query code, and 3) any options that follow the query. As an example, I will use the search plugin I created for AmSteg.org, a site which I administer. The search URL (with wildcard) is
which parses into
(there is no information after the query in this and many other cases).
The page URL goes in the
action="" line of the template, and the query becomes an
input tag. Additionally, plug in the name and description for the search plugin, and the URL of the search page (
searchForm=""). Developers creating plugins for their site can also insert a URL for the plugin and its icon, so that Firefox can detect any changes made to the plugin on the host site. The final plugin for AmSteg.org looks like this:
<input name="s" user="">
(note that in creating the
?s=%s has become
<input name="s" user="">)
Advanced searches typically have information following the query in the search URL. The Yale Library Title Search mentioned above is a perfect example:
In this case (and many others), the query is followed by multiple
x=y statements, all separated by
&. For a URL like this, parse out the search form and query like normal, and then give each
x=y statement its own
input tag like so:
<input name="x" value="y">
Thus, the plugin for the Yale Library Title Search looks like this:
name="Yale Library - Title"
description="Search Yale Library"
<input name="Search_Arg" user="">
<input name="Search_Code" value="TALL">
<input name="DB" value="local">
<input name="CNT" value="50">
Note the difference in the way the search query
?Search_Arg=%s and the search limits are transformed into their respective input tags.
Once you've worked out the code for your search plugin, save it as
pluginName.src. You can also create a 16x16 pixel PNG icon with the name
pluginName.png (be sure the plugin names match). Then save both of them to the
searchplugins folder. The typical locations of the
searchplugins folder are as follows: On Linux, they are located in /opt/MozillaFirefox/lib/searchplugins. On Windows, they are located in C:\Program Files\Mozilla Firefox\searchplugins. On Mac OS X, open the Finder, and go to Applications. Ctrl-click on Firefox, and on the menu that pops up, click "Show Package Contents," then put the plugin files in Contents/MacOS/searchplugins. You now have a customized search plugin!
As mentioned, Firefox 2.0 supports search suggestions, which appear as a user types search terms into the search bar (if the site supports it as well). This is due to a new, XML-based search plugin format called MozSearch, based on Amazon A9's OpenSearch format. The primary advantage to a MozSearch plugin is this support of search suggestions. However, since Firefox 2.0 still supports the old plugin format outlined above, and Firefox 1.x only supports the old format, developers who are not looking to add search suggestion support can create a single plugin for their site for all Firefox users using the Firefox 1.x standard. And since search suggestions require work to be done on the server side, a user creating a customized plugin for their personal use will not be able to take advantage of this feature. For those users, both formats will have the same functionality. However, developers who want to take advantage of the new search suggestion feature must adopt the MozSearch standard for their plugin. For those developers, or any others who want to implement the new standard, Mozilla provides detailed instructions on creating a MozSearch plugin and implementing search suggestions.
A better searching experience
When it comes to searching, there are many options for users who wish to enhance their browsing and research. Users who conduct the same kinds of advanced searches on a frequent basis can particularly benefit from the tools outlined in this article. With these custom search capabilities, Opera and Firefox users need look no farther than their browsers to perform advanced searches quickly and easily.
Kris Shaffer is a graduate student in music theory at Yale University and an avid open source software enthusiast. He is co-editor-in-chief of AmSteg.org, an online resource for young composers and music theorists, and he has written articles on Linux and open source software for Linux Journal, NewsForge.com, and Linux.com.