Checkbox.toys Auto Clicker

Auto clicks checkboxes on checkbox.toys

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Checkbox.toys Auto Clicker
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Auto clicks checkboxes on checkbox.toys
// @author       You
// @match        https://checkbox.toys/*
// @grant        none
// @license      sigma
// ==/UserScript==

(function() {
  'use strict';

  const checkboxdiv = document.querySelector(".checkboxes");
  const startButton = document.querySelector(".startButton");
  let canClick = false;

  const buttonObserver = new MutationObserver(() => {
    const buttonText = startButton.innerText;
    canClick = !["START COUNTDOWN", "3", "2", "1"].includes(buttonText);
    if (canClick) {
      checkboxdiv.children[0].click();
    }
    console.log(`Button text changed to: ${buttonText}, canClick: ${canClick}`);
  });

  const checkboxObserver = new MutationObserver(() => {
    console.log(`Checkbox mutation detected, canClick: ${canClick}`);
    if (!canClick) return;
    
    const checkboxes = Array.from(checkboxdiv.children);
    const lastEnabled = checkboxes.reverse().find(checkbox => !checkbox.disabled);
    if (lastEnabled) {
      console.log('Clicking last enabled checkbox');
      lastEnabled.click();
    } else {
      console.log('No enabled checkboxes found');
    }
  });

  console.log('Setting up observers...');

  buttonObserver.observe(startButton, {
    characterData: true,
    childList: true,
    subtree: true
  });

  checkboxObserver.observe(checkboxdiv, {
    childList: true,
    subtree: true,
    attributes: true
  });

  console.log('Observers initialized');
})();