Last active
July 28, 2022 18:57
-
-
Save pedily/bf9249b71dfd4d16c21461d306ecaaaa to your computer and use it in GitHub Desktop.
Download all saved cards in cardconjurer. Open the Developer Console while on https://cardconjurer.org/creator, paste the content of this file, then hit "return"
This file contains 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
(async () => { | |
const DELAY_BETWEEN_CARDS_IN_SECONDS = 2; | |
const cardNames = JSON.parse(localStorage.getItem("cardKeys")); | |
const wait = miliseconds => new Promise(resolve => setTimeout(resolve, miliseconds)); | |
const loadImage = src => new Promise(resolve => { | |
const img = document.createElement('img'); | |
img.onload = () => { | |
resolve(); | |
} | |
img.src = src; | |
}); | |
const loadImagesForCard = card => Promise.all([ | |
loadImage(card.artSource), | |
...card.frames.map(frame => frame.src).map(loadImage) | |
]); | |
const getCard = cardName => JSON.parse(localStorage.getItem(cardName)); | |
const pickAndDownloadCard = async cardName => { | |
await loadCard(cardName); | |
await Promise.all([ | |
loadImagesForCard(getCard(cardName)), | |
wait(DELAY_BETWEEN_CARDS_IN_SECONDS * 1000) | |
]); | |
downloadCard(); | |
await wait(DELAY_BETWEEN_CARDS_IN_SECONDS * 1000); | |
} | |
for (let i = 0; i < cardNames.length; i++) { | |
const cardName = cardNames[i]; | |
console.log(`[${i+1}/${cardNames.length}]: ${cardName}`); | |
await pickAndDownloadCard(cardName); | |
} | |
return cardNames; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment