-
-
Save jsejcksn/c0e75bf6c772e016560757b29f7f3792 to your computer and use it in GitHub Desktop.
https://ludipe.itch.io/constancia -> Automatically persevere
This file contains hidden or 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
// https://ludipe.itch.io/constancia | |
// 1. Open the JS console | |
// 2. Switch the JS context to the embedded iframe. More info about this at: | |
// https://developers.google.com/web/tools/chrome-devtools/console/reference#context | |
// 3. Copy and paste the code below, then press Enter to run it | |
// 4. Close the JS console and click on Constancia to focus it again | |
// 5. Press the spacebar to start/stop. Press 1 to decrease speed. Press 2 to increase speed. | |
(async () => { | |
const wait = ms => new Promise(res => setTimeout(res, ms)); | |
const createKeyboardEvent = (type, key) => new KeyboardEvent(type, {bubbles: true, key}); | |
const sendKeyDownAndUp = async (element, key) => { | |
element.dispatchEvent(createKeyboardEvent('keydown', key)); | |
await wait(2); | |
element.dispatchEvent(createKeyboardEvent('keyup', key)); | |
}; | |
const perseveranceGenerator = (function* () { | |
const keys = 'perseverance'.split(''); | |
while (true) for (const key of keys) yield key; | |
})(); | |
const canvas = document.querySelector('canvas'); | |
let active = false; | |
let keyDelay = 200; | |
const toggle = async () => { | |
while (active) { | |
await sendKeyDownAndUp(canvas, perseveranceGenerator.next().value); | |
await wait(keyDelay); | |
} | |
}; | |
document.addEventListener('keydown', ev => { | |
switch (ev.key){ | |
case '1': { | |
const newKeyDelay = keyDelay + 100; | |
keyDelay = newKeyDelay; | |
break; | |
} | |
case '2': { | |
const newKeyDelay = keyDelay - 100; | |
if (newKeyDelay >= 100) keyDelay = newKeyDelay; | |
break; | |
} | |
default: return; | |
} | |
}); | |
document.addEventListener('keyup', ev => { | |
if (ev.key === ' ') { | |
active = !active; | |
toggle(); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment