Cookie Clicker hack

Just a cookie clicker hack.

目前為 2019-12-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 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 hack
// @namespace    https://greasyfork.org/ru/scripts/392425-cookie-clicker-hack
// @version      1.2.1.1
// @license      MIT
// @description  Just a cookie clicker hack.
// @author       hasha2982
// @match        *://orteil.dashnet.org/cookieclicker/*
// @match        *://orteil.dashnet.org/cookieclicker/
// @grant        none
// ==/UserScript==

// NOTE: Don't works in IE!

console.log('[== Starting hack... ==]');

var ans = '';
var confirmans = false;
var forCookies = {
    iter: 0,
    ctr: 0
}

const hinfo = {
    version: '1.2.1',
    changes: 'Added Mouse Wheel mode!'
}

var ac = {
    sure: false,
    click: function() {
        document.getElementById('bigCookie').click();
    },
    timer: null, // used for clearTimeout in ac.termtimer()
    termtimer: function() {
        if (ac.timer === null) {
            alert('false ac.termtimer() call');
            console.log(ac);
        } else {
            clearTimeout(ac.timer);
        }
    },
    warning: false
}

var mwheel = {
    active: false,
    active2: false
}

document.onkeydown = function(e){
    e = e || window.event;
    var key = e.which || e.keyCode;
    if(key===72){
        hackMenu();
    } else if (key === 67) {
        ac.termtimer();
    }
}; // thx StackOverflow

var hmenuText = 'Welcome to hasha2982\'s Cookie Clicker hack v.' + hinfo.version + '!\nPlease select an option below:\n1) Earn free cookies\n2) Spawn golden cookies\n3) Autoclicker (tested on Cookie Clicker v.2.022)\n4) Mouse Wheel mode';

function hackMenu() {
    // if (event.code = 'KeyH') {
        ans = prompt(hmenuText);
        if (ans == '1') {
            ans = prompt('How many cookies do you want to earn?');
            if (ans === "" || ans === null) {
                alert('Cancelled.');
            } else {
                Game.cookies += Number(ans);
                Game.cookiesEarned += Number(ans);
            }
        ///////////////////////////////////////////////////
        } else if (ans == '2') {
            ans = prompt('How many cookies do you want to spawn?');
            if (!(ans === "" || ans === null) && Number(ans) > 0) {
                forCookies.iter = Number(ans);
                for (; forCookies.ctr < forCookies.iter; forCookies.ctr++) {
                    var newShimmer=new Game.shimmer("golden");
                    console.log(`Golden cookie spawned.\nIteration ${forCookies.ctr} is finished.\nIterations remaining: ${forCookies.iter - forCookies.ctr}`);
                }
                forCookies.iter = 0;
                forCookies.ctr = 0;
            } else {
                alert('Cancelled.');
            }
        }
        ////////////////////////////////////////////////////
        else if (ans == '3') {
            ans = prompt('Enter delay between clicks in ms. (1000 ms. = 1 s.)\n(press \'c\' to disable autoclicker)');
            if (ans === null || ans === "" || ans === '0' || Number(ans) < 1) {
                alert('Cancelled.');
            } else if (Number(ans) <= 100) {
                confirmans = confirm('Delay lower than 100ms. can cause lags.\nAre you sure?');
                if (confirmans === true) {
                    ac.sure = true;
                    console.log(`ac.sure is set to true\n`); console.log(ac);
                }
                // if (ac.sure === true) { // here it goes
                    ac.timer = setInterval(ac.click, Number(ans));
                // }
            } else {
                ac.timer = setInterval(ac.click, Number(ans));
            }
        }
        else if (ans === '4') {
            if (mwheel.active === false) {
                confirmans = confirm('Mouse wheel mode is disabled.\nIn mouse wheel mode every mouse wheel movement counts as a click on the cookie.\nYou can still use mouse buttons.\nPress \'OK\' to activate mouse wheel mode.\n(sorry for bad English.)');
                if (confirmans === true) {
                    mwheel.active2 = true;
                    console.log('Mouse wheel mode is activated.');
                } else {
                    alert('Cancelled.');
                }
            } else if (mwheel.active === true) {
                confirmans = confirm('Mouse wheel mode is enabled.\nIn mouse wheel mode every mouse wheel movement counts as a click on the cookie.\nYou can still use mouse buttons.\nPress \'OK\' to deactivate mouse wheel mode.\n(sorry for bad English.)');
                if (confirmans === true) {
                    mwheel.active2 = false;
                    console.log('Mouse wheel mode is deactivated.');
                } else {
                    alert('Cancelled.');
                }
            }
            if (mwheel.active2 === true) mwheel.active = true;
            else if (mwheel.active2 === false) mwheel.active = false;
            if (mwheel.active === true) document.onmousewheel = ac.click; // yoink
            else if (mwheel.active === false) document.onmousewheel = null; // null is default on orteil.dashnet.org/cookieclicker/
        }
        else if (ans === null || ans === "") {
            console.log('Prevented \'Function not found\' message');
        }
        else {
            alert('Function not found.');
        }
   // }
}

console.log('[== Hack is started. ==]\nVersion: v.' + hinfo.version);