CookieClicker trading bot

Starts trading indices that have 60 or more ticks stored locally.

目前为 2022-11-21 提交的版本。查看 最新版本

// ==UserScript==
// @name        CookieClicker trading bot
// @namespace   Violentmonkey Scripts
// @match       http://orteil.dashnet.org/cookieclicker/
// @match       https://orteil.dashnet.org/cookieclicker/
// @grant       none
// @version     1.0.4
// @author      lordratte
// @description Starts trading indices that have 60 or more ticks stored locally.
// ==/UserScript==

(function(){
  var ram = 25;
  var print = console.log;
  function trade() {
    
    var mgame = Game.Objects.Bank.minigame;
    
    
    Object.keys(Game.Objects.Bank.minigame.goods).forEach(function(building) {
      var vals = mgame.goods[building].vals;

      try {
        if (vals.length < 60) throw new Error();
      } catch(e){return;};

      /*var current = mgame.goods[building].val;*/
      
      var far_average = vals.reduce((a,b)=>a+b, 0)/vals.length;
      var near_average = vals.slice(0,10).reduce((a,b)=>a+b, 0)/vals.slice(0,ram).length;
      
      if (far_average <  near_average) {
        if (mgame.buyGood(mgame.goods[building].id, 10000)) {
          print('Bought: ' + mgame.goods[building].name);
        } else {
          print('Couldn\'t buy: ' + mgame.goods[building].name);

        }
      } else {
        if (mgame.sellGood(mgame.goods[building].id, 10000)) {
          print('Sold: ' + mgame.goods[building].name);
        } else {
          print('Couldn\'t sell: ' + mgame.goods[building].name);
        }
      }
    });
  }
  
  function doLoad() {
    if (window.Game) {
      Game.Objects.Bank.minigame.__old_tick = Game.Objects.Bank.minigame.tick;
      Game.Objects.Bank.minigame.tick = function() {
        this.__old_tick();
        trade();
      }
    } else {
      setTimeout(doLoad, 10000);
    }
  }

  setTimeout(doLoad, 10000);
  
  
  
  
})();

QingJ © 2025

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