DelugeRPG Auto Battler!

Automates trainer battles using a move with your lead Pokémon (set as shiny mega houndoom, using water spout as lead for mine :D).

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name DelugeRPG Auto Battler!
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Automates trainer battles using a move with your lead Pokémon (set as shiny mega houndoom, using water spout as lead for mine :D).
// @match https://www.delugerpg.com/battle/*
// @icon https://www.delugerpg.com/images/items/pokeball.png
// @grant none
// ==/UserScript==
// DISCLAIMER: YOU MAY GET BANNED FOR THIS, USE AT YOUR OWN DISCRETION.
(function() {
    'use strict';
    const intervalTime = 1500; // interval between each action - keep 1500 as minimum!

    setInterval(() => {
        // Priority 0: CAPTCHA "Return to Game" button - auto checks the 'not a robot' captcha
        const captchaReturnBtn = document.querySelector('input.btn.btn-primary[type="submit"][name="clickhere"][value="Return to Game"]');
        if (captchaReturnBtn) {
            captchaReturnBtn.click();
            return;
        }

        // Priority 1: Initial "Start Battle" button
        const startBattleBtn = document.querySelector('input.btn-battle_action[type="submit"][name="Start Battle"][value="Start Battle"]');
        if (startBattleBtn) {
            startBattleBtn.click();
            return;
        }

        // Priority 2: Notify continue/repeat buttons after full battle win (try Repeat first)
        let notifyBtn = document.querySelector("#battle > div.notify_done > a.btn.btn-primary");
        if (notifyBtn) {
            notifyBtn.click();
            return;
        }
        notifyBtn = document.querySelector("#battle > div.notify_done > a.btn.btn-default");
        if (notifyBtn) {
            notifyBtn.click();
            return;
        }
        notifyBtn = document.querySelector("#battle > div.notify_done > a:nth-child(5)");
        if (notifyBtn) {
            notifyBtn.click();
            return;
        }

        // Priority 3: Battle "Continue" after all enemy Pokémon faint
        const battleContinueBtn = document.querySelector('input.btn-battle_action[type="submit"][name="continue_"][value=" Continue "]');
        if (battleContinueBtn) {
            battleContinueBtn.click();
            return;
        }

        // Priority 4: "Skip Pokemon Selection" after single enemy faint
        const skipBtn = document.querySelector('input.btn-battle_action[type="submit"][name="skip_"][value=" Skip Pokemon Selection "]');
        if (skipBtn) {
            skipBtn.click();
            return;
        }

        // Priority 5: "Continue" button after handling single enemy faint (when Continue was clicked instead of Skip)
        const postFaintContinueBtn = document.querySelector('input.btn-battle_action[type="submit"][name="Continue"][value="Continue"]');
        if (postFaintContinueBtn) {
            postFaintContinueBtn.click();
            return;
        }

        // Priority 6: "Normal Battle", "Repeat", or "Fight this trainer again." on trainer dashboard (win/loss) - battles the trainer again in a normal battle
        const battleBtns = document.querySelectorAll('a.btn.btn-primary[href*="/battle/trainer/"]');
        for (let btn of battleBtns) {
            const text = btn.textContent.trim();
            if (text === 'Normal Battle' ||
                text.includes('Normal Battle') ||
                text === 'Repeat' ||
                text.includes('Repeat') ||
                text === 'Fight this trainer again.' ||
                text.includes('Fight this trainer again')) {
                btn.click();
                return;
            }
        }

        // Priority 7: Pokémon selection/start (first option, no modal open)
        if (!document.querySelector(".modal-open")) {
            const pokeStartBtn = document.querySelector("#attack > div.cardif > form > div.buttoncenter > input:nth-child(1)");
            if (pokeStartBtn) {
                pokeStartBtn.click();
                return;
            }
        }

        // Priority 8: "Attack" button to enter move selection
        const attackBtn = document.querySelector('input.btn-battle_action[type="submit"][name="attack_"]');
        if (attackBtn) {
            attackBtn.click();
            return;
        }

        // Priority 9: move used - change as per your head move.
        const waterSpoutBtn = document.querySelector('#battle > form > div.center > input[value="Water Spout"]');
        if (waterSpoutBtn) {
            waterSpoutBtn.click();
            return;
        }
    }, intervalTime);
})();