Main Menu Button on Duels

Adds the Main Menu button back to the Duels Summary Screen

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Main Menu Button on Duels
// @version      1.0.0
// @description  Adds the Main Menu button back to the Duels Summary Screen
// @match        https://www.geoguessr.com/*
// @author       Tyow#3742
// @grant        none
// @license      MIT
// @namespace    https://greasyfork.org/en/users/1011193-tyow
// ==/UserScript==

function checkURL() {
    return location.pathname.startsWith("/duels") && location.pathname.endsWith("/summary")
};

let menuButton = document.createElement('a');
menuButton.classList.add("button_button__CnARx");
menuButton.classList.add("button_variantSecondary__lSxsR");
menuButton.href = "https://www.geoguessr.com/competitive";
menuButton.style.marginLeft = "15px";

let buttonWrapper = document.createElement('div');
buttonWrapper.classList.add("button_wrapper__NkcHZ");

let text = document.createElement('span');
text.classList.add("button_label__kpJrA");
text.innerHTML = "Main Menu";

buttonWrapper.appendChild(text);
menuButton.appendChild(buttonWrapper);


function doCheck() {
    let play = document.querySelector('button[class*="button_button__CnARx button_variantPrimary__xc8Hp"]');
    if (play) {
        play.parentElement.appendChild(menuButton);
    }
};

let lastDoCheckCall = 0;
new MutationObserver(async (mutations) => {
    if (!checkURL() || lastDoCheckCall >= (Date.now() - 50)) return;
    lastDoCheckCall = Date.now();
    doCheck();
}).observe(document.body, { subtree: true, childList: true });