Danbooru

download image shortcut

Posted under General

im sorry if there's already topic of this but
have been wondering if there's any plan to make a shortcut to download an image [original size] by using keyboard button such as shift + D or anything else

It is possible with JavaScript alone (and the help of the HTML5 download attribute):

download = document.createElement("a");
download.setAttribute("download","");
download.setAttribute("href","https://danbooru.donmai.us/data/a68430f82f2877b1eb43a9abed73e6fa.png");
download.setAttribute("style","display:none");
document.body.appendChild(download).click();

Some notes:

  • This is tested with Firefox and should work with Chrome and Edge as well but it won't work with IE
  • In Firefox this works only for same-origin downloads - not a problem in this case -
  • For the JavaScript generated click to work the element has to be inserted into the DOM, but it can be invisble

See also:

Of course the above code would have to be either added as site feature or adapted into an userscript.

1