Cookie clicker tools

Cookie clicker tools (visual)

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

  1. // ==UserScript==
  2. // @name Cookie clicker tools
  3. // @namespace orteil.dashnet.org
  4. // @version 1.5
  5. // @description Cookie clicker tools (visual)
  6. // @author Anton
  7. // @match http://orteil.dashnet.org/cookieclicker/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. if (console) console.log('Cookies?');
  14. var t = setInterval(function() {
  15. var icons = document.querySelectorAll('.icon:not([id^=product])');
  16. var x = icons && icons.length > 0 ? icons[0].offsetParent : null;
  17. if (x !== null) {
  18. var $tooltip = jQuery(x);
  19. var price = $tooltip.find('span.price').text();
  20. if (price) {
  21. price = price.replace(',', '');
  22. var priceNum = parseFloat(price);
  23. var mult = 1;
  24. if (price.indexOf('billion') > -1) mult = 1E9;
  25. else if (price.indexOf('million') > -1) mult = 1E6;
  26. var totalPrice = priceNum * mult;
  27.  
  28. var data = $tooltip.find('div.data b');
  29. var eachIncome = data[0].text().replace(',', '');
  30. mult = 1;
  31. if (eachIncome.indexOf('billion') > -1) mult = 1E9;
  32. else if (eachIncome.indexOf('million') > -1) mult = 1E6;
  33. var totalIncome = eachIncome * mult;
  34. if (console) console.log(totalPrice, totalIncome);
  35. }
  36. }
  37. }, 500);
  38. })();