Skip to content

Instantly share code, notes, and snippets.

@didier
Created April 1, 2022 09:46
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 didier/de1829e84ef0548a21a28ab8b943e51d to your computer and use it in GitHub Desktop.
Save didier/de1829e84ef0548a21a28ab8b943e51d to your computer and use it in GitHub Desktop.
Download all images from a page
const images = document.querySelectorAll('img').forEach((image, index) => {
const filename = `${window.location.host}-${index}.jpg`
const element = document.createElement('a');
element.setAttribute('href', image.src);
element.setAttribute('download', filename);
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment