puggan icon

CookieMonsterAuto.js

puggan | PRO | 05/02/21 06:48:24 PM UTC (Edited) | 0 ⭐ | 1023 👁️ | Never ⏰ | []
JavaScript |

1.41 KB

|

None

|

0 👍

/

0 👎

window.runPuggan = (() => {
    const upgradesElement = document.getElementById('upgrades');
    for(const upgradeElement of upgradesElement.children) {
        if(+upgradeElement.style.order === 1) {
            if(!upgradeElement.classList.contains('upgrade')) continue;
            const priceElement = upgradeElement.querySelector('.CMBackBlue');
            if(!priceElement) continue;
            if(!upgradeElement.classList.contains('enabled')) return false;
            upgradeElement.click();
            return upgradeElement;
        }
    }
 
    const productsElement = document.getElementById('products');
    for(const productElement of productsElement.children) {
        if(+productElement.style['grid-row-start'] === 2) {
            if(!productElement.classList.contains('product')) continue;
            if(!productElement.classList.contains('unlocked')) return false;
            if(!productElement.classList.contains('enabled')) return false;
 
            const priceElement = productElement.querySelector('.price');
            if(!priceElement) continue;
 
            const isBlue = priceElement.style.color !== 'rgb(0, 255, 0)';
 
            if(!isBlue) {
                const productId = +productElement.id.substr(7);
                const product = Game.ObjectsById[productId];
                const cost = product.bulkPrice;
                if ( cost <= 0 || Game.cookies <= cost * 10) {
                    return false;
                } 
            }
 
 
            productElement.click();
            return productElement;
        }
    }
 
    return null;
});
clearInterval(puggan.auto);
puggan.auto = setInterval(runPuggan, 3000);

Comments