Skip to content

Instantly share code, notes, and snippets.

@Infocatcher
Last active December 18, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Infocatcher/5787749 to your computer and use it in GitHub Desktop.
Save Infocatcher/5787749 to your computer and use it in GitHub Desktop.
Firefox: show download rate in built-in download panel, code for Custom Buttons extension https://addons.mozilla.org/addon/custom-buttons/ ("initialization" section) http://custombuttons.sf.net/forum/viewtopic.php?t=1006
// https://gist.github.com/Infocatcher/5787749
// More: https://github.com/Infocatcher/Download_Panel_Tweaker
// (c) Infocatcher 2013
function showDownloadRate(patch) {
//var {DownloadUtils} = Components.utils.import("resource://gre/modules/DownloadUtils.jsm", {});
const bakKey = "_customButtons_getDownloadStatusNoRate";
if(!patch ^ bakKey in DownloadUtils)
return;
if(patch) {
DownloadUtils[bakKey] = DownloadUtils.getDownloadStatusNoRate;
DownloadUtils.getDownloadStatusNoRate = DownloadUtils.getDownloadStatus;
}
else {
DownloadUtils.getDownloadStatusNoRate = DownloadUtils[bakKey];
delete DownloadUtils[bakKey];
}
}
function destructor(reason) {
if(reason == "update" || reason == "delete")
showDownloadRate(false);
}
if(
typeof addDestructor == "function" // Custom Buttons 0.0.5.6pre4+
&& addDestructor != ("addDestructor" in window && window.addDestructor)
)
addDestructor(destructor, this);
else
this.onDestroy = destructor;
showDownloadRate(true);
@Infocatcher
Copy link
Author

The same without undo ability (and not only for Custom Buttons):

DownloadUtils.getDownloadStatusNoRate = DownloadUtils.getDownloadStatus;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment