Cookie clicker tools

Cookie clicker tools (visual)

当前为 2017-02-25 提交的版本,查看 最新版本

// ==UserScript==
// @name         Cookie clicker tools
// @namespace    http://orteil.dashnet.org
// @version      1.0
// @description  Cookie clicker tools (visual)
// @author       Anton
// @match        http://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 t = setInterval(function() {
        var x = document.querySelectorAll('.icon:not([id^=product])')[0].offsetParent;
        if (x !== null) {
            var $tooltip = $(x);
            var price = $tooltip.find('span.price').text;
            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;
            if (console) console.log(totalPrice);
        }
    }, 500);
})();