Skip to content

Instantly share code, notes, and snippets.

@ansonhoyt
Created March 22, 2018 18:29
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 ansonhoyt/1e1f2ee98049a0839cdba4591699c149 to your computer and use it in GitHub Desktop.
Save ansonhoyt/1e1f2ee98049a0839cdba4591699c149 to your computer and use it in GitHub Desktop.
Download all link's target files for the given selector
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