Last active
April 10, 2019 11:16
-
-
Save wilgert/f4f9590d3d8b110041531132c4c6c8e0 to your computer and use it in GitHub Desktop.
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
/* | |
* What is this? | |
* This is an automated "conductor" for the beautiful web app In C by Tero Pavianen | |
* | |
* How to use it? | |
* 1. Go to https://teropa.info/in-c/ | |
* 2. Click on the Play button after it has finished loading | |
* 3. Open the Chrome Developer Tools | |
* 4. Paste the Code below in the Console tab and press Enter | |
* 5. Listen to your personal unique performance of In C | |
* | |
* Who made this | |
* Wilgert Velinga ([email protected]) | |
* | |
* Why was this made | |
* Because I love the web app by Tero but I got tired of clicking the advande buttons manually | |
* | |
*/ | |
let advanceRandom; | |
let schedule; | |
let getPlayers; | |
let getRandomTimeout; | |
getPlayers = () => Array.from(document.getElementsByTagName('in-c-advance-button')).map(p => p.getElementsByTagName('button')[0]); | |
getRandomTimeout = () => Math.floor(Math.sqrt(Math.random() * 6000) * 100); | |
advanceRandom = () => { | |
if (Math.random() < 0.2) { | |
return; | |
} | |
const activePlayers = getPlayers().filter((player) => !player.hasAttribute('disabled')); | |
activePlayers[Math.floor(Math.random() * activePlayers.length)].click(); | |
} | |
schedule = () => { | |
setTimeout(schedule, getRandomTimeout()); | |
advanceRandom(); | |
} | |
schedule(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment