GeoGuessr Return Old Duels UI

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

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         GeoGuessr Return Old Duels UI
// @namespace    http://tampermonkey.net/
// @version      1.0
// @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') {

                    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');
})();