// ==UserScript==
// @name Complete Explorer Mode
// @namespace http://tampermonkey.net/
// @version 2.0
// @description Improve your list and map in explorer mode with old official maps (Vietnam and Türkiye (duplicate)).
// @license MIT
// @author Ice-Dodo
// @match *://*.geoguessr.com/*
// @icon https://www.google.com/s2/favicons?domain=geoguessr.com
// @grant GM_xmlhttpRequest
// @downloadURL https://update.greasyfork.icu/scripts/472784/Complete%20Explorer%20Mode.user.js
// @updateURL https://update.greasyfork.icu/scripts/472784/Complete%20Explorer%20Mode.meta.js
// ==/UserScript==
(function() {
const collectors = [
{
"name": "Vietnam",
"id": "vietnam",
"pathId": "country-vn",
"flag": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Flag_of_Vietnam.svg/800px-Flag_of_Vietnam.svg.png?20170626140925"
},
{
"name": "Türkiye (duplicate)",
"id": "turkiye",
"pathId": "country-tr",
"flag": "data:image/svg+xml;charset=utf-8,%3Csvg%20width%3D%2221%22%20height%3D%2215%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cdefs%3E%3ClinearGradient%20x1%3D%2250%25%22%20y1%3D%220%25%22%20x2%3D%2250%25%22%20y2%3D%22100%25%22%20id%3D%22a%22%3E%3Cstop%20stop-color%3D%22%23FFF%22%20offset%3D%220%25%22%2F%3E%3Cstop%20stop-color%3D%22%23F0F0F0%22%20offset%3D%22100%25%22%2F%3E%3C%2FlinearGradient%3E%3ClinearGradient%20x1%3D%2250%25%22%20y1%3D%220%25%22%20x2%3D%2250%25%22%20y2%3D%22100%25%22%20id%3D%22b%22%3E%3Cstop%20stop-color%3D%22%23E92434%22%20offset%3D%220%25%22%2F%3E%3Cstop%20stop-color%3D%22%23E11324%22%20offset%3D%22100%25%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20fill%3D%22url(%23a)%22%20d%3D%22M0%200h21v15H0z%22%2F%3E%3Cpath%20fill%3D%22url(%23b)%22%20d%3D%22M0%200h21v15H0z%22%2F%3E%3Cpath%20d%3D%22M13.052%204.737A3.907%203.907%200%200%200%2010.75%204C8.679%204%207%205.567%207%207.5S8.679%2011%2010.75%2011c.868%200%201.667-.275%202.302-.737a4.5%204.5%200%201%201%200-5.526Zm1.214%203.34-.919%201.113.063-1.442-1.343-.53%201.39-.386.09-1.441.796%201.204%201.398-.361-.898%201.13.775%201.217-1.352-.505Z%22%20fill%3D%22url(%23a)%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"
}
];
const medals = {
"Bronze": "https://www.geoguessr.com/_next/static/media/medal-bronze.aab227dc.svg",
"Silver": "https://www.geoguessr.com/_next/static/media/medal-silver.f0eb62e1.svg",
"Gold": "https://www.geoguessr.com/_next/static/media/medal-gold.ffccc427.svg",
"Platinum": "https://www.geoguessr.com/_next/static/media/medal-platinum.37cd72ca.svg"
}
const colors = {
"Bronze": "#A66C69",
"Silver": "#C0C0BF",
"Gold": "#EFFE00",
"Platinum": "#EFFE00"
}
const colorsSupp = {
"Bronze": "#ee9055",
"Silver": "#999",
"Gold": "var(--color-yellow-50)",
"Platinum": "var(--color-yellow-50)",
"None": "#e5dcce"
}
const svgContent = `
`;
const supp = ["country-ae", "country-fo", "country-lu", "country-ad", "country-sm", "country-gu", "country-mp", "country-cw", "country-as", "country-cx", "country-vi"];
var classNamePath = "";
new MutationObserver(async (mutations) => {
if(document.getElementById("complete") == null){
if(window.location.href.split("/").indexOf("fr") >= 0){
var pts = "points";
var labels = ["Médaille", "Meilleur score"];
}else{
var pts = "pts";
var labels = ["Medal", "Best score"];
}
if(window.location.href.split("/").indexOf("explorer") >= 0){
var map = document.querySelector("[class^=world-map_worldMap__]");
var oldPaths = document.getElementsByTagName("path");
var collection = {};
var collectionClass = {};
for(elt of oldPaths){
collection[elt.id] = elt.getAttribute("fill");
if(elt.className.baseVal.length > 0){
collectionClass[elt.id] = elt.className.baseVal;
classNamePath = elt.className.baseVal;
}else{
collectionClass[elt.id] = "none";
}
}
map.innerHTML = svgContent;
var paths = document.getElementsByTagName("path");
for(elt of paths){
elt.id = "country-"+elt.id.toLowerCase();
if(collectionClass[elt.id] != null){
elt.classList.add(collectionClass[elt.id]);
if(collectionClass[elt.id] != "none"){
elt.addEventListener("click", (event) => {
document.location.href = document.location.href.replace("explorer", "maps/"+event.target.getAttribute("title").toLowerCase().replaceAll(" ", "-"));
});
}
}else{
elt.classList.add("none");
}
if(collection[elt.id] != null){
elt.setAttribute("fill", collection[elt.id]);
}else{
elt.setAttribute("fill", "rgba(255, 255, 255, 0.2)");
}
elt.style.stroke = "rgba(0, 0, 0, 0.1)";
elt.style.strokeWidth = "1px";
}
document.getElementsByTagName("svg")[0].setAttribute("viewBox", "105 45 796 580");
var title = document.createElement("tr");
title.className = "table__row table__row--header";
title.innerHTML = `
Collectors | `;
title.id = "complete";
var container = document.querySelector("tbody");
container.prepend(title);
try {
var userId = document.getElementById("__NEXT_DATA__").innerHTML.split('"userId":"')[1].split('"')[0];
GM_xmlhttpRequest({
method: "GET",
url: "https://www.geoguessr.com/api/v3/explorer/user/"+userId,
onload: function(response) {
var result = JSON.parse(response.responseText);
for(let elt of supp){
var p = document.getElementById(elt);
let name = p.getAttribute("title").toLowerCase().replaceAll(" ", "-");
if(result[name] != null){
p.setAttribute("fill", colorsSupp[result[name].medal]);
p.addEventListener("click", (event) => {
document.location.href = document.location.href.replace("explorer", "maps/"+name);
});
p.classList.add(classNamePath);
}else{
p.setAttribute("fill", colorsSupp["None"]);
p.addEventListener("click", (event) => {
document.location.href = document.location.href.replace("explorer", "maps/"+name);
});
p.classList.add(classNamePath);
}
}
for(let e of collectors){
var row = document.createElement("tr");
row.className = "table__row";
if(result[e.id] != null){
var medalid = result[e.id].medal.toLowerCase();
var score = result[e.id].bestScore;
if(result[e.id].medal == "Platinum"){
var medal = `
`;
}else{
var medal = `
`;
}
}else{
var score = "—";
var medal = "";
var medalid = "";
pts = "";
}
row.innerHTML = ` `+e.name+` | `+medal+` | `+score+` `+pts+` |
`;
container.insertBefore(row, document.getElementsByClassName("table__row--header")[1]);
if(result[e.id] != null){
document.getElementById(e.pathId).style.stroke = colors[result[e.id].medal];
}
document.getElementById(e.pathId).style.strokeWidth = "1.5px";
}
var space = document.createElement("tr");
space.className = "table__spacing-row";
container.insertBefore(space, document.getElementsByClassName("table__row--header")[1]);
}
});
}
catch (err) {
console.log(err);
}
}else if(document.querySelector("[class^=profile-header_accountInfoWrapper__]") != null && document.querySelector("[class^=profile-header_accountInfoWrapper__]").id != "complete"){
document.querySelector("[class^=profile-header_accountInfoWrapper__]").id = "complete";
var map = document.querySelector("[class^=world-map_worldMap__]");
var oldPaths = document.getElementsByTagName("path");
var collection = {};
var collectionClass = {};
for(elt of oldPaths){
if(elt.id.length > 0){
collection[elt.id] = elt.getAttribute("fill");
if(elt.className.baseVal.length > 0){
collectionClass[elt.id] = elt.className.baseVal;
classNamePath = elt.className.baseVal;
}else{
collectionClass[elt.id] = "none";
}
}
}
map.innerHTML = svgContent;
var paths = document.getElementsByTagName("path");
for(elt of paths){
elt.id = "country-"+elt.id.toLowerCase();
if(collectionClass[elt.id] != null){
elt.classList.add(collectionClass[elt.id]);
if(collectionClass[elt.id] != "none"){
elt.addEventListener("click", (event) => {
document.location.href = document.location.href.slice(0, document.location.href.length - 29) + "maps/"+event.target.getAttribute("title").toLowerCase().replaceAll(" ", "-");
});
}
}else{
elt.classList.add("none");
}
if(collection[elt.id] != null){
if(collection[elt.id] == "url(#silver-gradient)"){
elt.setAttribute("fill", colorsSupp["Silver"]);
}else{
elt.setAttribute("fill", collection[elt.id]);
}
}else{
elt.setAttribute("fill", "rgba(255, 255, 255, 0.2)");
}
elt.style.stroke = "rgba(0, 0, 0, 0.1)";
elt.style.strokeWidth = "1px";
}
document.getElementsByTagName("svg")[0].setAttribute("viewBox", "105 45 796 580");
GM_xmlhttpRequest({
method: "GET",
url: "https://www.geoguessr.com/api/v3/explorer/user/"+window.location.href.split("/")[window.location.href.split("/").length-1],
onload: function(response) {
var result = JSON.parse(response.responseText);
for(let elt of supp){
var p = document.getElementById(elt);
let name = p.getAttribute("title").toLowerCase().replaceAll(" ", "-");
if(result[name] != null){
p.setAttribute("fill", colorsSupp[result[name].medal]);
p.addEventListener("click", (event) => {
document.location.href = document.location.href.slice(0, document.location.href.length - 29) + "maps/"+name;
});
p.classList.add(classNamePath);
}else{
p.setAttribute("fill", colorsSupp["None"]);
p.addEventListener("click", (event) => {
document.location.href = document.location.href.slice(0, document.location.href.length - 29) + "maps/"+name;
});
p.classList.add(classNamePath);
}
}
for(let e of collectors){
if(result[e.id] != null){
document.getElementById(e.pathId).style.stroke = colors[result[e.id].medal];
}
document.getElementById(e.pathId).style.strokeWidth = "1.5px";
}
}
});
}
}
}).observe(document.body, { subtree: true, childList: true });
})();