Last active
April 15, 2024 19:24
-
-
Save kuhel/9d2cd41070c0874cd8a1e5508bd1323c to your computer and use it in GitHub Desktop.
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
function downloadImage(imageSrc, fileName) { | |
const link = document.createElement('a'); | |
link.href = imageSrc; | |
link.download = fileName || 'download'; | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); | |
} | |
function downloadImages(delay) { | |
const images = document.querySelectorAll('img.styles_image__3RaYx'); | |
let i = 0; | |
function downloadNext() { | |
if (i >= images.length) { | |
console.log('All images have been downloaded.'); | |
return; | |
} | |
const image = images[i]; | |
const src = image.src; | |
const imageName = `${image.getAttribute('alt')}_logo`; | |
console.log(`Downloading image ${i + 1}: ${src}`); | |
downloadImage(src, imageName); | |
i++; | |
setTimeout(downloadNext, delay); | |
} | |
downloadNext(); | |
} | |
downloadImages(500); // Adjust delay in milliseconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment