Play.hosting Auto-Queue

" Just auto clicks Start Queue and Server so... Enjoy! "

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name         Play.hosting Auto-Queue
// @namespace    http://tampermonkey.net
// @version      6.1
// @description  " Just auto clicks Start Queue and Server so... Enjoy! "
// @author       Farhat (Discord: ~~Farhat#9879 or agent666_0~~ NEW Discord: agent6660)
// @match        *://*.play.hosting/*
// @grant        none
// @run-at       document-idle
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const CONFIG = {
        refreshMs: 15000,
        checkInterval: 1500,
        btnJoin: "join queue",
        backupText: "restoring from backup"
    };

    let reloadTimer = null;

    // Generates a success audio notification
    function playSuccessSound() {
        const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
        [0, 200, 400].forEach(delay => {
            setTimeout(() => {
                const osc = audioCtx.createOscillator();
                const gain = audioCtx.createGain();
                osc.connect(gain); gain.connect(audioCtx.destination);
                osc.type = 'sine'; osc.frequency.setValueAtTime(1000, audioCtx.currentTime);
                gain.gain.setValueAtTime(0.05, audioCtx.currentTime);
                osc.start(); osc.stop(audioCtx.currentTime + 0.1);
            }, delay);
        });
    }

    // Updates status text in the UI
    function updateStatus(text, color = "#aaa") {
        const el = document.getElementById('tm-bot-status');
        if (el) {
            el.innerText = text;
            el.style.color = color;
        }
    }

    // Creates the floating settings menu
    function createUI() {
        if (document.getElementById('tm-main-menu')) return;
        const container = document.createElement('div');
        container.id = 'tm-main-menu';
        container.style = "position:fixed;top:10px;right:10px;z-index:99999;background:#111;color:#fff;border:1px solid #444;border-radius:8px;font-family:sans-serif;font-size:12px;overflow:hidden;transition:0.3s;width:40px;height:40px;box-shadow:0 4px 15px rgba(0,0,0,0.8);";

        const header = document.createElement('div');
        header.innerHTML = '⚙️ <span style="margin-left:10px;display:none;" id="tm-title">BOT CONTROL</span>';
        header.style = "padding:12px;cursor:pointer;display:flex;align-items:center;font-weight:bold;background:#1a1a1a;border-bottom:1px solid #333;";

        const content = document.createElement('div');
        content.id = 'tm-content';
        content.style = "padding:10px;display:none;flex-direction:column;gap:8px;";

        const status = document.createElement('div');
        status.id = 'tm-bot-status';
        status.innerText = 'IDLE';
        status.style = "font-size:10px;text-transform:uppercase;margin-bottom:5px;border-bottom:1px solid #222;padding-bottom:5px;color:#aaa;";

        const wrapper = document.createElement('label');
        wrapper.style = "display:flex;align-items:center;justify-content:space-between;cursor:pointer;";
        const text = document.createElement('span'); text.innerText = "AUTO JOIN";
        const input = document.createElement('input'); input.type = 'checkbox';
        input.checked = localStorage.getItem('autoJoinEnabled') === 'true';
        input.onchange = (e) => localStorage.setItem('autoJoinEnabled', e.target.checked);
        wrapper.appendChild(text); wrapper.appendChild(input);

        content.appendChild(status);
        content.appendChild(wrapper);
        container.appendChild(header); container.appendChild(content);

        container.onmouseenter = () => { container.style.width = '180px'; container.style.height = 'auto'; content.style.display = 'flex'; document.getElementById('tm-title').style.display = 'inline'; };
        container.onmouseleave = () => { container.style.width = '40px'; container.style.height = '40px'; content.style.display = 'none'; document.getElementById('tm-title').style.display = 'none'; };
        document.body.appendChild(container);
    }

    // Main logic execution
    function run() {
        if (localStorage.getItem('autoJoinEnabled') !== 'true') {
            updateStatus("DISABLED");
            return;
        }

        const pageText = document.body.innerText.toLowerCase();
        const allButtons = Array.from(document.querySelectorAll('button'));

        // Case 1: Backup in progress
        if (pageText.includes(CONFIG.backupText)) {
            updateStatus("RESTORING...", "#ff9800");
            if (!reloadTimer) {
                reloadTimer = setTimeout(() => window.location.reload(), CONFIG.refreshMs);
            }
            return;
        }

        // Case 2: Join button available
        const joinBtn = allButtons.find(btn => btn.innerText.trim().toLowerCase() === CONFIG.btnJoin && !btn.disabled);
        if (joinBtn) {
            updateStatus("JOINING...", "#4caf50");
            joinBtn.click();
            playSuccessSound();
            if (reloadTimer) { clearTimeout(reloadTimer); reloadTimer = null; }
            return;
        }

        updateStatus("SCANNING...", "#aaa");
    }

    setInterval(() => {
        createUI();
        run();
    }, CONFIG.checkInterval);
})();