Cookie clicker tools

Cookie clicker tools (visual)

目前为 2017-02-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         Cookie clicker tools
// @namespace    orteil.dashnet.org
// @version      1.999
// @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 getInvertExpence = function($tooltip) {
        var price = $tooltip.find('span.price').text();
        if (price) {
            price = price.replace(',', '');
            var priceNum = parseFloat(price);
            var mult = 1;
            if (price.indexOf('billion') > -1) mult = 1E9;
            else if (price.indexOf('million') > -1) mult = 1E6;
            var totalPrice = priceNum * mult;

            var data = $tooltip.find('div.data b');
            var eachIncome = jQuery(data[0]).text().replace(',', '');
            var eachIncomeNum = parseFloat(eachIncome);
            mult = 1;
            if (eachIncome.indexOf('billion') > -1) mult = 1E9;
            else if (eachIncome.indexOf('million') > -1) mult = 1E6;
            var totalIncome = eachIncomeNum * mult;
                
            var needed = totalPrice > 0 ? totalIncome / totalPrice : 0;
            var needInvert = totalIncome > 0 ? totalPrice / totalIncome : 0;
                
            return needInvert;
        }
        return null;
    }
    
    var t = setInterval(function() {
        var icons = document.querySelectorAll('.icon:not([id^=product])');
        var x = icons && icons.length > 0 ? icons[0].offsetParent : null;
        if (x !== null) {
            var $tooltip = jQuery(x);
            var needInvert = getInvertExpence($tooltip);
            if (needInvert !== null) {
                var $name = $tooltip.find('div.name span');
                if ($name.length === 0) {
                    $tooltip.find('div.name').append(jQuery('<span />'));
                    $name = $tooltip.find('div.name span');
                }
                $name.text(' (' + Beautify(needInvert) + ')');
            }
        }
    }, 100);
    
    var t2;
    
    var startT = function() {
        t2 = setInterval(function() {
            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('Stopped');
    }
    
    jQuery('#versionNumber').on("click", function() {
        if (!started)
            startT();
        else
            stopT();
    });
    
    var t3 = setInterval(function() {
        var golden = Game.shimmers;
        if (golden.length > 0) {
            for (var i in golden) {
                golden[i].pop();
            }
        }
    }, 3000);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址