Created
March 22, 2018 18:29
-
-
Save ansonhoyt/1e1f2ee98049a0839cdba4591699c149 to your computer and use it in GitHub Desktop.
Download all link's target files for the given selector
This file contains 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
let linkSelector = '.download-button'; | |
document.querySelectorAll(linkSelector).forEach(function(link) { | |
let clone = link.cloneNode(); // avoid existing event listeners | |
clone.setAttribute('download', ''); // indicate the download action | |
clone.click(); // trigger the download | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment