Save images to hard disk WITHOUT prompt?
It is possible when using Tampermonkey or Violentmonkey (Firefox or Chrome).
They added the GM_Download command.
You can use it like this:
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http*://*/*
// @grant GM_download
// ==/UserScript==
var arg = { url: "https://example.com/123456.jpg",
name: "CustomFileName.jpg"
};
GM_download(arg);
For more help and available options see the Tampermonkey documentation: https://tampermonkey.net/documentation.php
Greasemonkey cannot do this, because ordinary javascript is forbidden to do this (for security reasons), and the Greasemonkey API does not expose a method to write files (and never will).
Here are four alternatives:
Update: Switch to Tampermonkey, which you should do anyway. Then you can use GM_download as user136036 said in his answer.
or
Install and
use the excellent DownThemAll add-on(Update: Firefox 57 withdrew support for this kind of extension). It still requires one click, but that's better than always grabbing a file willy nilly, in most cases anyway.or
Write your own
addonextension. See this (now obsolete) answer for file-writing code from one of the top gurus of FF add-ons. But "new" style extensions can still do this.or
Use XAMPP (or similar) to run a web server on your machine. You will then have to write a web application that excepts incoming image data (or just the image URL) and saves the image to disk.
JavaScript does not have access to the computer's file system.
There is no native JS functionality for this. Otherwise any site would be able to save anything to your PC, which would result in your PC getting messed up in no time.