Last active
December 18, 2015 13:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The same without undo ability (and not only for Custom Buttons):