Greasy Fork镜像 还支持 简体中文。

AutoDarts Freundesliste mit Online-Status (Lobby/Match)

Überwacht den Online-Status von Freunden nur auf Lobby- und Match-Seiten.

目前為 2025-01-27 提交的版本,檢視 最新版本

// ==UserScript==
// @name         AutoDarts Freundesliste mit Online-Status (Lobby/Match)
// @namespace    Owl
// @version      3.4
// @description  Überwacht den Online-Status von Freunden nur auf Lobby- und Match-Seiten.
// @match        https://play.autodarts.io/lobbies
// @match        https://play.autodarts.io/matches
// @run-at       document-idle
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Setup initial data
    let friendList = JSON.parse(localStorage.getItem('friendList')) || [];
    let infoDiv = null;
    let popupContainer = null;
    let isMinimized = false;
    let isDragging = false;
    let offsetX, offsetY;

    // Speichern der Freundesliste im LocalStorage
    function saveFriendList() {
        localStorage.setItem('friendList', JSON.stringify(friendList));
    }

    // Anzeigen einer Info-Nachricht im Browser
    function showInfo(message) {
        if (!infoDiv) {
            infoDiv = document.createElement('div');
            infoDiv.style.position = 'fixed';
            infoDiv.style.top = '0';
            infoDiv.style.left = '0';
            infoDiv.style.width = '100%';
            infoDiv.style.backgroundColor = 'blue';
            infoDiv.style.color = 'white';
            infoDiv.style.padding = '10px';
            infoDiv.style.textAlign = 'center';
            infoDiv.style.zIndex = '999999';
            document.body.appendChild(infoDiv);
        }
        infoDiv.textContent = message;
        setTimeout(() => infoDiv.remove(), 25000); // Nachricht nach 25 Sekunden entfernen
    }

    // Popup für Freundesliste erstellen
    function createPopup() {
        if (popupContainer) return;

        popupContainer = document.createElement('div');
        popupContainer.id = 'autodarts-friendlist-popup';
        popupContainer.style.position = 'fixed';
        popupContainer.style.top = '50%';
        popupContainer.style.left = '50%';
        popupContainer.style.transform = 'translate(-50%, -50%)';
        popupContainer.style.padding = '20px';
        popupContainer.style.backgroundColor = '#1A202C';
        popupContainer.style.color = '#E2E8F0';
        popupContainer.style.border = '1px solid #2D3748';
        popupContainer.style.borderRadius = '8px';
        popupContainer.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
        popupContainer.style.zIndex = '999999';

        // Schließen-Button
        const closeButton = document.createElement('button');
        closeButton.textContent = '×';
        closeButton.style.position = 'absolute';
        closeButton.style.top = '4px';
        closeButton.style.right = '8px';
        closeButton.style.background = 'transparent';
        closeButton.style.border = 'none';
        closeButton.style.color = '#E2E8F0';
        closeButton.style.fontSize = '20px';
        closeButton.style.cursor = 'pointer';
        closeButton.addEventListener('click', () => togglePopup(false));
        popupContainer.appendChild(closeButton);

        // Minimieren-Button
        const minimizeButton = document.createElement('button');
        minimizeButton.textContent = '-';
        minimizeButton.style.position = 'absolute';
        minimizeButton.style.top = '4px';
        minimizeButton.style.right = '40px';
        minimizeButton.style.background = 'transparent';
        minimizeButton.style.border = 'none';
        minimizeButton.style.color = '#E2E8F0';
        minimizeButton.style.fontSize = '20px';
        minimizeButton.style.cursor = 'pointer';
        minimizeButton.addEventListener('click', toggleMinimize);
        popupContainer.appendChild(minimizeButton);

        const inputWrapper = document.createElement('div');
        inputWrapper.style.display = 'flex';
        inputWrapper.style.marginBottom = '10px';
        popupContainer.appendChild(inputWrapper);

        const inputName = document.createElement('input');
        inputName.type = 'text';
        inputName.placeholder = 'Spielername';
        inputName.style.flex = '1';
        inputName.style.marginRight = '5px';
        inputName.style.padding = '4px 8px';
        inputWrapper.appendChild(inputName);

        const inputBoardId = document.createElement('input');
        inputBoardId.type = 'text';
        inputBoardId.placeholder = 'Board ID';
        inputBoardId.style.flex = '1';
        inputBoardId.style.marginRight = '5px';
        inputBoardId.style.padding = '4px 8px';
        inputWrapper.appendChild(inputBoardId);

        const addButton = document.createElement('button');
        addButton.textContent = 'Hinzufügen';
        addButton.style.padding = '4px 8px';
        addButton.style.cursor = 'pointer';
        addButton.style.backgroundColor = 'rgba(59, 182, 43, 1)';
        addButton.style.color = '#fff';
        addButton.style.border = 'none';
        addButton.style.borderRadius = '4px';
        inputWrapper.appendChild(addButton);

        // Liste der Freunde
        const listElement = document.createElement('ul');
        listElement.style.listStyle = 'none';
        listElement.style.paddingLeft = '0';
        popupContainer.appendChild(listElement);

        // Freund hinzufügen
        function addFriend() {
            const name = inputName.value.trim();
            const boardId = inputBoardId.value.trim();
            if (name && boardId) {
                friendList.push({ name: name.toUpperCase(), boardId, online: false });
                saveFriendList();
                updateList(listElement);
            }
            inputName.value = '';
            inputBoardId.value = '';
        }

        addButton.addEventListener('click', addFriend);
        inputName.addEventListener('keydown', (e) => {
            if (e.key === 'Enter') {
                e.preventDefault();
                addFriend();
            }
        });

        // Freunde-Liste anzeigen
        updateList(listElement);
        document.body.appendChild(popupContainer);
    }

    // Minimieren des Popups
    function toggleMinimize() {
        isMinimized = !isMinimized;
        popupContainer.style.width = isMinimized ? '150px' : 'auto';
        popupContainer.style.height = isMinimized ? '50px' : 'auto';
        popupContainer.style.transform = isMinimized ? 'translate(0%, -10%)' : 'translate(-50%, -50%)';
    }

    // Freundesliste aktualisieren
    function updateList(listElement) {
        listElement.innerHTML = '';
        friendList.forEach(friend => {
            const li = document.createElement('li');
            li.textContent = friend.name;
            li.style.color = friend.online ? 'green' : 'gray';
            listElement.appendChild(li);
        });
    }

    // Popup an/aus schalten
    function togglePopup(isVisible) {
        if (popupContainer) {
            popupContainer.style.display = isVisible ? 'block' : 'none';
        }
    }

    // Spielerstatus überprüfen (nur in Lobbies und Matches)
    function checkPlayers() {
        // Überprüfen auf der aktuellen Seite (Lobbies oder Matches)
        const page = window.location.pathname;

        // Wenn die Seite 'lobbies' oder 'matches' ist, suche nach den Spielern
        if (page.includes('lobbies') || page.includes('matches')) {
            const playerTags = document.querySelectorAll('p.chakra-text.css-0');
            let onlineNames = [];

            playerTags.forEach(tag => {
                const name = tag.textContent.trim().toUpperCase();
                const friend = friendList.find(item => item.name === name);
                if (friend) {
                    tag.style.backgroundColor = 'blue';  // Markieren von Online-Spielern
                    tag.style.color = 'white';
                    friend.online = true;
                    onlineNames.push(name);
                } else {
                    tag.style.backgroundColor = '';
                    tag.style.color = '';
                }
            });

            // Anzeige einer Info-Nachricht, wenn Online-Spieler gefunden werden
            if (onlineNames.length > 0) {
                showInfo(`Online: ${onlineNames.join(', ')}`);
            }

            // Freundesliste aktualisieren
            updateFriendStatus(onlineNames);
        }
    }

    // Online-Status der Freunde aktualisieren
    function updateFriendStatus(onlineNames) {
        friendList.forEach(friend => {
            friend.online = onlineNames.includes(friend.name.toUpperCase());
        });
        saveFriendList();
    }

    // Periodisches Überprüfen der Spieler alle 5 Sekunden (nur Lobby und Match)
    setInterval(checkPlayers, 5000);

    // Freundesliste im Menü anzeigen
    function addFriendlistMenu() {
        const menuContainer = document.querySelector('div.chakra-stack');
        if (menuContainer) {
            const menuItem = document.createElement('a');
            menuItem.textContent = 'Freundesliste';
            menuItem.style.cursor = 'pointer';
            menuItem.addEventListener('click', () => togglePopup(true));
            menuContainer.appendChild(menuItem);
        }
    }

    // Menü hinzufügen
    setInterval(addFriendlistMenu, 1000);
})();

QingJ © 2025

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