Skip to content

Instantly share code, notes, and snippets.

@pedily
Last active July 28, 2022 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedily/bf9249b71dfd4d16c21461d306ecaaaa to your computer and use it in GitHub Desktop.
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"
(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