Skip to content

Instantly share code, notes, and snippets.

@esolitos
Created November 19, 2021 10:55
Show Gist options
  • Save esolitos/f9eff675c537de0308fe8f59ab0a2867 to your computer and use it in GitHub Desktop.
Save esolitos/f9eff675c537de0308fe8f59ab0a2867 to your computer and use it in GitHub Desktop.
Download all images from padlet.com without clicking each one
const down = function(img_url, name) {
fetch(img_url)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
// the filename you want
a.download = `img-${name}.jpg`
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
})
.catch(() => alert('oh no!'));
};
nodeList = Array.from(document.querySelectorAll('.wish'));
//Array.prototype.reverse.call(nodeList);
//debugger;
week = ''
nodeList.forEach((item, index) => {
if(item.classList.contains('with-attachment')){
let link = item.querySelector('a[href*=padlet-uploads]');
if(link) {
down(link.href, 'week-' + week + '-1C');
// console.log(link.href, week);
}
}
else {
week = item.querySelector('div[data-cy=postSubject]').innerText.slice(-2);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment