Closed candrapersada closed 2 years ago
I just wonder why? Will it be always or some rule based? It is hard to do so since my extension don't work as Aria2-Integration which prompt a new window and ask user to confirm the downloads
For temporary work around, you can
{"url": "YourDownloadURL", "options": {"out": "YourFileNameWithExtension","referer": "CurrentTabURL"}}
New
Download Window, and set Download Urls
to JSON
then paste the info into the textarea
boxSubmit
to start the downloadhow to use tab title as filename in Capture browser downloads like *page_title*.*ext*
?
In Firefox downloads API
https://github.com/jc3213/download_with_aria2/blob/9bbbcc82773896a22c6adda59148f8e59feb7904/firefox/background.js#L97
webRequest API
https://github.com/jc3213/download_with_aria2/blob/9bbbcc82773896a22c6adda59148f8e59feb7904/firefox/background.js#L84
In Chromium
https://github.com/jc3213/download_with_aria2/blob/9bbbcc82773896a22c6adda59148f8e59feb7904/chromium/background.js#L49
In Chromium Manifest V3
https://github.com/jc3213/download_with_aria2/blob/9bbbcc82773896a22c6adda59148f8e59feb7904/chromium_mv3/background.js#L39
Aria2 option out
defines download filename. so I used variable out
to do so.
To query tab title, you'd need tabs
api as https://github.com/jc3213/download_with_aria2/blob/9bbbcc82773896a22c6adda59148f8e59feb7904/firefox/background.js#L59 or https://github.com/jc3213/download_with_aria2/blob/9bbbcc82773896a22c6adda59148f8e59feb7904/chromium_mv3/background.js#L35
There will be an issue that if downloads will be start in some time (like sourceforge, in 5 seconds), and you are visiting another tab, the result tab title will be messed up as current tab title.
EDIT: I've tested that, it's easy to add an option, but you may need to turn it on/off manually for usage. It's not recommended to do so.
Take chromium branch for example, here's the changes. Firefox one needs some trick so.
You need to these steps for the codes to take effect
Extentions Manager
aria2Store['use_titlename'] = '1';
and press EnterReference based on https://github.com/jc3213/download_with_aria2/tree/76923b5e6f95249f8595aebc8c8796e0c448a7bb
chrome.contextMenus.onClicked.addListener((info, tab) => {
var {linkUrl, pageUrl} = info;
var out = aria2FileName(null, tab.title);
aria2Download(linkUrl, getHostname(pageUrl), {referer: pageUrl, out});
});
chrome.tabs.query({active: true, currentWindow: true}, ([tab]) => {
var referer = 'about:blank'.includes(referrer) ? tab.url : referrer;
var hostname = getHostname(referer);
if (getCaptureFilter(hostname, getFileExtension(filename), fileSize)) {
chrome.downloads.erase({id});
var out = aria2FileName(filename, tab.title);
aria2Download(finalUrl, hostname, {referer, out: filename});
}
});
function aria2FileName(filename, title) {
if (aria2Store['use_titlename'] === '1') {
if (filename) {
var ext = getFileExtension(filename);
return title + '.' + ext;
}
return title;
}
return filename;
}
You need to these steps for the codes to take effect
is there any option or button to use it right away without needing these steps?
I won't implement this into the main branch, since it's kind of conflict with my code. It's better that you switch to Aria2-Integration and ask the developer to implement this feature.
will there be an option for how to download use tab title as filename?