cookie_clicker_game_bot

clicker bot for coockieclicker game

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         cookie_clicker_game_bot
// @namespace    http://tampermonkey.net/
// @version      0.1.4
// @description  clicker bot for coockieclicker game
// @author       iampopovich
// @match        https://orteil.dashnet.org/cookieclicker/
// @grant        none
// ==/UserScript==

const DEFAULT_TIME_STRATEGY = 35000

function cookieWorker() {
	let cookie = null;
	let products = null;
	let timeStrategy = null;
	try {
		timeStrategy = parseInt(window.prompt("Enter period in sec between shop buing\n \
                                     1 sec - agressive\n \
                                     60 sec - passive"))*1000;
	} catch (e){
        console.log(e);
		timeStrategy = DEFAULT_TIME_STRATEGY;
	}
    console.log(timeStrategy);
	let searchForElements = setInterval(function() {
		cookie = document.getElementById('bigCookie');
		products = document.getElementById('products');
		if (cookie && products) {
			clearInterval(searchForElements);
			const event = new MouseEvent('mouseover', {
				'view': window,
				'bubbles': true,
				'cancelable': true
			});
			cookie.dispatchEvent(event);
		}
	}, 10000);

	setInterval(function() {
		cookie.click();
	}, 150);
	setInterval(function() {
		productBuyer(products)
	}, timeStrategy);
}

function buyCursor(chance){
    let cursor = document.getElementById("productName0");
    if(chance >= Math.random()) {
        cursor.click();
        console.log('cursor was bought');
    }
}

function buyGrandma(chance){
    let cursor = document.getElementById("productName1");
    if(chance >= Math.random()) {
        cursor.click();
        console.log('cursor was bought');
    }
}

function buyFarm(chance) {
    let cursor = document.getElementById("productName2");
    if(chance >= Math.random()) {
        cursor.click();
        console.log('cursor was bought');
    }
}

function buyMine(chance) {
    let cursor = document.getElementById("productName3");
    if(chance >= Math.random()) {
        cursor.click();
        console.log('cursor was bought');
    }
}

function buyUpgrades(upgrades) {}

function productBuyer(products) {
    buyCursor(0.15);
    buyGrandma(0.20);
    buyFarm(0.25);
    buyMine(0.30);

    let productList = products.querySelectorAll('div[class~=product]');
	for (let i = productList.length - 1; i >= 4; i--) {
		productList[i].click()
	};
}

cookieWorker();