Auto Cookie Clicker

Automate Cookie Clicker and have it do the work for you!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Auto Cookie Clicker
// @namespace    https://waa.ai/spinpy
// @version      1.4
// @description  Automate Cookie Clicker and have it do the work for you!
// @author       Spinfal
// @match        http://orteil.dashnet.org/cookieclicker/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    async function click() {
        setInterval(function() { document.getElementById('bigCookie').click() }, 0);
    }

    async function upgrades(delay) {
        if (isNaN(parseInt(delay))) {
            alert('that wasnt a number.');
            upgrades(parseInt(prompt('enter an interval to auto buy upgrades (in seconds)')));
        } else {
            console.log(`upgrade delay set to: ${delay}`);
            setInterval(function() { document.getElementById('upgrade0').click() }, parseInt(delay) * 1000);
            // products
            setInterval(function() { document.getElementById('product0').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product1').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product2').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product3').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product4').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product5').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product6').click() }, delay * 1000);
        }
    }

    async function products(delay) {
        if (isNaN(parseInt(delay))) {
            alert('that wasnt a number.');
            upgrades(parseInt(prompt('enter an interval to auto buy products (in seconds)')));
        } else {
            console.log(`product delay set to: ${delay}`);
            setInterval(function() { document.getElementById('product0').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product1').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product2').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product3').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product4').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product5').click() }, delay * 1000);
            setInterval(function() { document.getElementById('product6').click() }, delay * 1000);
        }
    }


    setTimeout(function() {
        if (confirm('start autoclicker?')) {
            click();
        }

        if (confirm('auto buy upgrades?')) {
            upgrades(parseInt(prompt('enter an interval to auto buy upgrades (in seconds)')));
        }

        if (confirm('auto buy products?')) {
            upgrades(parseInt(prompt('enter an interval to auto buy products (in seconds)')));
        }
    }, 3000);

    setInterval(function() { Game.toSave=true;PlaySound('snd/tick.mp3') }, 10000);
})();