Greasy Fork 还支持 简体中文。

Cookie Clicker 1M Buyer

Buys 1M in batches of 100 with cooldown to avoid lag

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Cookie Clicker 1M Buyer
// @author    Emree.el
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Buys 1M in batches of 100 with cooldown to avoid lag
// @match        https://orteil.dashnet.org/cookieclicker/*
// @grant        none
// @license    MIT
// ==/UserScript==

(function() {
    'use strict';

    const CUSTOM_ID = 'storeBulk1M';
    const TOTAL_TARGET = 1000000;
    const BATCH_AMOUNT = 100;
    const DELAY_MS = 1000; // cooldown between batches (1 sec)

    let active = false;

    function makeButton() {
        const bulk = document.getElementById('storeBulk');
        if (!bulk || document.getElementById(CUSTOM_ID)) return;

        const ref = document.getElementById('storeBulk100');
        let btn = ref ? ref.cloneNode(true) : document.createElement('div');

        btn.id = CUSTOM_ID;
        btn.innerText = '1M';
        btn.classList.remove('selected');
        btn.title = 'Buys 1M in batches of 100 with cooldown';

        btn.addEventListener('click', e => {
            e.stopPropagation();
            e.preventDefault();
            active = true;
            bulk.querySelectorAll('.storeBulkAmount').forEach(b => b.classList.remove('selected'));
            btn.classList.add('selected');
        });

        if (ref) ref.insertAdjacentElement('afterend', btn);
        else bulk.appendChild(btn);

        // If other bulk button clicked, deactivate
        bulk.addEventListener('click', ev => {
            const clicked = ev.target.closest('.storeBulkAmount');
            if (clicked && clicked.id !== CUSTOM_ID) {
                active = false;
                btn.classList.remove('selected');
            }
        }, true);
    }

    // Handle product clicks when 1M active
    document.addEventListener('click', e => {
        if (!active) return;
        const product = e.target.closest('.product');
        if (!product) return;

        e.stopImmediatePropagation();
        e.preventDefault();

        const match = product.id.match(/^product(\d+)$/);
        if (!match) return;

        const idx = parseInt(match[1], 10);
        if (!Game || !Game.ObjectsById[idx]) return;

        let bought = 0;

        function buyBatch() {
            if (bought >= TOTAL_TARGET) return;
            for (let i = 0; i < BATCH_AMOUNT; i++) {
                Game.ObjectsById[idx].buy();
            }
            bought += BATCH_AMOUNT;
            setTimeout(buyBatch, DELAY_MS);
        }

        buyBatch();
    }, true);

    setInterval(makeButton, 500);
})();