Geoguessr Better Menu

Adds a menu bar to Geoguessr's new UI

当前为 2022-12-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Geoguessr Better Menu
  3. // @namespace https://gf.qytechs.cn/en/users/997484-aimee4737
  4. // @version 1.1
  5. // @description Adds a menu bar to Geoguessr's new UI
  6. // @author aimee
  7. // @match https://www.geoguessr.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=geoguessr.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. window.addEventListener('load', function() {
  14.  
  15. // also shows ongoing games, activities, my maps, and liked maps in menu bar
  16. // change to false if you only want singleplayer, competitive, party, and quiz
  17. const showProfileLinks = true
  18.  
  19. const headers = document.getElementsByTagName("header")
  20. const header = headers[0]
  21. const divs = header.getElementsByTagName("div")
  22. let menu
  23.  
  24. const url = window.location.href
  25.  
  26. // header is different on home page
  27. if (url == "https://www.geoguessr.com/"){
  28. menu = divs[1]
  29. } else {
  30. menu = divs[19]
  31. }
  32.  
  33. menu.style.display = "flex"
  34.  
  35. let html
  36.  
  37. const start = `<div class="slanted-wrapper_root__2eaEs slanted-wrapper_variantGrayTransparent__aufaF">
  38. <div class="slanted-wrapper_start__Kl7rv slanted-wrapper_right__G0JWR"></div>
  39. <div class="page-label_labelWrapper__o1vpe">
  40. <div class="label_sizeXSmall__mFnrR">`
  41.  
  42. const end = `</div></div><div class="slanted-wrapper_end__cD1Qu slanted-wrapper_right__G0JWR"></div></div>`
  43.  
  44. const singlePlayer = start + `<a href="/singleplayer" style="color:white">Singleplayer</a>` + end
  45. const competitive = start + `<a href="/competitive" style="color:white">Competitive</a>` + end
  46. const party = start + `<a href="/play-with-friends" style="color:white">Party</a>` + end
  47. const quiz = start + `<a href="/quiz" style="color:white">Quiz</a>` + end
  48.  
  49. if (showProfileLinks == true) {
  50. const ongoing = start + `<a href="/me/current" style="color:white">Ongoing Games</a>` + end
  51. const activities = start + `<a href="/me/activities" style="color:white">Activities</a>` + end
  52. const myMaps = start + `<a href="/me/maps" style="color:white">My Maps</a>` + end
  53. const likedMaps = start + `<a href="/me/likes" style="color:white">Liked Maps</a>` + end
  54. html = singlePlayer + competitive + party + quiz + ongoing + activities + myMaps + likedMaps
  55. } else {
  56. html = singlePlayer + competitive + party + quiz
  57. }
  58.  
  59. const newItems = document.createElement("div")
  60. newItems.innerHTML = html
  61. newItems.style.display = "flex"
  62. menu.prepend(newItems) // keeping the original labels fixes issues with "crashes" links on pages are clicked
  63.  
  64. const menuItems = menu.getElementsByClassName("slanted-wrapper_root__2eaEs")
  65. if (menuItems.length == 9) {
  66. menuItems[8].style.display = "none"
  67. }
  68.  
  69. const menuLinks = menu.getElementsByClassName("label_sizeXSmall__mFnrR")
  70.  
  71. // shows active page
  72. for (let i=0; i<8; i++) {
  73. let links = menuLinks[i].getElementsByTagName("a")
  74. if (links == null) continue
  75. let link = links[0]
  76. if (link == null) continue
  77. if (link.href == url) {
  78. link.style.color = ""
  79. menuItems[i].className = "slanted-wrapper_root__2eaEs slanted-wrapper_variantWhite__VKHvw"
  80. break
  81. } else {
  82. link.style.color = "white"
  83. menuItems[i].className = "slanted-wrapper_root__2eaEs slanted-wrapper_variantGrayTransparent__aufaF"
  84. }
  85. }
  86.  
  87. }, false);
  88.  
  89.  

QingJ © 2025

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