Created
December 5, 2021 07:06
-
-
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
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
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