202
Part IV — Hacking Navigation, Downloads, and Searching
Optionally, you can modify them using the about:config functionality built into Firefox.
Table 11-1 Customizing the Download Manager Settings
Preference Name Description Value
browser. download. manager. Use this to close the Download Manager window true/false
closeWhenDone when it finishes downloading.
browser. download. manager. Use this to focus the Download Manager window true/false
focusWhenStarting when a download starts.
browser. download. manager. This is the number of milliseconds that Firefox integer
openDelay waits before displaying the Download Manager.
Setting this to 2000 will have it wait 2 seconds
before opening the manager window. This is useful
if you are downloading a bunch of small files and
do not want the Download Manager to keep
popping up.
browser. download. manager. Use this to enable/disable the download complete true/false
showAlertOnComplete alert window that pops up on the bottom-right side
of the browser.
To change a preference back to the default, just remove the entry from the user.js file, if it exists;
then open about:config, select the preference, right-click, and select the Reset option from the
context menu. This will set the value back to the default value.
Hacking Downloads with Extensions
Hacking the download experience with extensions is the most useful way to personalize down-
loading, whether it is showing the download status in the status bar, tab, or in the sidebar.
Additionally, eliminating annoying situations such as blank new windows on file downloads
and sorting downloads into different directories based on their file extension can really come in
handy. This section covers them all and what options work best with each.
Showing Downloads in the Status Bar Using the
Download Statusbar Extension
One of the most useful extensions that I have found to minimize the impact of downloading
files, while maintaining a keen eye on progress and download throughput, is the Download
Statusbar extension. While the title might imply that the default status bar is modified, in real-
ity, what it does is build a custom download status bar that it places temporarily above the offi-
cial status bar area extension, as shown in Figure 11-7.
17_596500 ch11.qxd 6/30/05 3:01 PM Page 202
203
Chapter 11 — Download and Plugin Hacks
To maximize Download Statusbar’s effectiveness, disable Firefox’s built-in Download Manager
window from popping up. Do this in the Downloads section of the Tools➪ Options menu.
F
IGURE
11-7: Download Statusbar extension, with Firefox download complete and Thunderbird
download paused
When Download Statusbar is in action, you will see a new bar open up above the status bar
with the progress and information about each of the current downloads. To pause a download,
left-click it and then click it again to resume. A red band appears around paused downloads.
Additionally, right-clicking a download shows a context menu with different options based on
active, paused, or completed downloads. Figure 11-8 displays the different configuration
options available with this extension.
For more information about the Download Statusbar extension, visit http://
downloadstatusbar.mozdev.org/.
17_596500 ch11.qxd 6/30/05 3:01 PM Page 203
204
Part IV — Hacking Navigation, Downloads, and Searching
F
IGURE
11-8: Download Statusbar extension options window
Showing Download Manager in the Sidebar or Tab
with Download Manager Tweak Extension
On the surface, this extension appears to be a cute overlay to the internal Downloads Manger,
as shown in Figure 11-9, but when you dig into the options, you’ll find that there are a few
other interesting tweaks and possible hacks that you can apply. Nice hidden features include
the following:
Ⅲ Specify Download Manger window open delay.
Ⅲ Specify buttons to show in the Download Manager window.
Ⅲ Move the toolbar in the window and other minor tweaks.
Another nice customization is placement of the Download Manager — whether you want it in
a new window, in the sidebar, or in a tab.The basic features fit the extension’s name aptly but
don’t do it justice with respect to what it really provides.
There are three ways to get to the Download Manager Tweak options and settings. You can:
Ⅲ open the Extension Manger and double-click on the extension’s entry on the list.
Ⅲ click the Options button on the Download Manger’s toolbar.
Ⅲ access it via the Tools ➪ Options menu in the Downloads section by clicking the
Download Manager Tweak Options button there.
17_596500 ch11.qxd 6/30/05 3:01 PM Page 204
205
Chapter 11 — Download and Plugin Hacks
Figure 11-10 displays the options available for this extension.
F
IGURE
11-9: Download Manager Tweak customized version
of the Download Manager
F
IGURE
11-10: Download Manager Tweak options and settings
For more information on the Download Manger Tweak extension, visit http://
dmextension.mozdev.org/.
17_596500 ch11.qxd 6/30/05 3:01 PM Page 205
206
Part IV — Hacking Navigation, Downloads, and Searching
Disabling Blank Download Windows with the
Disable Targets for Downloads Extension
One of the most annoying things about downloading files off the Internet is the insistence of
web masters, HTML coders, and automated download sites on adding a target field to a file’s
download link. You have probably seen this — for example, you click to download myhack.zip,
and when you do, a new blank window opens and then download begins, leaving behind the
blank window after the file has completed. As mentioned on this extension’s web site, this issue
has been officially filed as Bug #241972, which can be found here:
https://bugzilla
.mozilla.org/show_bug.cgi?id=241972
. Most users would like a resolution sooner
rather than later, and that is where the Disable Targets for Downloads extension comes in.
This extension removes targets only from active hyperlinks, not those wrapped in JavaScript
code, and so on.
A normal link may look like this (shameless plug):
<a href=” />Here</a>
But a link with a target will look similar to the following:
<a href=” />target=”_blank”>Download Here</a>
This extension disables the link’s additional target property so the browser handles the link
normally and opens it in the current window.
By default, this extension disables new windows for links with targets for the following file-
name extensions: .zip, .rar, .exe, tar, .jar, .xpi, .gzip, .gz, .ace, and .bin.
While this extension covers the majority of common filename extensions, I tend to add a few
more potential culprits, including .7z, .cab, .msi, and .pdf.
Figure 11-11 shows the Disable Targets for Downloads Options window.
For more information or updates for the Disable Targets for Downloads extension, visit
/>17_596500 ch11.qxd 6/30/05 3:01 PM Page 206
207
Chapter 11 — Download and Plugin Hacks
F
IGURE
11-11: Disable Targets for Downloads Options window
Follow these steps to add additional filename extensions to the list for target disabling:
1.
Install the Disable Targets for Downloads extension.
2.
Restart your browser to finish the installation process.
3.
Select the Extensions option from the main browser’s Tools menu.
4.
Locate and double-click the Disable Targets for Downloads entry on the list.
5.
For each filename extension desired, type the filename’s extension and click the
Add button.
6.
Click OK when you’re done, and your settings are ready for use.
While most extensions are three letters, this is not a steadfast rule for all operating systems and
applications, as you see with the .7z, .gz, and .gzip filename extensions.
Another real bonus of this extension is its ability to use regular expression pattern matching to
remove the blank target windows for links matching the regular expression. Because the exten-
sion relies on regular expression pattern matching, this means that you are not restricted to just
filename extensions. One example on this extension’s site is to add the following entry, which
removes the blank window opened by downloading a file in Gmail:
/gmail\?view=att/
17_596500 ch11.qxd 6/30/05 3:01 PM Page 207
208
Part IV — Hacking Navigation, Downloads, and Searching
Additionally, some sites open up just one too many tabs or windows when you are navigating
from section to section, and although they are not necessarily blank, they are annoying. Some
sites that I hack with this extension are
and http://
www.versiontracker.com/
. While these sites have great content and are updated fre-
quently, they are annoying when they open two, three, or more windows. To alleviate this on
the KLite Tools site, I have pinpointed the most common URL snippet to match on to remove
these target windows, which is as follows:
klitetools.com/comments.php
Or enter just the root domain to eliminate all targeted links for the Version Tracker site:
versiontracker.com
Using these will successfully remove the target window for the specified page or the entire site.
Sorting Downloads to Directories with the Download Sort
Extension
Once you have the Download Sort extension installed, you can begin a life of organized down-
loading. This extension allows you to add filename extensions or keywords to monitor and save
files that match to the desired directory. As shown in Figure 11-12, the settings window for
this extension allows full customization of each file extension, as well as the use of keywords in
filenames.
F
IGURE
11-12: Main configuration settings for Download Sort
17_596500 ch11.qxd 6/30/05 3:01 PM Page 208
209
Chapter 11 — Download and Plugin Hacks
To open the settings window, open the Extensions Manager and double-click on the
Download Sort entry listed. After entering or modifying an entry, make sure to click the
Apply/Update button, and your settings will be saved.
For more information on the Download Sort extension, visit http://downloadstatusbar
.mozdev.org/downsort/.
Hacking MIME Types
One of the key pieces of information that is communicated between a web server and a
browser is a file’s content type or MIME type. Multipurpose Internet Mail Extensions
(MIME) were originally implemented for use with e-mails and aides in defining a header of
information for nontext e-mail attachments. This standard was extended to the Web to define
the format of incoming objects that are requested. This section covers how to sniff out the
MIME type being sent by a server, as well as how to modify Firefox’s behavior for these
MIME types.
Understanding File MIME Types
The easiest way to explain MIME type is by using an example such as downloading an exe-
cutable from a site. Most web servers will associate a Windows executable or .exe extension
with a default MIME type of “application/octet-stream” or “application/exe.” When the web
server initiates the transfer back to the browser, it includes this information in the initial com-
munication header and lets the browser handle the information as it sees fit. A typical prompt
that Firefox would display after receiving this information is shown in Figure 11-13.
F
IGURE
11-13: Default download confirmation window
17_596500 ch11.qxd 6/30/05 3:01 PM Page 209
210
Part IV — Hacking Navigation, Downloads, and Searching
As Figure 11-13 also shows, some prompts do not always have all available options enabled.
Furthermore, some web servers spoof the MIME type to force downloading of files. Solutions
and alternatives to each of these situations are covered in the following sections.
Using the Mimetype Editor and LiveHTTPHeaders Extensions
After the headaches caused by trying to figure out what the best MIME type handling setting
are, I resorted to recommending a two-extension approach to dissecting the response headers
and hacking MIME types from a web server.
The approach that has worked for me is to install both the LiveHTTPHeaders and Mimetype
Editor extensions and to use the first to sniff out the MIME type or Content-Type and then
add it using the editor. The best part of these extensions is that they are tucked away in the
Tools menu until you are ready to use them; they do not add any visually obnoxious elements.
Using the LiveHTTPHeaders extension to detect the custom MIME type is a snap. The
whole process of detecting the Content-Type may seem a bit overwhelming, but after your first
run, you should have the hang of things. My approach is to do the following:
1.
Navigate directly to the page that contains the offending MIME type download issue.
2.
Launch the Live HTTP Headers tool from the Tools menu.
3.
Switch back to the download page.
4.
Click on the download link in question and then save or cancel the download.
5.
Switch back to the Live HTTP Header window.
At this point, the window contains the header communication that was exchanged between the
server and the browser. The entry to look for is the Content-Type, which is highlighted in
Figure 11-14.
You can right-click and copy any of the individual lines presented. To copy multiple lines, you can
click on the first entry, hold down the Shift key, and click the last entry desired; then release the
Shift key, right-click the highlighted block, and choose Copy from the context menu.
For more information on the LiveHTTPHeaders extension, visit http://livehttpheaders
.mozdev.org/.
Once you have the Content-Type text, you can open the Mimetype Editor tool from Tool ➪
Mimetypes, shown in Figure 11-15, to add the type and the default action that you would like
to associate with this type.
17_596500 ch11.qxd 6/30/05 3:02 PM Page 210
211
Chapter 11 — Download and Plugin Hacks
F
IGURE
11-14: LiveHTTPHeaders extension capture window
F
IGURE
11-15: Mimetype Editor options window
17_596500 ch11.qxd 6/30/05 3:02 PM Page 211