Advertisement
puggan

CookieMonsterAuto.js

May 2nd, 2021 (edited)
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.runPuggan = (() => {
  2.     const upgradesElement = document.getElementById('upgrades');
  3.     for(const upgradeElement of upgradesElement.children) {
  4.         if(+upgradeElement.style.order === 1) {
  5.             if(!upgradeElement.classList.contains('upgrade')) continue;
  6.             const priceElement = upgradeElement.querySelector('.CMBackBlue');
  7.             if(!priceElement) continue;
  8.             if(!upgradeElement.classList.contains('enabled')) return false;
  9.             upgradeElement.click();
  10.             return upgradeElement;
  11.         }
  12.     }
  13.  
  14.     const productsElement = document.getElementById('products');
  15.     for(const productElement of productsElement.children) {
  16.         if(+productElement.style['grid-row-start'] === 2) {
  17.             if(!productElement.classList.contains('product')) continue;
  18.             if(!productElement.classList.contains('unlocked')) return false;
  19.             if(!productElement.classList.contains('enabled')) return false;
  20.  
  21.             const priceElement = productElement.querySelector('.price');
  22.             if(!priceElement) continue;
  23.  
  24.             const isBlue = priceElement.style.color !== 'rgb(0, 255, 0)';
  25.  
  26.             if(!isBlue) {
  27.                 const productId = +productElement.id.substr(7);
  28.                 const product = Game.ObjectsById[productId];
  29.                 const cost = product.bulkPrice;
  30.                 if ( cost <= 0 || Game.cookies <= cost * 10) {
  31.                     return false;
  32.                 }
  33.             }
  34.  
  35.  
  36.             productElement.click();
  37.             return productElement;
  38.         }
  39.     }
  40.  
  41.     return null;
  42. });
  43. clearInterval(puggan.auto);
  44. puggan.auto = setInterval(runPuggan, 3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement