downthemall / downthemall-legacy

Official DownThemAll! repository. Pull requests welcome.
https://downthemall.org/
Other
517 stars 150 forks source link

Feature Request: Add download url to Firefox history #89

Open gaberad opened 8 years ago

gaberad commented 8 years ago

DTA 3.0.6, Firefox 48.0.2, Win 10

Expected Behavior

When queuing a download (or maybe when the download has finished), add the url to Firefox history. Maybe have it as an option in settings?

The primary reason for this request is so css styles will be applied to a:visited links, so I can see which files have already been downloaded.

Actual Behavior

Currently doesn't add url to firefox history.

BonzoDog1921 commented 8 years ago

To me this is an essential enhancement that would be very much appreciated. It's not at all unusual for the need to arise to want to get back to the original url from where a file was downloaded and in both Firefox and Palemoon it can be a bit of a nightmare and very time consuming.

gaberad commented 8 years ago

So I was playing around with this functionality, got it working like this in 3.0.8:

In modules > glue.jsm I added the following after the other dlsg lines (line ~216):

dlsg("asyncHistory", "@mozilla.org/browser/history;1", "mozIAsyncHistory");

In chrome > content > dta > manager > manager.js I added the following after the 'save' & before the 'remove' functions in QueueItem.prototype (line ~1788):

_addToHistory: function () {
        Services.asyncHistory.updatePlaces({
            uri: Services.io.newURI(this, null, null),
            visits: [{
                visitDate: Date.now() * 1000,
                transitionType: 1
            }]
        });
    }, 

I also modified the 'save' function to have 'this._addToHistory();' before the final 'return true;' (line ~1784):

    save: function() {
        ...
        this.dbId = QueueStore.queueDownload(JSON.stringify(this), this.position);
        this._addToHistory();
        return true;
    },

Not sure if that's the best place to add the url to history, but it might be starting point for you.