4chan Auto Toggle

Automatically clicks the 'Auto' toggle on 4chan threads if it's not already checked.

// ==UserScript==
// @name         4chan Auto Toggle
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatically clicks the 'Auto' toggle on 4chan threads if it's not already checked.
// @author       loki1488
// @match        https://boards.4chan.org/*/thread/*
// @connect      4chan.org
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    function waitForElement(selector, callback) {
        var el = document.querySelector(selector);
        if (el) {
            callback(el);
        } else {
            setTimeout(function() {
                waitForElement(selector, callback);
            }, 100);
        }
    }
    waitForElement('input[data-cmd="auto"]', function(autoInput) {
        if (!autoInput.checked) {
            autoInput.click();
        }
    });
})();