Checkbox Olympics
checkboxolympics.com
Checkbox Olympics
1–10 of 51 posts
Re: Checkbox Olympics
#2edit 1: 9.004 at my pixel, i am mobile gamer now! pog
edit 2: 6.446 on phone !
Re: Checkbox Olympics
#3Re: Checkbox Olympics
#4In a weird way this reminds me of the old 80s "epyx" sports game which seemed to involve typeing keys as fast as you can.
Re: Checkbox Olympics
#5Re: Checkbox Olympics
#6 var simulateClick = function (elem) {
// Create our event (with options)
var evt = new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window
});
// If cancelled, don't dispatch our event
var canceled = !elem.dispatchEvent(evt);
};
var run = () => {
var el = document.querySelector('input[type=checkbox]:not(:checked)')
simulateClick(el)
}
setInterval(run, 100)Re: Checkbox Olympics
#7Re: Checkbox Olympics
#8Cool game! Doesn't really work for me on mobile because the second box is obscured by the SET button.
Re: Checkbox Olympics
#9My "speedrun": var simulateClick = function (elem) { // Create our event (with options) var evt = new MouseEvent('click', { bubbles: true, cancelable: true, view: window }); // If cancelled, don't dispatch our event var canceled = !elem.dispatchEvent(evt); }; var run = () => { var el = document.querySelector('input[type=checkbox]:not(:checked)') simulateClick(el) } setInterval(run, 100)
let setGo = document.querySelector(".setGo");
let observer = new MutationObserver(mutations => {
if (setGo.classList.contains("going")) {
for (const { target } of mutations) {
if (target.checked == target.disabled) {
target.click();
}
}
}
});
observer.observe(setGo, {attributes: true});
document.querySelectorAll(".theSport input").forEach(checkbox => {
observer.observe(checkbox, {attributes: true});
});
Explanation: instead of messing about with timers, it asks to be informed when any attribute changes (could use attributeFilter to only hear about "class" for setGo and "disabled" for checkboxes, but I didn’t bother). This is faster than can be acheived with setTimeout, setInterval or requestAnimationFrame, as timers are deliberately speed-capped. (Whereas mutation observers create microtasks, so we can go through this whole thing in one frame.)When the observer gets notified (in a microtask), it checks if we’re going (in order to avoid false starts), and then goes through the checkboxes it’s been told just changed, and checks if they’re enabled and unchecked, and clicks them. In practice, the first mutation will come in with mutation records for setGo and the first checkbox, which we’ll click, which will trigger an event (a task) from the page code which enables the second checkbox, which will trigger an immediate mutation notification (a microtask), &c. until it’s all done, without ever rendering a frame in the meantime.
Re: Checkbox Olympics
#10My "speedrun": var simulateClick = function (elem) { // Create our event (with options) var evt = new MouseEvent('click', { bubbles: true, cancelable: true, view: window }); // If cancelled, don't dispatch our event var canceled = !elem.dispatchEvent(evt); }; var run = () => { var el = document.querySelector('input[type=checkbox]:not(:checked)') simulateClick(el) } setInterval(run, 100)
var boxes = document.querySelectorAll("#root > div > div.sportsWrapper > div.theSport > div:nth-child(2) > input[type=checkbox]")
Then "start", wait for go signal while getting the code below ready on console. on go run the code: boxes.forEach(b => b.click())
Got: Time: 0.268