Add-ons using the techniques described in this document are considered a legacy technology in Firefox. Don't use these techniques to develop new add-ons. Use WebExtensions instead. If you maintain an add-on which uses the techniques described here, consider migrating it to use WebExtensions.
From Firefox 53 onwards, no new legacy add-ons will be accepted on addons.mozilla.org (AMO).
From Firefox 57 onwards, WebExtensions will be the only supported extension type, and Firefox will not load other types.
Even before Firefox 57, changes coming up in the Firefox platform will break many legacy extensions. These changes include multiprocess Firefox (e10s), sandboxing, and multiple content processes. Legacy extensions that are affected by these changes should migrate to WebExtensions if they can. See the "Compatibility Milestones" document for more.
A wiki page containing resources, migration paths, office hours, and more, is available to help developers transition to the new technologies.
This example illustrates how to customize the progress bar displayed for a given download in the Downloads window.
First you need to overlay the Downloads window so that you can add a new stylesheet. In your jar.mn file, add the following (replacing "myextension" with the name of your extension's chrome package):
% overlay chrome://mozapps/content/downloads/downloads.xul chrome://myextension/content/downloads-overlay.xul
In downloads-overlay.xul, reference the new stylesheet:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://myextension/skin/myextension.css" type="text/css"?>
<overlay id="myDownloadOverlay" xmlns="http://www.mozilla.org/keymaster/gat...re.is.only.xul">
</overlay>
In jar.mn, make sure that there is an asterisk in front of the entry for myextension.css so that it will be preprocessed. This is required since it contains platform-specific directives, as we will see.
The myextension.css file will look something like this:
richlistitem progressmeter {
%ifdef XP_WIN
min-height: 17px !important;
%else
%ifdef XP_MACOSX
-moz-appearance: none !important;
background-image: url(chrome://myextension/skin/progress_bg_osx.png) !important;
%endif
%endif
}
richlistitem .progress-bar {
%ifdef XP_WIN
-moz-appearance: none !important;
background-image: url(chrome://myextension/skin/progress_fd_win.png) !important;
%else
%ifdef XP_MACOSX
background-image: url(chrome://myextension/skin/progress_fd_osx.gif) !important;
%endif
%endif
}
This is the product of some tweaking and experimentation, so perhaps there is a different and/or better way to achieve the same thing. We are specifying the height of the progress meter on Windows and a background image on Mac. The background image (the first one in the file) should be a segment of whatever you want the unfilled portion of the progress bar to look like. An image of 7 pixels wide and 12 pixels high seems to work well. The other two images are for the filled in progress bar on Windows and Mac respectively. Once again, a height of 12 pixels or so and a few pixels wide seems about right, though you might have to experiment with this a bit.
Changing the progress bar for specific downloads
This is all you need to change the progress bar appearance for all downloads. If you want to change it for certain specific downloads only, things get a bit trickier. In your overlay file, add a JavaScript file between the <overlay> and </overlay> tags:
<script type="application/javascript" src="chrome://myextension/content/downloads-overlay.js" />
The JavaScript file will look something like this:
var MyDownloadManager = {
defaultCreateDownloadItem : null,
init : function fdm_init() {
MyDownloadManager.defaultCreateDownloadItem = window.createDownloadItem;
window.createDownloadItem = function(aAttrs) {
var dl = MyDownloadManager.defaultCreateDownloadItem(aAttrs);
if (dl) {
if (...whatever condition you use to decide whether to change this download...) {
dl.setAttribute("myspecialdownload", "true");
}
}
return dl;
}
}
};
window.addEventListener("load", function(e) { MyDownloadManager.init(); }, false);
In your CSS file, change richdownloaditem
(both occurrences) to richdownloaditem[myspecialdownload="true"]
. Now your new progress bar image will only be used for the downloads with your special attribute.