17_596500 ch11.qxd 6/30/05 3:02 PM Page 222 Search Hacks A web browser is an information-gathering tool. Sometimes you know where you need to go, so you use bookmarks and familiar links, but eventually you’ll need to search the Web to look up new sites and sources of information. Firefox includes some excellent search tools and makes it easy for you to modify the browser to suit your search habits. And some nifty tricks can speed up your searches and help you find what you need right away. Adjusting the Default Google Search A fresh install of Firefox uses Google for all searches, whether from the location bar or the search box in the upper-right corner. If you enter your search terms in the location bar, Firefox checks with Google and then takes you to the top search result site. In other words, it’s the same as if you searched from http://www.google.com and clicked the I’m Feeling Lucky button. The search box in the upper-right corner behaves a little differently. When you enter your search terms there, Firefox treats it like a normal Google search and shows you a web page with all of the results. If you prefer to see all of your search results but like performing your searches from the location bar, you can adjust Firefox’s default Google search through about:config. From the about:config list, type keyword to filter out all but the two items related to keyword searches. You should see these two items: keyword.URL keyword.enabled Leave the second one alone and focus on the URL setting. By default, it should look like this: Keyword.URL default string http://www.google.com/search?btnI=I%27m+Feeling+ Lucky&ie=UTF-8&oe=UTF-8&q= Notice the words I’m Feeling Lucky in the URL? That setting tells Firefox to submit the search to Google and return the same result as if you’d clicked that button on their site. To adjust it so that a location bar search shows you all the results from Google, double-click on the item and change the URL to look like this instead: http://www.google.com/search?&ie=UTF-8&q= ˛ Customize searches with Google ˛ Add search tools to context menus ˛ Search within pages using Find-As-You- Type ˛ Add toolbars to your browser to increase your searching power chapter in this chapter by Phil Catelinet 18_596500 ch12.qxd 6/30/05 3:03 PM Page 223 224 Part IV — Hacking Navigation, Downloads, and Searching Normally, changes you make to about:config take effect right away. However, because of a bug in Firefox (as of version 1.0.3), you’ll need to restart Firefox for this particular change to take effect. After you restart Firefox, try a search from the location bar again. It should show you all of the search results this time. Using Quick Searches Firefox also lets you search different sites from the location bar by putting a letter or keyword in front of the search terms. These searches are in the default bookmarks under the Quick Searches folder. For example, to search for the definition of politics at Dictionary.com, type dict politics in the location bar and press Enter. Firefox takes you to Dictionary.com, display- ing the results of your search. You can add your own location bar searches to Firefox using any site with a search function. Here’s how to add a Microsoft.com option to your browser. 1. Go to http://www.microsoft.com. 2. Locate the search box in the web page. 3. Right-click in the search box on the web page and select “Add a Keyword for this Search. . .” 4. An Add Bookmark popup window appears (see Figure 12-1). Fill in a name for your search and type a keyword (such as ms) in the Keyword field. You might want to prepend the keyword to the name of your bookmark so when you look in the Quick Searches bookmarks folder you don’t need to check the properties of each bookmark to remember the keyword. 5. Select a folder for the bookmark. Click OK. You can put a Quick Search bookmark anywhere, but I suggest keeping them in the Quick Searches folder so you can find them later. F IGURE 12-1: Adding a Quick Search to your bookmarks. 18_596500 ch12.qxd 6/30/05 3:03 PM Page 224 225 Chapter 12 — Search Hacks Now go back to your location bar.Type ms windows bsod and press Enter. Firefox searches Microsoft’s web site using the terms “windows bsod” and shows you the results just as if you’d browsed to microsoft.com and used their search box. Hacking the Search Box The real power of searching with Firefox is in the built-in search box in the browser’s upper- right corner. While Google is the default search engine, Firefox comes with several other search plugins in a fresh install: Yahoo!, Amazon.com, eBay, and others. To choose a different search plugin for a particular search, click on the icon in the window and select an engine from the drop-down list, as shown in Figure 12-2. F IGURE 12-2: Firefox’s built-in search engine options. You can add new search engines to the list by clicking on the Add Engines link. You’ll see a few popular search sites linked there; click on any of them and you’ll be prompted to confirm the plugin installation. The new engine appears as a drop-down option immediately. 18_596500 ch12.qxd 6/30/05 3:03 PM Page 225 226 Part IV — Hacking Navigation, Downloads, and Searching One of the best sites to find a wide variety of search engine plugins is Mycroft at http:// mycroft.mozdev.org . Mycroft lists plugins by category and provides a search box for you to look up those hard-to-find sites that defy categorization. When you find the search plugin you want, just click on it and it will be added to your Firefox search box drop-down list. Firefox remembers the last search engine you used, so if you use the Yahoo! plugin then close and reopen the browser, Yahoo! will still be the selected search engine. To remove a search plugin, browse to the searchplugins folder and delete the SRC and GIF files for the plugin, then restart Firefox. Search plugins consist of two files: Ⅲ An SRC file that contains the code telling Firefox how to use search terms for that site. Ⅲ A GIF file that provides the icon for the search box. These files are kept in the searchplugins subfolder of your Firefox installation directory (not your Firefox user profile directory). If you uninstall and reinstall Firefox, you will lose any plug- ins you downloaded from Mycroft or other sites. The typical plugin SRC file has two or three sections, as shown in the following code example from Firefox’s built-in Amazon.com search plugin: # Search Plug-in for Amazon.com (http://www.amazon.com) # by Paul Millar <dazzle@edazzle.net> created: 18 January 2003 # updated by Rafael Ebron <rebron@meer.net> <SEARCH version = “7.1” name=”Amazon.com” description=”Amazon.com Search” method=”GET” action=”http://www.amazon.com/exec/obidos/external-search/” > <input name=”field-keywords” user> <input name=”mode” value=”blended”> <input name=”tag” value=”mozilla-20”> <input name=”sourceid” value=”Mozilla-search”> </search> <BROWSER update=”http://www.mozilla.org/products/firefox/plugins/amazondotcom.src” updateIcon=”http://www.mozilla.org/products/firefox/plugins/amazondotcom.png” updateCheckDays=”3” > 18_596500 ch12.qxd 6/30/05 3:03 PM Page 226 227 Chapter 12 — Search Hacks The SEARCH section defines the plugin and tells Firefox what site will be used for the search. The version number is the highest version of Netscape (not Firefox) with which the plugin has been tested. It’s irrelevant for our purposes. The input tag with the word user tells the browser the actual user-entered search request. The BROWSER section gives Firefox a way to automatically update the plugin if the site’s search system changes and if the plugin author uploads a new version to the Mozilla site. Some plugins also include an INTERPRET section between SEARCH and BROWSER that tells Firefox how to display the results it receives from the site. Mycroft includes a detailed tutorial on plugin design; you can find it at http://mycroft .mozdev.org/deepdocs/quickstart.html. Searching from the Web Page Itself Admit it: sometimes you’re lazy. When surfing you’ll come across a word or phrase that you’d search the Web for if only that search box wasn’t at the top of the screen. Now you don’t have to type your search queries anymore. There are several search extensions available that let you right-click on terms in your web page and search the Web for those terms — no typing required. Web Searches Using the Context Menu Using the Context Search extension, you can add a search option to the right-click menu in a web page. After you install the extension, highlight a word or phrase, then right-click and select “Search Web for [your word or phrase will appear here].” Not only can you search the Web for the term, but you can also search using any of your installed search plugins. You can see Context Search in action in Figure 12-3. If your web page has a reference to George Washington and you want to see what books Amazon.com sells about him, just highlight George Washington, right-click on the selection, and choose Amazon.com from the search engine list. The results will appear in a new tab or window, depending on how you’ve config- ured those options. You can get Context Search from http://www.cusser.net/extensions/ contextsearch/. Define Words in Web Pages I love using Dictionary.com to find definitions and synonyms, but sometimes it’s a chore to go to the site and search, or even to use the Quick Search option with “dict [my word here]” in the location bar. You can get several extensions that add dictionary searches to your context menu, and two of them are covered here: DictionarySearch and DICT Search. Despite the similar names, they look up words in different ways. 18_596500 ch12.qxd 6/30/05 3:03 PM Page 227 228 Part IV — Hacking Navigation, Downloads, and Searching F IGURE 12-3: Context Search brings your search plugins right to the web page. DictionarySearch adds a simple context menu option when you right-click on a highlighted word. Selecting “Dictionary search for [highlighted word]” brings up a new tab or window with the results from Dictionary.com. You can add other online dictionaries to the context menu from the extension’s options window, shown in Figure 12-4. F IGURE 12-4: User options for the DictionarySearch extension. 18_596500 ch12.qxd 6/30/05 3:03 PM Page 228 229 Chapter 12 — Search Hacks You can find the DictionarySearch extension at http://dictionarysearch.mozdev .org/. DICT Search looks up words in online dictionaries using the DICT network protocol. Instead of searching for words in online versions of commercial dictionaries such as Merriam-Webster, DICT Search looks in user-maintained public dictionaries and online databases. Because it uses sites such as the Jargon File ( jargon.org) and the Virtual Entity of Relevant Acronyms, DICT Search is particularly well suited for technical and computer terms. The method is the same as with DictionarySearch: highlight the word you want to define, then right-click and select Define [word]. The extension displays its results in a special popup window, which you can see in Figure 12-5. F IGURE 12-5: DICT Search results appear in a new window. Get DICT Search at http://dict.mozdev.org. 18_596500 ch12.qxd 6/30/05 3:03 PM Page 229 230 Part IV — Hacking Navigation, Downloads, and Searching Add Translation Tools to Your Menus While web page translation systems are still in their infancy, sometimes reading a page trans- lated by a computer from a foreign language to your own is better than not being able to read the page at all. Firefox doesn’t come with any built-in translation offerings, but you can add your own easily via the Translate extension. It adds a Translate function to Firefox’s Options menu and the web page context menu. The former translates an entire web page to English, while the latter will translate highlighted text and present the results in a new tab or window. Translate uses Altavista’s Babelfish translation engine. If you’d prefer to translate pages from English to another language, Translate’s Options window lets you change your preferred lan- guage to any of 12 others, including French, Italian, Russian, Korean, Japanese, Chinese, and more (see Figure 12-6). F IGURE 12-6: Translate’s list of available languages. The Translate extension is available at https://addons.update.mozilla.org/ extensions/moreinfo.php?id=181. Put Your Search Results in a Sidebar The sidebar is a feature of the Mozilla suite that lets you keep your bookmarks, history, search tools, and other functions on the side of your browser window. Firefox’s sidebar functions are initially limited to just bookmarks, downloads, and history, but you can add new tools to the sidebar via extensions. One such tool is SearchStation, which gives you search and translator options. 18_596500 ch12.qxd 6/30/05 3:03 PM Page 230 231 Chapter 12 — Search Hacks SearchStation’s web search sidebar performs web searches but keeps the results in the sidebar. That way you can refer back to them without having to switch away from your current web page. Figure 12-7 shows a Google search using SearchStation. When you click on a result, the page loads in the active tab in the same browser window. SearchStation uses your search plug- ins, so you can search Yahoo!, eBay, Amazon.com, and any other sites using plugins you’ve installed. F IGURE 12-7: Searching Google with the SearchStation extension. The Translator sidebar is like a miniature version of the Babelfish or Google translator sites. It translates text you type or cut and paste into the space provided, but not entire web pages. (You’ll need the Translate extension I discussed earlier to do that.) You can choose among 15 languages (including English) to translate text in either direction, and you have three to five different translation engines at your disposal (depending on the languages you’ve selected — not all translation sites handle all 15 languages). You can see an example of the Translator fea- ture in Figure 12-8. You can get SearchStation from http://members.lycos.co.uk/toolbarpalette/ searchstation/index_en.html. 18_596500 ch12.qxd 6/30/05 3:03 PM Page 231 . pages using Find-As-You- Type ˛ Add toolbars to your browser to increase your searching power chapter in this chapter by Phil Catelinet 18_596500 ch12.qxd 6/30/05 3:03 PM Page 223 224 Part IV — Hacking. different search plugin for a particular search, click on the icon in the window and select an engine from the drop-down list, as shown in Figure 1 2-2 . F IGURE 1 2-2 : Firefox s built-in search engine options. You. search box. Hacking the Search Box The real power of searching with Firefox is in the built-in search box in the browser’s upper- right corner. While Google is the default search engine, Firefox