GeoGuessr Return Old Duels UI

This script returns the old geoguessr duels UI but only in matches.

当前为 2025-04-02 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         GeoGuessr Return Old Duels UI
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  This script returns the old geoguessr duels UI but only in matches.
// @author       AaronThug
// @match        https://www.geoguessr.com/*/multiplayer*
// @match        https://www.geoguessr.com/*
// @run-at       document-end
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function getLanguagePrefix() {
        const url = window.location.pathname;
        const urlParts = url.split('/').filter(part => part.length > 0);

        if (urlParts[0] && urlParts[0].length <= 3 && urlParts[0] !== 'multiplayer') {
            return '/' + urlParts[0];
        }

        return '';
    }

    function handlePlayButtonClick(event) {
        if (!window.location.pathname.includes('/multiplayer')) {
            return;
        }

        let target = event.target;
        let isPlayButton = false;

        while (target && target !== document) {
            if (target.tagName === 'BUTTON') {
                const buttonText = target.textContent.trim();
                if (buttonText === 'Play' || buttonText === 'Spielen' ||
                    buttonText === 'Jouer' || buttonText === 'Jugar' ||
                    buttonText === 'Gioca' || buttonText === 'Spela' ||
                    buttonText === 'プレイ' || buttonText === 'Jogar' ||
                    buttonText === 'Spelen' || buttonText === 'Oyna') {

                    isPlayButton = true;
                    break;
                }
            }
            target = target.parentElement;
        }

       if (isPlayButton) {
            event.preventDefault();
            event.stopPropagation();

           const langPrefix = getLanguagePrefix();

           window.location.href = `https://www.geoguessr.com${langPrefix}/matchmaking`;

            console.log(`GeoGuessr Redirect: detour to ${langPrefix}/matchmaking`);
            return false;
        }
    }

  function setupEventListener() {
        document.addEventListener('click', handlePlayButtonClick, true);
        console.log('GeoGuessr detour: Click Listener installed');
    }

  if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', function() {
            setTimeout(setupEventListener, 500);
        });
    } else {
        setTimeout(setupEventListener, 500);
    }

console.log('GeoGuessr Multiplayer Redirect: Script loaded');
})();