save link as anchor name
save link as anchor name
Is there a way to download what a link points to and name the downloaded file with the anchor name in the link? An example where this would be useful is a page which is a table of contents and the names on the links are sensible, but the file names in the uris are not.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0
Re: save link as anchor name
I'm thinking that may depend on the particular download manager you use.
Some may pick up "pretty" names, others can only garner the name of the URL.
(My download manager does not do "pretty".)
(I was wondering if there were any way to supply [any] name using browser built-in? As far as I can see, it only allows you to designate a directory for the files to go into.)
Some may pick up "pretty" names, others can only garner the name of the URL.
(My download manager does not do "pretty".)
(I was wondering if there were any way to supply [any] name using browser built-in? As far as I can see, it only allows you to designate a directory for the files to go into.)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball NoScript FlashGot AdblockPlus
Mozilla/5.0 (Windows NT 5.1; rv:42.0) Gecko/20100101 SeaMonkey/2.39
Re: save link as anchor name
You're right, it's certainly possible for the download manager to decide how to name the resulting files. I'll have to try looking for one that does it how I like.
I don't think that there is any way to use firefox built-in download manager out of the box to skip the prompt and name the files in this way. I've been using a custom bit of code to do it:
The problem with this code is that the new firefox extension signing disables it. I'd like to be able to use flashgot instead.
I don't think that there is any way to use firefox built-in download manager out of the box to skip the prompt and name the files in this way. I've been using a custom bit of code to do it:
Code: Select all
function SaveNamer_onSaveNamedLink()
{
// use selected text as file name if there is any
var fileName = document.commandDispatcher.focusedWindow.getSelection().toString();
// use link to name the file otherwise
if (!fileName) fileName = gContextMenu.linkText();
// remove misbehaving characters
fileName = fileName.replace(/^\s+|\/|\?|\:|\%|\&|\'|\"|\;|\!|\s+$/g, "");
//https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIFile
//https://developer.mozilla.org/en-US/docs/Code_snippets/File_I_O
var dest = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("Desk", Components.interfaces.nsIFile);
dest.append(fileName + ".html");
var aChosenData = new AutoChosen(dest,
makeURI(gContextMenu.linkURL, gContextMenu.target.ownerDocument.characterSet));
var aReferrer = makeURI(gContextMenu.target.ownerDocument.URL,
gContextMenu.target.ownerDocument.characterSet);
//toolkit/content/contentAreaUtils.js
internalSave(/*aURL*/ null, /*aDocument*/ null, /*aDefaultFileName*/ null,
/*aContentDisposition*/ null, /*aContentType*/ null,
/*aShouldBypassCache*/ true, /*aFilePickerTitleKey*/ null,
//aChosenData, aReferrer, true); return; dummy( // Iceweasel 17
aChosenData, aReferrer, /*aInitiatingDocument*/ document,
/*aSkipPrompt*/ true, /*aCacheKey*/ null);
}
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0
Re: save link as anchor name
A couple "name" Prefs, but don't know if they'll be of benefit?
> flashgot.media.forceNameHack
> flashgot.media.guessName
> flashgot.media.forceNameHack
> flashgot.media.guessName
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball NoScript FlashGot AdblockPlus
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39
Re: save link as anchor name
Actually, as far as I can tell, there's no way to pass the link text to the download manager. In the documentation https://flashgot.net/features#customdm, there's no option for passing the link text at all. So, if I write a script wrapper, I can't name the downloaded file according to this information. And I don't believe any other download manager can either. Also, I experimented by changing flashgot.media.forceNameHack and flashgot.media.guessName. And, I wasn't able to see any effect from doing that.
At this point, I don't think it is possible for the download manager to name files according to the link text.
At this point, I don't think it is possible for the download manager to name files according to the link text.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0
Re: save link as anchor name
Taking the path of least resistance, I submitted my naming extension to firefox. There's now a signed version available: https://addons.mozilla.org/en-US/firefo ... savenamer/
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0
Re: save link as anchor name
Kudos for proactivity! However, since you used XUL, your extension is already deprecated.
Want to test whether it works on other browsers (eg Seamonkey, Pale Moon) where it might have more future?
Want to test whether it works on other browsers (eg Seamonkey, Pale Moon) where it might have more future?
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.
True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.
True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0
Re: save link as anchor name
I don't understand how this is to work?
What download manager are we using, or does it matter?
What type of links, or does that matter?
What download manager are we using, or does it matter?
What type of links, or does that matter?
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball NoScript FlashGot AdblockPlus
Mozilla/5.0 (Windows NT 5.1; rv:42.0) Gecko/20100101 SeaMonkey/2.39