Skip to content

Instantly share code, notes, and snippets.

@rayriffy
Last active May 11, 2020 13:01
Show Gist options
  • Save rayriffy/40328419c7260424efc596938ffb7a2c to your computer and use it in GitHub Desktop.
Save rayriffy/40328419c7260424efc596938ffb7a2c to your computer and use it in GitHub Desktop.
Autoplay script for SEGA minigame: https://chunithm.sega.jp/minigame_memory/
Array.from({ length: document.querySelectorAll('div.card-backPicture').length / 2 })
.map((_, i) => [...document.querySelectorAll(`div.card-backPicture`)].filter(el => el.style.backgroundImage === `url("./images/master/score-${String(i + 1).padStart(2, '0')}.jpg")`))
.reduce((promise, pair) => {
return promise.then(() => {
return new Promise(resolve => {
setTimeout(() => {
resolve(pair.map(el => el.click()))
}, 3000);
})
})
}, Promise.resolve())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment