0

I'm trying to make a greasemonkey user script that will pop up the browser's/OS's "save as dialogue" for a certain file.

So the desired result would be:

var link = 'http://www.example.com/example.jpeg'; //or .zip or .doc or whatever

popout link(link); //This should make the specified link be available in the "save as dialogue"

I have tried the following code, which i found here:

var link = 'http://www.example.com/example.jpeg';

var clickEvent      = document.createEvent ('MouseEvents');     
clickEvent.initEvent ('click', true, true);

link.dispatchEvent(clickEvent);

But unfortunatly that didn't work. And i can't find an answer anywhere on the web, and i've searched for hours :(.

It's also okay if Greasemonkey would save the files to a folder without asking first, but that isn't possible as i've read everywhere. So a diologue window is still an acceptable solution, that way the user only has to click "OK" whith each file.

I know it's also possible to push to a server and let the server download the files given, but i'm not looking for such a solution.

EDIT: Also found an adaption of greasemonkey that does have a savelocally api/function. And it would be good enough for me to just use that one. But i've tried downloading it as a zip file, renaming it as .xpi and manually install it as a Firefox addon. No joy, does anyone know how to install it?

Community
  • 1
  • 1
Sleuteltje
  • 33
  • 6

1 Answers1

1

Your Greasemonkey script could create an html link in the host page (document.createElement('a') etc...) with the recently introduced download attribute described here : http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download

Delapouite
  • 9,469
  • 5
  • 36
  • 41