Aternos Auto Bot

Auto-clicks Start/Confirm with toggle button showing icon + "Auto Start On/Off" with color indicator

当前为 2025-06-24 提交的版本,查看 最新版本

// ==UserScript==
// @name         Aternos Auto Bot
// @version      0.7.1
// @description  Auto-clicks Start/Confirm with toggle button showing icon + "Auto Start On/Off" with color indicator
// @author       zuki
// @match        https://aternos.org/server/*
// @grant        none
// @namespace https://gf.qytechs.cn/users/1484866
// ==/UserScript==

let BotON = localStorage.getItem('aternosAutoBotON') === 'true'
let IsRunning = false

const observer = new MutationObserver(() => {
    const StartButton = document.querySelector('div#start')
    if (StartButton && StartButton.parentElement && !document.getElementById('autostart-toggle')) {
        const AutoButton = StartButton.cloneNode(true)
        AutoButton.id = "autostart-toggle"
        AutoButton.querySelector("i")?.remove()
        AutoButton.innerHTML = BotON
            ? '<i class="fa-solid fa-repeat"></i> Auto Start On'
            : '<i class="fa-solid fa-repeat"></i> Auto Start Off'
        AutoButton.style.backgroundColor = BotON ? '' : '#e3214b'
        AutoButton.style.transition = 'none'
        AutoButton.style.margin = '0'

        AutoButton.addEventListener("click", () => {
            BotON = !BotON
            localStorage.setItem('aternosAutoBotON', BotON)
            AutoButton.innerHTML = BotON
                ? '<i class="fa-solid fa-repeat"></i> Auto Start On'
                : '<i class="fa-solid fa-repeat"></i> Auto Start Off'
            AutoButton.style.transition = 'none'
            AutoButton.style.backgroundColor = BotON ? '' : '#e3214b'
        })

        StartButton.parentElement.appendChild(AutoButton)
        startTheServer()
    }
})

observer.observe(document.body, { childList: true, subtree: true })

function startTheServer() {
    if (BotON) {
        setTimeout(() => {
            antiBanCheckIfUnused()
            setTimeout(() => {
                if (IsRunning) {
                    document.querySelector('div#confirm')?.click()
                    document.querySelector('div#start')?.click()
                }
                startTheServer()
            }, 200)
        }, 900)
    } else {
        setTimeout(startTheServer, 1000)
    }
}

function antiBanCheckIfUnused() {
    const Online = document.getElementsByClassName('status online')
    const Loading = document.getElementsByClassName('status loading')
    const Starting = document.getElementsByClassName('status loading starting')
    IsRunning = !(Online.length || Loading.length || Starting.length)
}

QingJ © 2025

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