Live data from Hacker News

Checkbox Olympics

checkboxolympics.com

11–20 of 51 posts

Re: Checkbox Olympics

#11
post #6

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)

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.

Re: Checkbox Olympics

#15

What am I doing with my life...

Perhaps finding timed checkbox challenges more fun than the other thing? Here are some more ideas for a break:

- https://news.ycombinator.com/item?id=30517626

- https://news.ycombinator.com/item?id=31191152

- https://news.ycombinator.com/item?id=24320277

Re: Checkbox Olympics

#16
post #12

Similar, a bit more challenging: https://checkboxrace.com/

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.
Post reply on HN