Skip to content

Instantly share code, notes, and snippets.

@u-l-y
Created December 5, 2021 07:06
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 u-l-y/be786eab07ace36f9980393f1d22e91e to your computer and use it in GitHub Desktop.
Save u-l-y/be786eab07ace36f9980393f1d22e91e to your computer and use it in GitHub Desktop.
Donwload images from a site (filtering by type) using the browser console
const validFormats = ['jpg', 'jpeg', 'png'];
const images = [...document.getElementsByTagName('img')]
.map(img => img.getAttribute('src'))
.filter(img => validFormats.some(format => img.includes(format)));
let i = 0;
setInterval(() => {
if (images.length > i) {
const link = document.createElement('a');
link.id = i;
link.download = images[i];
link.href = images[i];
link.click();
i++;
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment