-
-
Save drhisham-code/aba7923ae65a399c886b0f4091c49cad to your computer and use it in GitHub Desktop.
Bookmarklet to download all images on a page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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