Skip to content

Instantly share code, notes, and snippets.

@kuhel
Last active April 15, 2024 19:24
Show Gist options
  • Save kuhel/9d2cd41070c0874cd8a1e5508bd1323c to your computer and use it in GitHub Desktop.
Save kuhel/9d2cd41070c0874cd8a1e5508bd1323c to your computer and use it in GitHub Desktop.
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