Real Loc Count

Gives the precise number of locations a GeoGuessr map has on its map page.

  1. // ==UserScript==
  2. // @name Real Loc Count
  3. // @namespace https://www.geoguessr.com/
  4. // @version 0.5
  5. // @description Gives the precise number of locations a GeoGuessr map has on its map page.
  6. // @author Wmtmky
  7. // @match http*://www.geoguessr.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=geoguessr.com
  9. // ==/UserScript==
  10.  
  11. // ===== SETTINGS ===== //
  12. // feel free to change these and Ctrl+S to save
  13.  
  14. const number_display_format = "en-CA"
  15. /* try "en-US" for 1,234,567
  16. ** try "de-DE" for 1.234.567
  17. ** try "fr-FR" for 1 234 567
  18. ** try "de-CH" for 1'234'567
  19. ** try "en-IN" for 12,34,567
  20. ** leave as "" for 1234567 (no formatting)
  21. or use the ISO 639-1 code for your own language!
  22. */
  23.  
  24. const do_rounding = false
  25. /* rounds numbers above 10000
  26. ** to the nearest hundred or thousand
  27. ** when set to true
  28. */
  29.  
  30. const try_collect_coins_on_page_load = false
  31. /* tries to collect shop coins when
  32. ** page is initially opened or reloaded
  33. */
  34.  
  35. const locClassName = "map-stats_mapStatMetricValue___sEAC"
  36. /* the name of the class of the HTML div
  37. ** that contains the text for a map's location count
  38. ** -- this needs to be updated when geoguessr redoes their UI
  39. */
  40.  
  41. // ======= MAIN ======= //
  42.  
  43. const API_SEARCH = "https://www.geoguessr.com/api/v3/search/map?q=";
  44. const delay_ms = 1000;
  45.  
  46. // this stupid but so is the inability to detect URL changes
  47. let i_URL = undefined;
  48. setInterval(function () {
  49. let f_URL = window.location.href;
  50. if (f_URL != i_URL) {
  51. i_URL = f_URL;
  52. let a_URL = f_URL.split("/")
  53. if (a_URL[a_URL.length - 2] == "maps") {
  54. getLocCount(a_URL[a_URL.length - 1]);
  55. }
  56. }
  57. }, delay_ms);
  58.  
  59. // why does geoguessr only show loc counts in the search api
  60. async function getLocCount(mapID) {
  61. const response = await fetch(API_SEARCH + mapID);
  62. const responseArray = await response.json();
  63. for (let result of responseArray) {
  64. if (result.id == mapID) {
  65. updateDisplay(result.coordinateCount);
  66. return;
  67. }
  68. }
  69. }
  70.  
  71. // formatting pain
  72. function updateDisplay(realLocCount) {
  73. const locCountDisplay = document.getElementsByClassName(locClassName)[2];
  74. if (do_rounding && realLocCount > 10000) {
  75. let places = realLocCount.toString().length - 4;
  76. if (places == 1) places++;
  77. if (places % 3 == 1) places--;
  78. realLocCount = Math.round(realLocCount / (10 ** places)) * (10 ** places);
  79. }
  80. if (/[a-z]/gi.test(number_display_format)) {
  81. realLocCount = realLocCount.toLocaleString(number_display_format)
  82. }
  83. locCountDisplay.innerText = realLocCount;
  84. }
  85.  
  86. // does anyone use these
  87. if (try_collect_coins_on_page_load) {
  88. fetch("https://www.geoguessr.com/api/v4/webshop/daily-shop-claim", {
  89. method: 'POST',
  90. headers: {
  91. 'Accept': 'application/json',
  92. 'Content-Type': 'application/json'
  93. },
  94. body: JSON.stringify({})
  95. });
  96. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址