GeoGuessr Return Old Team Duels UI

This script returns the old GeoGuessr Team Duels UI during matches. You need to press "Get old UI" after opponents were found.

// ==UserScript==
// @name         GeoGuessr Return Old Team Duels UI
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  This script returns the old GeoGuessr Team Duels UI during matches. You need to press "Get old UI" after opponents were found.
// @author       AaronThug
// @match        https://www.geoguessr.com/*
// @icon         https://www.geoguessr.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fteam-duels.52be0df6.webp&w=64&q=75
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let windowClosed = false;

    function isOnTeamsPage() {
        const currentPath = window.location.pathname;
        return /\/multiplayer\/teams(\/|$)/.test(currentPath);
    }

    function createOldUIWindow() {
        if (document.getElementById('oldui-helper-window') || windowClosed) return;

        const windowDiv = document.createElement('div');
        windowDiv.id = 'oldui-helper-window';
        windowDiv.style.cssText = `
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            width: 200px;
            background: linear-gradient(135deg, #4a4a7a 0%, #2d2d5a 100%);
            border: 2px solid #5a5a8a;
            border-radius: 12px;
            padding: 12px;
            box-shadow: 0 6px 20px rgba(0,0,0,0.4);
            z-index: 10000;
            font-family: Arial, sans-serif;
            font-size: 12px;
        `;

        const headerDiv = document.createElement('div');
        headerDiv.style.cssText = `
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        `;

        const titleDiv = document.createElement('div');
        titleDiv.textContent = 'Game started? Get old UI.';
        titleDiv.style.cssText = `
            color: #ffffff;
            font-weight: bold;
            font-size: 11px;
        `;

        const closeButton = document.createElement('button');
        closeButton.innerHTML = '×';
        closeButton.id = 'close-button';
        closeButton.style.cssText = `
            background: none;
            border: none;
            color: #ffffff;
            font-size: 18px;
            font-weight: bold;
            cursor: pointer;
            padding: 0;
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0.7;
            transition: opacity 0.2s;
        `;

        closeButton.addEventListener('mouseenter', function() {
            this.style.opacity = '1';
        });
        closeButton.addEventListener('mouseleave', function() {
            this.style.opacity = '0.7';
        });
        closeButton.addEventListener('click', function(e) {
            e.preventDefault();
            e.stopPropagation();
            const win = document.getElementById('oldui-helper-window');
            if (win) win.remove();
            windowClosed = true;
        });

        const button = document.createElement('button');
        button.textContent = 'Get old UI';
        button.id = 'oldui-button';
        button.style.cssText = `
            width: 100%;
            padding: 8px;
            background: linear-gradient(135deg, #7bb347 0%, #6aa136 100%);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 12px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        `;

        button.addEventListener('mouseenter', function() {
            this.style.background = 'linear-gradient(135deg, #8bc653 0%, #7bb347 100%)';
            this.style.transform = 'translateY(-1px)';
        });
        button.addEventListener('mouseleave', function() {
            this.style.background = 'linear-gradient(135deg, #7bb347 0%, #6aa136 100%)';
            this.style.transform = 'translateY(0)';
        });
        button.addEventListener('click', handleOldUIClick);

        headerDiv.appendChild(titleDiv);
        headerDiv.appendChild(closeButton);
        windowDiv.appendChild(headerDiv);
        windowDiv.appendChild(button);
        document.body.appendChild(windowDiv);
    }

    function handleOldUIClick() {
        const button = document.getElementById('oldui-button');
        button.textContent = 'Searching Game ID...';
        button.disabled = true;
        button.style.backgroundColor = '#cccccc';
        setTimeout(() => {
            location.reload();
        }, 500);
    }

    function extractGameId() {
        try {
            const pageSource = document.documentElement.outerHTML;
            const regex = /"ongoingGameId":\s*"([a-f0-9\-]{36})"/i;
            const match = pageSource.match(regex);
            if (match && match[1]) {
                const gameId = match[1];
                window.location.href = `https://www.geoguessr.com/team-duels/${gameId}`;
                return true;
            }
            return false;
        } catch {
            return false;
        }
    }

    function checkForTargetElement() {
        if (!isOnTeamsPage() || windowClosed) return;
        const targetElement = document.querySelector('.team-matchmaking-layout_root__xFn5v');
        if (targetElement && !document.getElementById('oldui-helper-window')) {
            createOldUIWindow();
        }
    }

    function checkForGameIdOnLoad() {
        if (!isOnTeamsPage() || windowClosed) return;
        setTimeout(() => {
            if (extractGameId()) return;
            checkForTargetElement();
        }, 1000);
    }

    let currentUrl = window.location.href;
    function handleUrlChange() {
        if (currentUrl !== window.location.href) {
            currentUrl = window.location.href;
            const oldWindow = document.getElementById('oldui-helper-window');
            if (oldWindow && !isOnTeamsPage()) oldWindow.remove();
            if (isOnTeamsPage() && !windowClosed) setTimeout(checkForTargetElement, 500);
        }
    }

    const observer = new MutationObserver(() => {
        handleUrlChange();
        if (isOnTeamsPage() && !windowClosed) checkForTargetElement();
    });

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

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', checkForGameIdOnLoad);
    } else {
        checkForGameIdOnLoad();
    }

    window.addEventListener('popstate', handleUrlChange);

})();

QingJ © 2025

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