Cookie clicker tools

Cookie clicker tools (visual)

目前為 2017-02-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 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 tools
// @namespace    orteil.dashnet.org
// @version      2.012
// @description  Cookie clicker tools (visual)
// @author       Anton
// @match        http://orteil.dashnet.org/cookieclicker/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    if (console) console.log('Cookies?');
    
    var started = false;
    
    var t2, t3, tClick;
    
    var startT = function() {
        t2 = setInterval(function() {
            var u = null; // upgrade can buy
            var minUpgradePrice = null;
            for (var g in Game.UpgradesById) {
                if (Game.UpgradesById[g].bought == 0 && Game.UpgradesById[g].unlocked == 1) {
                    //u.push(Game.UpgradesById[g]);
                    if (minUpgradePrice === null) {
                        minUpgradePrice = Game.UpgradesById[g].basePrice;
                        u = g;
                    } else if (Game.UpgradesById[g].basePrice < minUpgradePrice) {
                        minUpgradePrice = Game.UpgradesById[g].basePrice;
                        u = g;
                    }
                }
            }
            
            if (u !== null && typeof Game.UpgradesById[u] !== 'undefined'
                && (Game.cookies >= minUpgradePrice || ((minUpgradePrice - Game.cookies) / Game.cookiesPs) <= (15*60)))
            {
                
                if (Game.UpgradesById[u].canBuy()) {
                    Game.UpgradesById[u].buy();
                } else {
                    jQuery('#versionNumber').text('Upgrading ' + Game.UpgradesById[u].name + ' for ' + Beautify(minUpgradePrice));
                }
                
            } else {
            
                var minInvert = null, minObj = null;
                for (var i in Game.ObjectsById) {
                    if (typeof i !== 'undefined' && i != 'undefined' && Game.ObjectsById.hasOwnProperty(i)) {
                        if (Game.ObjectsById[i].locked === 0) {
                            var interest = Game.ObjectsById[i].price / Game.ObjectsById[i].storedCps;
                            if (minInvert == null) {
                                minInvert = interest;
                                minObj = i;
                            } else if (interest < minInvert) {
                                minInvert = interest;
                                minObj = i;
                            }
                        }
                    }
                }
                if (minObj != null) {
                    Game.ObjectsById[minObj].buy(1);
                    jQuery('#versionNumber').text('Collecting ' + Beautify(Game.ObjectsById[minObj].price) + ' for ' + Game.ObjectsById[minObj].name);
                }
                
            }
            
        }, 1000);
        
        started = true;
        jQuery('#versionNumber').text('Started');
    }
    
    var stopT = function() {
        clearInterval(t2);
        started = false;
        jQuery('#versionNumber').text('Collecting gold...');
    }
    
    jQuery('#versionNumber').on("click", function() {
        if (!started)
            startT();
        else
            stopT();
    });
    
    setTimeout(function() {
        t3 = setInterval(function() {
            var golden = Game.shimmers;
            if (golden.length > 0) {
                for (var i in golden) {
                    golden[i].pop();
                }
            }
        }, 1000);
        
        if (Game.cookiesPs < 1E6) {
            tClick = setInterval(function() {
                Game.mouseX = jQuery('#bigCookie').width() / 2 + jQuery('#bigCookie').left();
                Game.mouseY = jQuery('#bigCookie').height() / 2 + jQuery('#bigCookie').top();
                Game.ClickCookie();
                if (Game.cookiesPs > 1E6) clearInterval(tClick);
            }, 300);
        }
        
        jQuery('#versionNumber').text('Collecting gold...');
    }, 5000);
})();