Skip to content

Instantly share code, notes, and snippets.

@ajaysolleti
Forked from sfrdmn/image_downloader.js
Created April 27, 2017 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajaysolleti/679ab572238c0d7c238c64df6c21fb14 to your computer and use it in GitHub Desktop.
Save ajaysolleti/679ab572238c0d7c238c64df6c21fb14 to your computer and use it in GitHub Desktop.
Bookmarklet to download all images on a page
;(function() {
var images = [].slice.call(document.querySelectorAll('img'))
try {
images.forEach(function(img) {
downloadImage(img)
})
} catch (e) {
alert("Download failed.");
console.log('Download failed.', e);
}
function downloadImage(img) {
var link = document.createElement('a')
link.setAttribute('href', img.src)
link.setAttribute('download', '')
link.click()
}
}).call(window);
javascript:;(function() {var images = [].slice.call(document.querySelectorAll('img'));try {images.forEach(function(img){downloadImage(img)})} catch (e) {alert('Download failed.');console.log('Download failed.', e)}function downloadImage(img) {var link = document.createElement('a');link.setAttribute('href', img.src);link.setAttribute('download', '');link.click()}}).call(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment