Aternos Ultimate Script

Automates removing ad warning, automatically starts the server, confirms queue, and automatically extends the server time when the countdown timer reaches 0:30.

当前为 2024-02-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Aternos Ultimate Script
// @namespace    Mite's Scripts
// @version      1.0.0
// @description  Automates removing ad warning, automatically starts the server, confirms queue, and automatically extends the server time when the countdown timer reaches 0:30.
// @author       Mite
// @match        https://aternos.org/*
// @icon         https://upload.wikimedia.org/wikipedia/commons/thumb/1/10/Userbox_creeper.svg/567px-Userbox_creeper.svg.png
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const extendButtonObserver = new IntersectionObserver(handleIntersection, {
        root: null,
        rootMargin: '0px',
        threshold: 0.1
    });

    function handleIntersection(entries, observer) {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                const extendButton = entry.target;
                if (extendButton.textContent.trim().toLowerCase() !== "stop") {
                    extendButton.click();
                }
                observer.unobserve(extendButton);
            }
        });
    }

    function checkButtonVisibility() {
        const extendButton = document.querySelector('.btn.btn-tiny.btn-success.server-extend-end');
        if (extendButton) {
            extendButtonObserver.observe(extendButton);
        } else {
            console.error('[Aternos Extend Server Time] Button not found.');
        }
    }

    function skipAntiAdblock() {
        try {
            const antiAdblockButtons = document.querySelectorAll(".btn.btn-white");

            for (const button of antiAdblockButtons) {
                if (button.textContent.toLowerCase().includes("continue with adblocker anyway")) {
                    button.click();
                }
            }
        } catch (e) {
            console.error(`[Aternos Auto-Skip Anti-Adblock] There was an error: `, e);
        }
    }

    function startServer() {
        try {
            const startButton = document.querySelector("#start");
            if (startButton) {
                startButton.click();
            } else {
                console.error("[Aternos Auto-Start] 'Start' button not found.");
            }
        } catch (e) {
            console.error("[Aternos Auto-Start] There was an error: ", e);
        }
    }

    // Function to check the timer and click extend button at 0:30
    function checkTimerAndExtend() {
        const timerElement = document.querySelector('.server-end-countdown');
        if (timerElement) {
            const timerValue = timerElement.textContent.trim();
            if (timerValue === '0:30') {
                const extendButton = document.querySelector('.btn.btn-tiny.btn-success.server-extend-end');
                if (extendButton && extendButton.textContent.trim().toLowerCase() !== "stop") {
                    extendButton.click();
                }
            }
        }
    }

    // Function to check for white screen and refresh the page if detected
    function checkForWhiteScreen() {
        const whiteScreenElement = document.querySelector('.white-screen-element');
        if (whiteScreenElement) {
            console.error('[Aternos White Screen] White screen detected. Refreshing page...');
            window.location.reload();
        }
    }

    // Set up intervals to check continuously
    const checkInterval = 1000; // 1 second
    setInterval(checkButtonVisibility, checkInterval);
    setInterval(skipAntiAdblock, checkInterval);
    setInterval(startServer, checkInterval);
    setInterval(checkTimerAndExtend, checkInterval);
    setInterval(checkForWhiteScreen, checkInterval);
})();