Created
November 19, 2021 10:55
-
-
Save esolitos/f9eff675c537de0308fe8f59ab0a2867 to your computer and use it in GitHub Desktop.
Download all images from padlet.com without clicking each one
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 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