NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name GeoGuessr Maps List Enhanced (dreifachpunkt. version) // @namespace dreifachpunkt. // @description openuserjs.org/scripts/kommu/GeoGuessr_Maps_List_Enhanced with changes w.r.t design (so that it fits the league list) + ordering of the maps. // @version 0.0.4.2 // @include https://www.geoguessr.com/* // @run-at document-start // @license MIT // ==/UserScript== /*jshint esversion: 6 */ var oldHref = document.location.href; window.onload = (event) => { mapsBehavior(); var bodyList = document.querySelector("body"), observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (oldHref != document.location.href) { oldHref = document.location.href; mapsBehavior(); } }); }); var config = { childList: true, subtree: true }; observer.observe(bodyList, config); }; function mapsBehavior() { if (!location.pathname.startsWith("/me/maps") || location.pathname.endsWith("#")) { return false; } var style = "table.custom-table {\n" + " border: 1px solid #e2e2e2;\n" + " width: 100%;\n" + " border-collapse: collapse;\n" + " margin-bottom: 40px;\n" + " font-size: 12px;\n" + "}\n" + "\n" + "table.custom-table td, table.custom-table th {\n" + " padding: 5px 10px;\n" + " border: 1px solid #e2e2e2;\n" + "}\n" + "\n" + "table.custom-table th {\n" + " text-transform: uppercase;\n" + " font-size: 10px;\n" + " color: #FCFAF9;\n" + "}\n" + "\n" + "table.custom-table td:nth-child(3) {\n" + " font-size: 10px;\n" + " width: 300px!important;\n" + " max-width: 500px;\n" + " word-break: break-word;\n" + "}\n" + ".table-filter input {\n" + " width: 100%;\n" + "}\n" + ".map-name.visible {\n" + " display: table-row;\n" + "}\n" + ".map-name {\n" + " display: none;\n" + "}\n" + "table.custom-table td:nth-child(1),\n" + "table.custom-table td:nth-child(4),\n" + "table.custom-table td:nth-child(5),\n" + "table.custom-table td:nth-child(6),\n" + "table.custom-table td:nth-child(7) {\n" + " text-align: center;\n" + "}"; var table = "<style>" + style + "</style><div class=\"table-filter\"><input id=\"filter-map-name\" type=\"text\" placeholder=\"Filter on the map name\"></div><table class=\"custom-table\"><tr bgcolor=\"282828\"><th>published</th><th>Name</th><th>Description</th><th>Nb coordinates</th><th>Likes</th><th>Nb games</th><th>Actions</th></tr>"; var current = null; var page = 0; var fulldata = []; var no_data_found = false; while ((current === null || current % 25 === 0) && !no_data_found) { if (current === null) { current = 0; } var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", 'https://www.geoguessr.com/api/v3/profiles/maps?page=' + page + '&count=25', false); xmlhttp.send(); if (xmlhttp.status === 200) { var data = JSON.parse(xmlhttp.responseText); if (data.length > 0) { current = current + data.length; page++; fulldata = fulldata.concat(data); } else { no_data_found = true; } } else { alert('An error occured, while getting maps.'); return false; } } fulldata.sort(function (a, b) { return a.name.localeCompare(b.name); }); table += getHtml(fulldata); table += "</table>"; var div = document.createElement('div'); div.innerHTML = table; var elements = document.getElementsByClassName('container__content'); elements[0].parentNode.insertBefore(div, elements[0]); var rows = document.getElementsByClassName("map-name"); var filter_map_name = document.getElementById("filter-map-name"); filter_map_name.addEventListener('input', function (evt) { var filter_value = filter_map_name.value.toLowerCase(); if (filter_value != "" && filter_value.length > 2) { for (var row_index = 0; row_index < rows.length; row_index++) { if (typeof rows[row_index] != 'undefined') { var text = rows[row_index].getAttribute('mapname'); if (text.includes(filter_value)) { if (!rows[row_index].classList.contains('visible')) { rows[row_index].classList.add("visible"); } } else { if (rows[row_index].classList.contains('visible')) { rows[row_index].classList.remove("visible"); } } } } } else { for (var row_index_2 = 0; row_index_2 < rows.length; row_index_2++) { if (typeof rows[row_index_2] != 'undefined') { if (!rows[row_index_2].classList.contains('visible')) { rows[row_index_2].classList.add("visible"); } } } } }); } function getHtml(data) { var output = ''; //SORT BY PLAYED GAMES data.sort((a, b) => { return b.numFinishedGames - a.numFinishedGames }); //SORT BY AMOUNT OF LOCS /* data.sort((a, b) => { var aCoords = a.coordinateCount, bCoords = b.coordinateCount; if (aCoords.substring(aCoords.length - 1) === "+") { aCoords = aCoords.substring(0, aCoords.length - 1); if (aCoords.substring(aCoords.length - 1) === "K") { aCoords = aCoords.substring(0, aCoords.length - 1).concat("000"); } if (aCoords.substring(aCoords.length - 1) === "M") { aCoords = aCoords.substring(0, aCoords.length - 1).concat("000000"); } } if (bCoords.substring(bCoords.length - 1) === "+") { bCoords = bCoords.substring(0, bCoords.length - 1); if (bCoords.substring(bCoords.length - 1) === "K") { bCoords = bCoords.substring(0, bCoords.length - 1).concat("000"); } if (bCoords.substring(bCoords.length - 1) === "M") { bCoords = bCoords.substring(0, bCoords.length - 1).concat("000000"); } } return bCoords - aCoords; });*/ var tableRow = 0; for (let obj in data) { var map = data[obj]; output += '<tr class="map-name visible" mapname="' + map.name.toLowerCase() + '">' + '<td>' + ((map.published) ? '🟢' : '🔴') + '</td>' + '<td>' + map.name + '</td>' + '<td style="width: 200px">' + map.description + '</td>' + '<td>' + map.coordinateCount + '</td>' + '<td>' + map.likes + '</td>' + '<td>' + map.numFinishedGames + '</td>' + '<td>' + ' <a target="_blank" class="button button--small button--secondary" href="/map-maker/' + map.id + '"><span class="button__animation"></span><span class="button__label">Edit</span></a>' + ' <a target="_blank" class="button button--small button--primary" href="/maps/' + map.id + '"><span class="button__animation"></span><span class="button__label">Open</span></a>' + '</td>' + '</tr>'; } return output; }