Skip to content

Enhanced Auto Mine no longer working #410

Open

Description

@K0STYURIK

After v0.10.22 update, mining system was overhauled, and Enhanced Auto Mine seems to no longer work. Which is sad, because there are new achievements tied to miming

Activity

  1. aheadfrogg commented on Nov 14, 2024

    @aheadfrogg

    Use the helpers?

  2. K0STYURIK commented on Nov 15, 2024

    @K0STYURIK
    Author

    Use the helpers?

    Helpers aren't automatically using battery (so not upgrading new Oak Item towards "Level all 12 Oak Items to maximum level" achievement).
    Also, helpers using chisel, hammer, bomb and survey tools aren't count towards "Use chisel tool 1000 times", "Use hammer tool 2000 times", "Use bomb tool 5000 times", "Use survey tool 50 times", "Use any tool 10000 times" achievements.
    So, without Enhanced Auto Mine it is near impossible to get 6 achievements.

    Plus, unlike Hatchers and Farm hands, you can only use ONE mine helper at a time. So, even without achievements, using helpers just really SLOWER than using Enhanced Auto Mine

  3. K0STYURIK commented on Dec 7, 2024

    @K0STYURIK
    Author

    Use the helpers?

    I have some helper working in underground mine for a three weeks now (started with Steve and Alex, waited until they are at least at level 50, switched to Gemma, waited until she is at least at level 50, switched to Sharlene, waited until she is at least at level 50, switched to Jones, waited until he is at least at level 50, switched to Darwin, waited until he is lat least at evel 50, switched back to Steve and Alex, and they are currently at level 87), I don't even turn off my computer when I go to work, and my underground mine is still only at level 45. Without "Enhanced Auto Mine" it's borderline impossible to get an achievement "Reach Underground Level 50"

  4. kosmirion-epos commented on Jan 3, 2025

    @kosmirion-epos

    I am also a bit bummed, but I made my own thing, at least kind of. There's a reason the file is called stupidmine.js.

    What this does is it waits 5 seconds on initial load and then spam clicks the first square in the list every 0.1s / 100ms with your selected tool, which in my case is the bomb. This works great as soon as your bomb has unlimited durability.

    I tried several times to integrate this different approach for the new underground system classes into the existing ephenia script, especially to also get interactability, but didn't manage to do it.

    I'm posting my approach in case it helps someone more accustomed to maybe update the script.

            var autoMineTimer;
            
            // Wait a few seconds to not mine before underground is fully loaded
            setTimeout(() => {
                autoMineTimer = setInterval(function () {
                    doAutoMine();
                }, 100);
            }, 5000);
    
            function doAutoMine(){
                UndergroundController.clickModalMineSquare(1);
            }
    

    To activate the battery, the method should be App.game.underground.battery.discharge() (at least that is what's bound to the button).

    If you want to use potions, I think only the part that tries to use them needs to be discarded, as the helpers use them automatically if you have it enabled. Just the buying part would be kept.

  5. CptGryps commented on Jan 12, 2025

    @CptGryps

    I am also a bit bummed, but I made my own thing, at least kind of. There's a reason the file is called stupidmine.js.

    What this does is it waits 5 seconds on initial load and then spam clicks the first square in the list every 0.1s / 100ms with your selected tool, which in my case is the bomb. This works great as soon as your bomb has unlimited durability.

    I tried several times to integrate this different approach for the new underground system classes into the existing ephenia script, especially to also get interactability, but didn't manage to do it.

    I'm posting my approach in case it helps someone more accustomed to maybe update the script.

            var autoMineTimer;
            
            // Wait a few seconds to not mine before underground is fully loaded
            setTimeout(() => {
                autoMineTimer = setInterval(function () {
                    doAutoMine();
                }, 100);
            }, 5000);
    
            function doAutoMine(){
                UndergroundController.clickModalMineSquare(1);
            }
    

    To activate the battery, the method should be App.game.underground.battery.discharge() (at least that is what's bound to the button).

    If you want to use potions, I think only the part that tries to use them needs to be discarded, as the helpers use them automatically if you have it enabled. Just the buying part would be kept.

    You know what, this is perfect for me, so I'll take it. Thank you for sharing!

  6. Ybanca commented on Jan 17, 2025

    @Ybanca

    Hello,
    Does anyone have an alternate script that works ?

  7. KissVeiL commented on Feb 3, 2025

    @KissVeiL

    Hello, Does anyone have an alternate script that works ?

    i think they still dont have the script, I am also waiting hehe

  8. bsegault commented on Feb 20, 2025

    @bsegault

    Hi,

    Based on this thread, I worked on a prototype, here is the script itself. I think it can help to quickly update your underground level.

    Features:

    • Auto mine: first use the bomb, then back to chisel if all items are partially found
    • Auto battery discharge
    • Auto sell: regularly sell all treasures
    • Auto small restore (I basically use the same code, I need to double check this one).

    Limitations:

    • I was not able to test everything yet
    • No control over what to sell. I guess it would be too complicated now that treading is here.
    • It does not handle helpers, you have to do it on your own
    • It is not able to control the frequency of the refresh. I hard-coded it to 0.05 seconds, and it suits my need.
    // ==UserScript==
    // @name          [Pokeclicker] Enhanced Auto Mine
    // @namespace     Pokeclicker Scripts
    // @author        Ephenia (Credit: falcon71, KarmaAlex, umbralOptimatum, Pastaficionado, bsegault)
    // @description   Automatically mines the Underground with Bombs. Features adjustable settings as well.
    // @copyright     https://github.com/Ephenia
    // @license       GPL-3.0 License
    // @version       3.0
    
    // @homepageURL   https://github.com/Ephenia/Pokeclicker-Scripts/
    // @supportURL    https://github.com/Ephenia/Pokeclicker-Scripts/issues
    // @downloadURL   https://raw.githubusercontent.com/Ephenia/Pokeclicker-Scripts/master/enhancedautomine.user.js
    // @updateURL     https://raw.githubusercontent.com/Ephenia/Pokeclicker-Scripts/master/enhancedautomine.user.js
    
    // @match         https://www.pokeclicker.com/
    // @icon          https://www.google.com/s2/favicons?domain=pokeclicker.com
    // @grant         unsafeWindow
    // @run-at        document-idle
    // ==/UserScript==
    
    var mineState;
    var autoSellState;
    var smallRestoreState;
    var setThreshold;
    var autoMineTimer;
    
    function initAutoMine() {
        const minerHTML = document.createElement("div");
        minerHTML.innerHTML = `<div id="auto-miner">
    <button id="auto-mine-start" class="col-12 col-md-2 btn btn-${mineState ? 'success' : 'danger'}">Auto Mine [${mineState ? 'ON' : 'OFF'}]</button>
    <button id="auto-sell-start" class="col-12 col-md-3 btn btn-${autoSellState ? 'success' : 'danger'}">Auto Sell items [${autoSellState ? 'ON' : 'OFF'}]</button>
    <button id="small-restore-start" class="col-12 col-md-3 btn btn-${smallRestoreState ? 'success' : 'danger'}">Auto Small Restore [${smallRestoreState ? 'ON' : 'OFF'}]</button>
    <span class="col-12 col-md-3"><img title="Money" src="assets/images/currency/money.svg" height="25px"> <input title="Value at which to stop buying Small Restores." type="text" id="small-restore"></span>
    </div>`
        document.querySelectorAll('#mineModal .modal-body')[0].prepend(minerHTML);
        $("#auto-mine-start").unwrap();
        document.getElementById('small-restore').value = setThreshold.toLocaleString('en-US');
    
        document.getElementById('auto-mine-start').addEventListener('click', event => { startAutoMine(event); });
        document.getElementById('small-restore-start').addEventListener('click', event => { autoRestore(event); });
        document.getElementById('auto-sell-start').addEventListener('click', event => { autoSell(event); });
    
        document.querySelector('#small-restore').addEventListener('input', event => {
            setThreshold = +event.target.value.replace(/[A-Za-z!@#$%^&*()]/g, '').replace(/[,]/g, "");
            localStorage.setItem("autoBuyThreshold", setThreshold);
            event.target.value = setThreshold.toLocaleString('en-US');
        });
    
        addGlobalStyle('#auto-miner { display:flex;flex-direction:row;flex-wrap:wrap;align-content:center;justify-content:space-evenly;align-items:center; }');
        addGlobalStyle('#small-restore { width:150px; }');
    
        if (mineState) {
            // Wait a few seconds to not mine before underground is fully loaded
            setTimeout(setAutoMineInterval, 5000);
        }
    }
    
    function setAutoMineInterval() {
        autoMineTimer = setInterval(function () {
            doAutoMine();
        }, 50); // Happens every .05 second
    }
    
    function startAutoMine(event) {
        const element = event.target;
        mineState = !mineState
        mineState ? element.classList.replace('btn-danger', 'btn-success') : element.classList.replace('btn-success', 'btn-danger');
        element.textContent = `Auto Mine [${mineState ? 'ON' : 'OFF'}]`;
        if (mineState) {
            setAutoMineInterval();
        } else {
            clearInterval(autoMineTimer)
        }
        localStorage.setItem('autoMineState', mineState);
    }
    
    function doAutoMine() {
        if (Mine.loadingNewLayer) {
            // Do nothing while the new layer is loading
            return;
        }
    
        if(autoSellState) {
            UndergroundItems.list.forEach(i => {
                if(i.hasSellValue()) {
                    UndergroundTrading.sellAmount = player.itemList[i.itemName]();
                    UndergroundTrading.selectedTradeFromItem = i;
                    UndergroundTrading.sell();
                }
            });
        }
    
        if (smallRestoreState) {
            if ((ItemList["SmallRestore"].price() == 30000) && (player.itemList["SmallRestore"]() == 0) && (App.game.wallet.currencies[GameConstants.Currency.money]() >= setThreshold + 30000)) {
                ItemList["SmallRestore"].buy(1);
            }
        }
    
        if(App.game.underground.battery.charges === App.game.underground.battery.maxCharges) {
            App.game.underground.battery.discharge();
        }
        // Use the bomb if not all items have been discovered
        if(App.game.underground.mine._itemsPartiallyFound() < App.game.underground.mine._itemsBuried()) {
            App.game.underground.tools.useTool(2, 1, 0);
        } else {
            // Get all tiles with rewards
            const tilesWithReward = App.game.underground.mine.grid.map((tile, i) => ({...tile, index: i})).filter(tile => tile._reward && !tile._reward.rewarded)
            const uncoveredTileWithReward = tilesWithReward.filter(tile => tile._layerDepth() > 0);
    
            // Use chisel on each tile
            uncoveredTileWithReward.forEach(tile => {
                const {x, y} = App.game.underground.mine.getCoordinateForGridIndex(tile.index);
                App.game.underground.tools.useTool(0, x, y);
            });
        }
    
    }
    
    function autoSell(event) {
        const element = event.target;
        autoSellState = !autoSellState;
        autoSellState ? element.classList.replace('btn-danger', 'btn-success') : element.classList.replace('btn-success', 'btn-danger');
        element.textContent = `Auto Small Restore [${autoSellState ? 'ON' : 'OFF'}]`;
        localStorage.setItem('autoSellState', autoSellState);
    }
    
    function autoRestore(event) {
        const element = event.target;
        smallRestoreState = !smallRestoreState;
        smallRestoreState ? element.classList.replace('btn-danger', 'btn-success') : element.classList.replace('btn-success', 'btn-danger');
        element.textContent = `Auto Small Restore [${smallRestoreState ? 'ON' : 'OFF'}]`;
        localStorage.setItem('autoSmallRestore', smallRestoreState);
    }
    
    if (!validParse(localStorage.getItem('autoMineState'))) {
        localStorage.setItem("autoMineState", false);
    }
    if (!validParse(localStorage.getItem('autoSellState'))) {
        localStorage.setItem("autoSellState", false);
    }
    if (!validParse(localStorage.getItem('autoSmallRestore'))) {
        localStorage.setItem("autoSmallRestore", false);
    }
    if (!validParse(localStorage.getItem('autoBuyThreshold'))) {
        localStorage.setItem("autoBuyThreshold", 0);
    }
    mineState = JSON.parse(localStorage.getItem('autoMineState'));
    autoSellState = JSON.parse(localStorage.getItem('autoSellState'));
    smallRestoreState = JSON.parse(localStorage.getItem('autoSmallRestore'));
    setThreshold = JSON.parse(localStorage.getItem('autoBuyThreshold'));
    
    function validParse(key) {
        try {
            if (key === null) {
                throw new Error;
            }
            JSON.parse(key);
            return true;
        } catch (e) {
            return false;
        }
    }
    
    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }
    
    function loadEpheniaScript(scriptName, initFunction, priorityFunction) {
        function reportScriptError(scriptName, error) {
            console.error(`Error while initializing '${scriptName}' userscript:\n${error}`);
            Notifier.notify({
                type: NotificationConstants.NotificationOption.warning,
                title: scriptName,
                message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`,
                timeout: GameConstants.DAY,
            });
        }
        const windowObject = !App.isUsingClient ? unsafeWindow : window;
        // Inject handlers if they don't exist yet
        if (windowObject.epheniaScriptInitializers === undefined) {
            windowObject.epheniaScriptInitializers = {};
            const oldInit = Preload.hideSplashScreen;
            var hasInitialized = false;
    
            // Initializes scripts once enough of the game has loaded
            Preload.hideSplashScreen = function (...args) {
                var result = oldInit.apply(this, args);
                if (App.game && !hasInitialized) {
                    // Initialize all attached userscripts
                    Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => {
                        try {
                            initFunction();
                        } catch (e) {
                            reportScriptError(scriptName, e);
                        }
                    });
                    hasInitialized = true;
                }
                return result;
            }
        }
    
        // Prevent issues with duplicate script names
        if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) {
            console.warn(`Duplicate '${scriptName}' userscripts found!`);
            Notifier.notify({
                type: NotificationConstants.NotificationOption.warning,
                title: scriptName,
                message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`,
                timeout: GameConstants.DAY,
            });
            let number = 2;
            while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) {
                number++;
            }
            scriptName = `${scriptName} ${number}`;
        }
        // Add initializer for this particular script
        windowObject.epheniaScriptInitializers[scriptName] = initFunction;
        // Run any functions that need to execute before the game starts
        if (priorityFunction) {
            $(document).ready(() => {
                try {
                    priorityFunction();
                } catch (e) {
                    reportScriptError(scriptName, e);
                    // Remove main initialization function
                    windowObject.epheniaScriptInitializers[scriptName] = () => null;
                }
            });
        }
    }
    
    if (!App.isUsingClient || localStorage.getItem('enhancedautomine') === 'true') {
        loadEpheniaScript('enhancedautomine', initAutoMine);
    }
  9. LysisLou-FR commented on Jul 3, 2025

    @LysisLou-FR

    Hello everyone,
    I took the liberty to propose a version of the script Auto Mine compatible with version 0.10.23. This script is relatively simple and probably needs some optimization, but at least it works! It clicks on tiles that contain rewards using all available tools. Combined with automatic mine switching, it's very convenient!
    Bye bye!

    // @name          [Pokeclicker] Enhanced Auto Mine (v0.10.23 compatible)
    // @namespace     Pokeclicker Scripts
    // @version       3.1.1
    // @description   Automatically mines the Underground using bombs, hammer and chisels intelligently.
    // @match         https://www.pokeclicker.com/
    // @grant         unsafeWindow
    // @run-at        document-idle
    // ==/UserScript==
    
    (function () {
        'use strict';
    
        let mineState = JSON.parse(localStorage.getItem('autoMineState') || 'false');
        let autoMineTimer;
    
        function addGlobalStyle(css) {
            const head = document.head || document.getElementsByTagName('head')[0];
            if (!head) return;
            const style = document.createElement('style');
            style.innerHTML = css;
            head.appendChild(style);
        }
    
        function initAutoMine() {
            if (!document.getElementById('auto-mine-start')) {
                const minerHTML = document.createElement("div");
                minerHTML.innerHTML = `
                <div id="auto-miner">
                    <button id="auto-mine-start" class="col-12 col-md-4 btn btn-${mineState ? 'success' : 'danger'}">
                        Auto Mine [${mineState ? 'ON' : 'OFF'}]
                    </button>
                </div>`;
                document.querySelector('#mineModal .modal-body').prepend(minerHTML);
                addGlobalStyle('#auto-miner { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; margin-bottom:10px }');
            }
    
            document.getElementById('auto-mine-start').addEventListener('click', toggleAutoMine);
    
            if (mineState) {
                setTimeout(setAutoMineInterval, 1000);
            }
        }
    
        function toggleAutoMine(event) {
            mineState = !mineState;
            localStorage.setItem('autoMineState', mineState);
            const el = event.target;
            el.classList.toggle('btn-success', mineState);
            el.classList.toggle('btn-danger', !mineState);
            el.textContent = `Auto Mine [${mineState ? 'ON' : 'OFF'}]`;
            mineState ? setAutoMineInterval() : clearInterval(autoMineTimer);
        }
    
        function setAutoMineInterval() {
            clearInterval(autoMineTimer);
            autoMineTimer = setInterval(doAutoMine, 1000);
        }
    
        function doAutoMine() {
            const mine = App.game.underground.mine;
            const tools = App.game.underground.tools;
    
            if (App.game.underground.loadingNewLayer) return;
    
            const battery = App.game.underground.battery;
            if (battery.charges === battery.maxCharges) battery.discharge();
    
            const bomb = tools.getTool(UndergroundToolType.Bomb);
            const hammer = tools.getTool(UndergroundToolType.Hammer);
            const chisel = tools.getTool(UndergroundToolType.Chisel);
            const grid = mine.grid;
    
            if (bomb.durability >= bomb.durabilityPerUse) {
                const targetIndex = grid.findIndex(tile => tile && tile.layerDepth > 0);
                if (targetIndex !== -1) {
                    tools.selectedToolType = UndergroundToolType.Bomb;
                    UndergroundController.clickModalMineSquare(targetIndex);
                    return;
                }
            }
    
            const rewardTiles = grid
                .map((tile, index) => ({ tile, index }))
                .filter(({ tile }) => tile && tile.reward && tile.layerDepth > 0);
    
            if (rewardTiles.length > 0) {
                const target = rewardTiles[Math.floor(Math.random() * rewardTiles.length)];
    
                let toolToUse = null;
                if (hammer.durability >= hammer.durabilityPerUse) {
                    toolToUse = UndergroundToolType.Hammer;
                } else if (chisel.durability >= chisel.durabilityPerUse) {
                    toolToUse = UndergroundToolType.Chisel;
                }
    
                if (toolToUse !== null) {
                    tools.selectedToolType = toolToUse;
                    UndergroundController.clickModalMineSquare(target.index);
                }
            }
        }
    
        function waitForMineModal() {
            const modalCheck = setInterval(() => {
                const modal = document.querySelector('#mineModal .modal-body');
                if (modal && modal.children.length > 0) {
                    clearInterval(modalCheck);
                    initAutoMine();
                }
            }, 500);
        }
    
        function waitForGameLoad() {
            const interval = setInterval(() => {
                if (typeof App !== 'undefined' && App.game?.underground?.mine) {
                    clearInterval(interval);
                    waitForMineModal();
                }
            }, 100);
        }
    
        waitForGameLoad();
    })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions