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.995
  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 getInvertExpence = function($tooltip) {
  15. var price = $tooltip.find('span.price').text();
  16. if (price) {
  17. price = price.replace(',', '');
  18. var priceNum = parseFloat(price);
  19. var mult = 1;
  20. if (price.indexOf('billion') > -1) mult = 1E9;
  21. else if (price.indexOf('million') > -1) mult = 1E6;
  22. var totalPrice = priceNum * mult;
  23.  
  24. var data = $tooltip.find('div.data b');
  25. var eachIncome = jQuery(data[0]).text().replace(',', '');
  26. var eachIncomeNum = parseFloat(eachIncome);
  27. mult = 1;
  28. if (eachIncome.indexOf('billion') > -1) mult = 1E9;
  29. else if (eachIncome.indexOf('million') > -1) mult = 1E6;
  30. var totalIncome = eachIncomeNum * mult;
  31. var needed = totalPrice > 0 ? totalIncome / totalPrice : 0;
  32. var needInvert = totalIncome > 0 ? totalPrice / totalIncome : 0;
  33. return needInvert;
  34. }
  35. return null;
  36. }
  37. var t = setInterval(function() {
  38. var icons = document.querySelectorAll('.icon:not([id^=product])');
  39. var x = icons && icons.length > 0 ? icons[0].offsetParent : null;
  40. if (x !== null) {
  41. var $tooltip = jQuery(x);
  42. var needInvert = getInvertExpence($tooltip);
  43. if (needInvert !== null) {
  44. var $name = $tooltip.find('div.name span');
  45. if ($name.length === 0) {
  46. $tooltip.find('div.name').append(jQuery('<span />'));
  47. $name = $tooltip.find('div.name span');
  48. }
  49. $name.text(' (' + Beautify(needInvert) + ')');
  50. }
  51. }
  52. }, 100);
  53. var t2 = setInterval(function() {
  54. var minInvert = null, minObj = null;
  55. for (var i in Game.ObjectsById) {
  56. if (typeof i !== 'undefined' && i != 'undefined' && Game.ObjectsById.hasOwnProperty(i)) {
  57. if (Game.ObjectsById[i].locked === 0) {
  58. var interest = Game.ObjectsById[i].price / Game.ObjectsById[i].storedCps;
  59. if (minInvert == null) {
  60. minInvert = interest;
  61. minObj = i;
  62. } else if (interest < minInvert) {
  63. minInvert = interest;
  64. minObj = i;
  65. }
  66. }
  67. }
  68. }
  69. console.log('min', minInvert, 'obj', minObj);
  70. }, 1000);
  71. })();