top | item 31797988

Checkbox Olympics

148 points| Gedxx | 3 years ago |checkboxolympics.com | reply

48 comments

order
[+] brzezmac|3 years ago|reply
Looks like a good place to workout before attempting to switch off notifications in some popular applications.
[+] layer8|3 years ago|reply
Certain cookie opt-out dialogs are a good training ground as well.
[+] acomjean|3 years ago|reply
When done, don't forget to click the "back" arrow in the upper left corner. There is another checkbox event (hurdles...)

In a weird way this reminds me of the old 80s "epyx" sports game which seemed to involve typeing keys as fast as you can.

https://en.wikipedia.org/wiki/Summer_Games_(video_game)

[+] klenwell|3 years ago|reply
My "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)
[+] chrismorgan|3 years ago|reply
My tool-assisted speedrun (0.001s):

  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.

[+] chrismorgan|3 years ago|reply
Dunno quite what your idea was with canceled: your comment doesn’t match behaviour at all. As for dispatching a click event, you can just use .click().

Your speedrun code can be reduced to this:

  setInterval(() => document.querySelector('input[type=checkbox]:not(:checked)').click(), 100)
It would be significantly improved by the addition of :enabled and then reduction of interval time.
[+] ssharp|3 years ago|reply
Brute approach (This doesn't account for whether a checkbox is checked or not so I don't actually know if the game prevents everything getting checked programmatically all at once. I had to set the setTimeout to "2" instead of "1" so it would actually record some time!):

  document.querySelector('.readyButton').click();
  waitForStart();

  function waitForStart() {
    if (document.querySelector('.setGo').classList.value.includes("going")) { 
      for(x=0; x<document.querySelectorAll('input[type="checkbox"]').length; x++) { document.querySelectorAll('input[type="checkbox"]')[x].click(); }
    }
    else { setTimeout(waitForStart, 2); }
  }
[+] dhab|3 years ago|reply
I went with a manual-mix approach:

  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
[+] jxcole|3 years ago|reply
If you're going to cheat why not all the way:

    document.querySelector(".time").innerHTML = '<b>Time:</b> 0.0001';
    Array.from(document.querySelectorAll(".theSport input[type='checkbox']"))
      .forEach(e => { e.disabled = false; e.checked = true; });
[+] msoad|3 years ago|reply

     $('.readyButton').click(); setTimeout(()=> [...document.querySelectorAll('input[type="checkbox"]')].map(cb => cb.click()), 3000)

This gives me 0.143 in Safari which is just a proof that DOM is freaking slow haha!
[+] eloox|3 years ago|reply
setTimeout doesn't guarantee that it will execute exactly after 3000.

  (() => {
    const targ = $(".setGo");
    const targ2 = $(".theSport > div:nth-child(2)");
    const observer = new MutationObserver((mutations, observer) => {
      if (mutations[0]?.target?.classList.contains('going')) {
        targ2.childNodes.forEach(c => c.click());
      }
    });
  
    observer.observe(targ, {
      subtree: false,
      attributes: true
    });
  
    $('.readyButton').click()
  })();
  
This gives me consistent Time: 0.001 in FF. "Time: not yet set" in Edge/Chrome.
[+] alarmingfox|3 years ago|reply
Wow in Chrome 102.0.5005.115 (Official Build) (arm64) it gives me 3.273s which proves that point even more
[+] drudoo|3 years ago|reply
I got 0.087 with firefox but subsequent tries are all in the 0.3-0.8 range.
[+] bduffany|3 years ago|reply
I wonder how much of the time is spent in the onclick handler. Each of those clicks has to wait for the onclick handler before the next one executes, IIUC?
[+] indifferentalex|3 years ago|reply
Some of us have our stash of ~10 domain names for our side projects (that we renew year after year, with some embarrassment). Tim's got 90 linked from https://theuselessweb.com/

I wonder if he renews them on the cheap somehow, either way there are some really funny ones in there

[+] butz|3 years ago|reply
Are you intentionally setting random tabindex values just to mess with keyboard users? I would like to suggest adding "Checkbox Paralympics" version, where keyboard users could compete too.
[+] demindiro|3 years ago|reply
I decided to use Python instead of JS for this:

    import pyautogui as m
    from fastgrab import screenshot

    m.PAUSE = 0

    while 1:
        x, y = m.position()
        r, g, b, _ = screenshot.Screenshot().capture((x, y, 1, 1))[0][0]
        if (r, g, b) in ((50, 205, 50), (127, 224, 127)):
            break

    m.moveRel(-35, 105)

    for _ in range(27):
        m.click()
        m.moveRel(23, 0)
    m.click()
My record is 0.03 in FF

EDIT: 0.02 in Chromium

[+] LittlePeter|3 years ago|reply
r/mildlyinteresting, but would have been better if after the race you were shown your rank among other participants.
[+] deltree7|3 years ago|reply
considering how people are already gaming/cheating on this, it's useless stats. Sure, you can write code to check for bots and the bots will write code to beat it...and so on
[+] thih9|3 years ago|reply
Similar, a bit more challenging: https://checkboxrace.com/
[+] chrismorgan|3 years ago|reply
My TAS can be slightly adjusted to work with this one:

  let observer = new MutationObserver(mutations => {
      for (const { target } of mutations) {
          if (target.checked == target.disabled) {
              target.click();
          }
      }
  });
  document.querySelectorAll("[type=checkbox]").forEach(checkbox => {
      observer.observe(checkbox, {attributes: true});
  });
Then click on the first checkbox and it’ll do all of the rest. Time varies a bit, best I’ve done in a couple of dozen attempts is 00:00:03.
[+] Benanov|3 years ago|reply
This basically told me I need a new / different trackball. The coefficient of static friction is too high in my current one to do this accurately - I need more force to start the ball rolling than I need to move to the next checkbox.

I'm using a Sanwa Supply one now

Looks like it might be a ploopy with BTS instead of their rollerbearings.

[+] dsr_|3 years ago|reply
Have you cleaned the ball and the bearings recently? I need to clean a Logitech M570 about every 2-3 weeks.
[+] texaslonghorn5|3 years ago|reply
Cool game! Doesn't really work for me on mobile because the second box is obscured by the SET button.
[+] forty|3 years ago|reply
Click "ready" then wait for the "Go" to go green. Then you can start racing, and here at least, I was able to click through the Set light
[+] usrusr|3 years ago|reply
Kind of like minesweeper, but without the strategy part?

Because once a minesweeper addict has reached a certain base level of skill, the strategy part stops to be about where the mines are, it becomes all about reordering the click queue for speed. (don't ask me how I know)

[+] elchief|3 years ago|reply
"Set" covers the 2nd checkbox. Fun
[+] loudthing|3 years ago|reply
It would be nice if I got to see how I did against other players.
[+] bigtones|3 years ago|reply
I got: 100 Meter Sprint 18.509

110 Meter Hurdles 18.85

Total Time: 37.359

with a mouse on desktop chrome.

[+] someweirdperson|3 years ago|reply
On my tablet the slightes movement of the pen causes firefox to select stuff instead of switching the checkbox. Causes extreme slow-down.

Under normal circumstances I don't like websites to try to mess with selection, copynpaste, ... but in this case it would be both helpful and justified.

[+] poiuyytrewq|3 years ago|reply
setInterval(() => { if(document.querySelector('.going')) { document.querySelectorAll('.theSport input').forEach(box => { box.click(); }); }}, 10);
[+] crazywulf|3 years ago|reply
best game! Time: 9.598

edit 1: 9.004 at my pixel, i am mobile gamer now! pog

edit 2: 6.446 on phone !

[+] hansword|3 years ago|reply
Good job! I can't get below 10 on my iPad.
[+] pickpuck|3 years ago|reply
I think this demonstrates that:

1) the hit area of native checkboxes should be larger, and

2) fieldsets with checkboxes should come with a native "Toggle All" button

[+] april_22|3 years ago|reply
it would be such a dream if the hit area for native checkboxes would be larger