Top 10 Hacks

Friday, August 04, 2006

Top 10 Firefox hacks!

1. How to Play Games Using Mozilla Forefox

Do you now that you can play simple games with Firefox? The Card Games extension provides dozens of single-person card games, most of them are solitaires.

It's also possible to play simple 2 1/2 D console games from the 80s and 90s. Dynamic HTML (and Dynamic XUL) provide a fast enough basis for the required sprites. To play these games, you don't even need an extension. Just visit the MozDev Games web page (http://games.mozdev.org). You can run the games online by clicking their links, or you can download the games pages to your laptop and open them whenever you want.

2. How to Get More Search Tools

By default, the Search box queries the Google search engine. You can tell this from the small G icon that appears on the left side of the box. If you click on that icon, however, you'll see a list of several other available engines, such as Yahoo!, Dictionary.com, and Amazon.com. You can change which search engine is used. Just select a different engine from this list before hitting Return to launch your query.

If the site you want to query isn't listed, you'll want to visit the Mycroft extension site at http://mycroft.mozdev.org.

Mycroft is a project dedicated to collecting a wide variety of search plug-ins for Mozilla-based browsers. You can find plug-ins for hundreds of sites, from A9.com to Zoek.nl. If you're looking to add a specific site to your Search bar, you can query the site name using the search option on the main page, or you can browse the list of submitted engines by category. Once you find the site you want, just click on the name and Firefox will add it to your list automatically.

3. How to Speed up Network Access

The following preferences might not make you a good web citizen, but they'll get you as much bandwidth as you can manage. Note, however, that too many simultaneous network connections will just slow you down. The best possible performance occurs when there's one connection only and the remote web server is blindingly fast. If web servers or other hops in the network are comparatively slow, try playing with these many preferences.

Turn the following preferences on for dial-up; they produce little effect for broadband connections. A few web pages that don't support HTTP/1.1 will be confused, but all modern web sites should handle it fine:

network.http.pipelining                 /* default = false */
network.http.proxy.pipelining           /* default = false */


Raise the following for dial-up only. It states how many pipelined requests are possible (has a minor effect only):

network.http.pipelining.maxrequests     /* default = 4 */


Set the following higher if you want to hammer web servers with many simultaneous requests (suitable for broadband use only):

network.http.max-connections-per-server /* default = 8 */


Set the following higher if you want to keep an unfair share of web servers that you access a lot. The web server must also be too dumb to deny your request for extra access:

network.http.max-persistent-connections-per-server /* default = 2 */


Set the following higher if you want an unfair share of web proxies that you access a lot. The web proxy must also be too dumb to deny your request for extra access:

network.http.max-persistent-connections-per-proxy /* default = 4 */


Set the following higher if you keep millions of tabs and/or windows open (suitable for broadband use only).

network.http.max-connections /* default = 24 */

4. How to Speed up page display

To display pages faster, you first need a fast CPU and memory. Don't try the following things on an ancient Pentium II, unless specifically noted here.

Setting the following preference to false is a brutal performance tweak that tells Firefox to process every byte of Web content as soon as it arrives, rather that buffering it in sensible chunks. This makes Firefox web-page handling work extremely hard but theoretically puts page content on the screen faster (recommended only for burning-hot CPUs with super-fast display cards and dial-up connections):

content.notify.ontimer /* default = true */


An even more brutal tweak shuts out all interruptions (including user input) while the incoming web page content is analyzed (not recommended at all unless Firefox is being used as an untended monitoring station):

content.interrupt.parsing /* default = true */


If content.notify.ontimer sensibly remains false, this is the time-out interval for collecting sensible chunks of incoming web page. Lower it for faster incremental page display. Lower it below 10000, and web-page handling will be working extremely hard again (recommended for dial-up):

content.notify.interval /* default = 120000 (micro-seconds) */


For Granny's slow computer, if nothing's arrived recently, then do extra buffering, which saves more CPU cycles. Set to the number of milliseconds to back off each time the network connection is found to be idle (recommended for ancient PCs on dial-up only):

content.notify.backoffcount /* default = -1, meaning never */


Make Firefox pay more attention to the mouse and keyboard at the expense of other activities. Making this a larger polling delay slows down recognition of user input but marginally improves page display:

content.max.tokenizing.time /* default = 360000 (micro-seconds) */


If the user is in the habit of opening 10 web pages (especially 10 tabs) and then sipping coffee while the pages load, making the following parameter's value larger will speed up page display (recommended for slow CPUs):

content.switch.threshold /* default = 750000 (micro-seconds) */


Make a big memory buffer for big pages. Set to a power of 2 minus 1e.g., 16385 (recommended for broadband):

content.maxtextrun /* default = 8191 */


Here are a couple of additional oddments. The following preference tells Firefox to start putting received web pages on the screen right away, even if not much content has been received yet:

nglayout.initialpaint.delay /* set to 0, default = 250 (millisecs) */


The following preference tells Firefox not to bother putting image placeholders on the screen while the real images are fetched, which will also speed page display up a bit (recommended for broadband):

browser.display.show_image_placeholders /* default = true , set to false */


Finally, on Linux/Unix, don't run Firefox with X-servers and X-clients on different machines; that can be quite slow. VNC (or PC-Anywhere, or Windows Remote Desktop) does not affect Firefox performance, except for capping the speed at which desktop updates occur. That is not a Firefox-specific effect, though.

5. How to Inspect the HTTP Information

First of all, install The Live HTTP Headers extension. After that you can see requests and response headers in separate window

6. How to Add Translation Tools to Your Menus

While web page translation systems are still in their infancy, sometimes reading a page translated 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 language to any of 12 others, including French, Italian, Russian, Korean, Japanese, Chinese, and more. More info about The Translate extension.

7. How to Create a Portable Profile

If you’re using Firefox on two or more computers, you might want to maintain the same bookmarks and preferences on both machines. A portable profile lets you take your most important settings with you but keeps things small and simple, so it will work on any Firefox installation. Bear in mind that a portable profile should be easy to move around, so don’t plan to use extensions or themes in this configuration.

  1. Start Firefox with the Profile Manager. Create a new profile named Portable. Change the directory name to PortableProfile.
  2. Firefox will start with the new, blank profile. Close Firefox.
  3. Copy these files from your regular profile to the PortableProfile folder, overwriting the existing copies: bookmarks.html, prefs.js, cookies.txt, chrome/userChrome.css (if present in your profile), chrome/userContent.css (if present in your profile)
  4. Start Firefox again and the Portable profile should be in use. Your bookmarks existing preferences will be in place, but you won’t have any of your extensions.
  5. Under Tools - Options - Privacy, change the size of the disk cache from 50,000 to a much smaller number, such as 5000. Because you’ll be moving this profile around, the disk cache should not be allowed to grow to 50 MB. Close Firefox.
  6. Copy this PortableProfile folder to a USB key, a floppy disk, or other removable medium.
  7. On another machine with Firefox installed, plug in your USB key or copy the profile to the hard drive. Access the profile by starting Firefox with the -profile switch, like so: “c:\Program Files\Mozilla Firefox\firefox.exe” -profile X:\PortableProfile X: is the drive letter where the profile directory is located. You can make sure that Firefox is using the portable profile by checking the directory for the parent.lock file.

8. How to Change Disk Cache Location

Modifying the location of the disk cache can have a side benefit of freeing up space without having to repartition or remap directories at the operating-system level. The best benefit, though, comes if you happen to have two physical hard drives installed. In my experience, moving a system’s paging file and Firefox’s disk cache to a secondary drive helps performance by balancing disk reads and writes across both drives.

First of all, clear your cache directory!

By default, newer computers come with one hard drive and one partition. This, coupled with the fact that newer hard drives are very fast, means that this hack is not a top priority for very fast computers. If you are on an older system with a second hard drive or would like to repoint the disk cache to a RAM drive, this tweak is for you. Here’s how to modify this setting:

// Sample for Windows Users
user_pref(“browser.cache.disk.parent_directory”, “d:\\temp\\”);
// Sample for Unix/Linux/Mac Users
user_pref(“browser.cache.disk.parent_directory”, “/tmp”);

If the path you have chosen does not exist, Firefox creates it the next time you open it up. Windows users should make sure that this value has double slashes, as displayed in the preceding code; not including these causes internal parsing errors and possible preference-file corruption. The only exception to this rule is if you are adding this value via the about:config screen, in which case, you should not use the double slashes — single slashes will automatically get converted to double.

9. How to Hide Menu options

Power users are always concerned about desktop real estate. Personally, I do a lot of ridiculous things to squeeze in an extra row here or there, including using autohide with the task bar in Windows. Generally, this is more difficult to do at the application level. Some applications do allow the user to hide a status bar or title bar, or sometimes even all the menus, but generally they allow very little customization. The userChrome.css file, however, does enable us to remove specific menu items.

As the stereotypical guy, the first thing that I will remove using the userChrome file is the Help menu. This is probably a safe choice for you too, as readers of Hacking Firefox are the type who should be resourceful enough to find help on the Internet. If the userChrome.css file does not yet exist, it needs to be created in the profiles/chrome directory. The code for removing the Help menu is straightforward:

menu[label=”Help”] {display: none !important; }

The same procedure can be done for every other menu item simply by replacing Help with the appropriate menu item. Removing multiple menu items at once can be done in one of two ways. You can duplicate the Help removal code and change the menu item specified in label, or you can expand upon the CSS statement a little bit more and keep the code a bit cleaner. The following will remove both the Edit and the Help menu:

menu[label=”Edit”],menu[label=”Help”] {display: none !important; }


The keyword menu removes the entire tree specified, and sometimes this functionality may not be desired. Submenu items can also be removed using the same technique, but with menuitem as the keyword instead of menu. One of the menu items that I have little use for is Reload, as I always use the keyboard shortcut, so I will remove it along with the Help and Edit menus.

menuitem[label=”Reload”], menu[label=”Edit”],menu[label=”Help”] {display: none !important;}

10. How to Hack Tabs Using userChrome.css

You’ve already seen the power of modifying the userChrome.css file to alter the appearance of other Firefox elements. Now the focus is on what you can do with the look and feel of tabs.

By adding code to the userChrome.css file, you can move the tab bar to the left, right, or bottom of the browser window. For example, to put the tab bar at the bottom of your Firefox window, add this line to your userChrome.css file:

#content > tabbox { -moz-box-direction: reverse; }

Restart Firefox and your tab bar appears at the bottom of the screen

Firefox provides a default busy icon for tabs that are loading pages, but you might want to give yourself a clearer indication of what’s going on with your tabs.To change the colors of normal, active, and loading tabs, add these lines of code to your userChrome.css file:

/* Change Tab Colors */
/* Change color of active tab */
tab[selected=”true”] {background-color: rgb(222,218,210) !important; color: black !important;}
/* Change color of normal tabs */
tab {background-color: rgb(200,196,188) !important; color: gray !important;}
/* Tab while loading */
tab[busy] {color:gray !important;}

If  you use Mozilla Firefox like I do, I advise you read Firefox Hacks
By Nigel McFarlane
(O'Reilly) and Hacking Firefox by Mel Reyes (Wiley Publishing, Inc.)