How to remove the file that are downloaded more than one hour

Hi, I would like to create a download file history add-on and remove the file that are downloaded more than one hour. How can I do this?

Hi there,

My advice to you depends on how experienced with WebExtensions[0]. First get familiar with the basics[1]. If you already know the basics and have built WebExtensions before, I’d check out the downloads API[2].

I’m guessing what you’d need to do is something like:

  1. get the current date and time using the JS Date API[3], then work out what is an hour before that.
  2. delete all downloads that occurred before that date/time using the erase() method[4]

Chris

[0] https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions
[1] https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions#Getting_started
[2] https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads
[3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
[4] https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/erase

where can I get the example source codes?

There are a lot of WebExtensions examples in this repo:

This one uses the downloads API: