Cookie Clicker hack

Just a cookie clicker hack.

От 12.12.2019. Виж последната версия.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като 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);