Skip to content

Instantly share code, notes, and snippets.

@Lars418
Created August 18, 2021 18:00
Show Gist options
  • Save Lars418/53f10b2fc9e488eb038cd3382b5e774d to your computer and use it in GitHub Desktop.
Save Lars418/53f10b2fc9e488eb038cd3382b5e774d to your computer and use it in GitHub Desktop.
Alle Bilder von einer Anzeige von ebay-kleinanzeigen herunterladen
/**
* HOWTO: Copy whole file, open devtools on page (F12 / Ctrl + Shift + i) and paste it into the console
* Chrome might ask you to allow downloading multiple images.
*/
// credits for forceDownload: https://stackoverflow.com/a/49886131/8463645
function forceDownload(url, fileName){
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "blob";
xhr.onload = function(){
var urlCreator = window.URL || window.webkitURL;
var imageUrl = urlCreator.createObjectURL(this.response);
var tag = document.createElement('a');
tag.href = imageUrl;
tag.download = fileName;
document.body.appendChild(tag);
tag.click();
document.body.removeChild(tag);
}
xhr.send();
}
function downloadAllImages() {
const title = document.getElementById('viewad-title').innerText;
const images = Array.from(document.querySelectorAll('#viewad-image')).map(x => x.src.replace('$_59', '$_57'));
images.forEach((img, index) => forceDownload(img, `${title}-${index}`));
}
downloadAllImages();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment