Hacker Newsnew | past | comments | ask | show | jobs | submit | MechanicalFish's commentslogin

// ==UserScript== // @name Check All Unchecked Checkboxes // @namespace http://tampermonkey.net/ // @version 1.0 // @description Check all unchecked checkboxes on the page // @author MechanicalFish // @match https://onemillioncheckboxes.com/* // @grant none // ==/UserScript==

(function() { 'use strict';

    function checkAllCheckboxes() {
        var checkboxes = document.querySelectorAll('input[type="checkbox"]');

        checkboxes.forEach(function(checkbox) {
            if (!checkbox.checked) {
                checkbox.checked = true;
            }
        });
    }

    const observer = new MutationObserver((mutations) => {
        checkAllCheckboxes();
    });

    observer.observe(document.body, { childList: true, subtree: true });

    checkAllCheckboxes();
})();


This really feels like it defeats the purpose of the site ngl


Well maybe next time OP will actually do their analysis and figure out that the project is DOA before even writing one line of code.


The project was wildly successful. I didn't know who eieio was, and now I do. I suspect that's true for lots of people now.


Oh that's Celine Dion minus the consonants


How on earth did you come up with this? Or did you hear it somewhere?

If it’s the former, you need to do improv. You have the gift.



Yep, that's the form I've seen it in before.


He is celine dion


i thought it was old mac donald


This ain't gonna work for 1,000,000 checkboxes. You could try using requestAnimationFrame or querying only non-checked checkboxes querySelectorAll('input[type="checkbox"]:not(:checked)') or not calling checkAllCheckboxes for all mutations.

Edit: or just call querySelector('input[type="checkbox"]:not(:checked)') and do them one by one in some kinda while(true) loop


Just write data to the underlying API. No need to interact with the browser UI at all.



Thanks!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: