Skip to content

Instantly share code, notes, and snippets.

@wazazaby
Last active June 22, 2022 10:06
Show Gist options
  • Save wazazaby/4de36b6326d9cefb7ebf9a2d8727286e to your computer and use it in GitHub Desktop.
Save wazazaby/4de36b6326d9cefb7ebf9a2d8727286e to your computer and use it in GitHub Desktop.
// This script allows you to download the new albums created by the Studio Ghibli on their website
// For example, open this one: https://www.ghibli.jp/works/laputa/
// Copy-paste this function in the console
// And then, simply call it!
async function getImages() {
const images = document.querySelectorAll('a.panelarea');
// Count to know when to sleep and avoid the limit of simultaneous downloads in Chrome (10)
let count = 0;
for (let image of images) {
let newLink = document.createElement('a');
newLink.href = image.href;
newLink.download = image.title;
document.body.appendChild(newLink);
newLink.click();
document.body.removeChild(newLink);
count++;
if (count === 10) {
await new Promise(resolve => setTimeout(resolve, 1000));
count = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment