Checkbox.toys Auto Clicker

Auto clicks checkboxes on checkbox.toys

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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');
})();