Created
March 22, 2017 14:09
-
-
Save hattmarris/49a86f74466c6b0ea431a20fb5e99905 to your computer and use it in GitHub Desktop.
JavaScript - Batch Download Images
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
// <img>s wrapped in <a> tags | |
// Select images | |
var images = document.querySelectorAll('img'); | |
// Get parent links | |
var links = []; | |
images.forEach( | |
function (el) { | |
links.push(el.parentElement); | |
} | |
); | |
// Loop and download each | |
links.forEach( | |
function(a) { | |
a.setAttribute('download', null); // set download attr explicitly | |
a.click(); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment