Geoguessr unrounded games played for popular maps

Display the exact number of played games on maps where this number has been rounded (more than 1000 games played)

当前为 2022-10-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Geoguessr unrounded games played for popular maps
// @version      0.1
// @description  Display the exact number of played games on maps where this number has been rounded (more than 1000 games played)
// @author       victheturtle#5159
// @license      MIT
// @match        https://www.geoguessr.com/*
// @grant        none
// @icon         https://www.google.com/s2/favicons?sz=64&domain=geoguessr.com
// @namespace    https://greasyfork.org/users/967692-victheturtle
// ==/UserScript==

let last_URL = "";
let map_data = {};

function checkRoundedStat() {
    let q = document.querySelectorAll(".map-stats_mapStatMetricValue__UW5ne");
    return q.length >= 2 && (q[1].innerText.includes("M") || q[1].innerText.includes("K"));
};

function addDetailedPlayed() {
    let elt = document.querySelectorAll(".map-stats_mapStatMetricValue__UW5ne")[1];
    let value = map_data.props.pageProps.map.numFinishedGames.toLocaleString();
    elt.innerText = value;
    for (let ms of [100,200,300,400,500]) {
        setTimeout(() => {elt.innerText = value;}, ms);
    }
};

function checkStats() {
    if (map_data.props != null) {
        addDetailedPlayed();
        return;
    }
    let game_url = window.location.href;
    fetch(game_url)
    .then(res => res.text())
    .then(str => {
        let parser = new DOMParser();
        let html = parser.parseFromString(str, "text/html");
        let dataHTML = html.getElementById("__NEXT_DATA__");
        map_data = JSON.parse(dataHTML.innerHTML);
        addDetailedPlayed();
    }).catch(err => {throw(err);});
};

function doCheck() {
    if (location.pathname.startsWith("/maps") && location.pathname != last_URL && checkRoundedStat()) {
        checkStats();
    } else if (location.pathname != last_URL) {
        map_data = {};
    }
    location.pathname != last_URL;
};

function tryAddDetailedPlayedOnRefresh() {
    setTimeout(doCheck, 300);
};

function tryAddDetailedPlayed() {
    for (let timeout of [250,500,1200,2000]) {
        setTimeout(doCheck, timeout);
    }
};

document.addEventListener('click', tryAddDetailedPlayed, false);
document.addEventListener('load', tryAddDetailedPlayedOnRefresh(), false);
window.addEventListener('popstate', tryAddDetailedPlayed, false);