Geoguessr Guess Sound

Plays a sound when you or your opponent guesses in duels

  1. // ==UserScript==
  2. // @name Geoguessr Guess Sound
  3. // @description Plays a sound when you or your opponent guesses in duels
  4. // @version 1.0.2
  5. // @author Tyow#3742
  6. // @match *://*.geoguessr.com/*
  7. // @license MIT
  8. // @namespace https://gf.qytechs.cn/users/1011193
  9. // ==/UserScript==
  10.  
  11. const audio = document.createElement('audio');
  12.  
  13. /* ############################################################################### */
  14. /* ##### DON'T MODIFY ANYTHING ABOVE HERE UNLESS YOU KNOW WHAT YOU ARE DOING ##### */
  15. /* ############################################################################### */
  16.  
  17. audio.volume = 1; // Can be replaced by any number between 0 and 1
  18.  
  19. // The below can be replaced by any link that goes directly to an mp3 file, to change the sound played on join
  20. audio.src = "https://www.dropbox.com/scl/fi/bsp7jcylwl7b9iuvn80ge/A-Tone-His_Self-1266414414.mp3?rlkey=07w27nj2u6j77nmiwvwpiurin&dl=1"
  21.  
  22. let userGuess = false; // controls whether you hear the sound when you guess first.
  23. // change 'false' to 'true' to hear a sound when you guess first
  24.  
  25. /* ############################################################################### */
  26. /* ##### DON'T MODIFY ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ##### */
  27. /* ############################################################################### */
  28.  
  29. audio.id = "guessSoundAudioPlayer";
  30. audio.preload = 'auto';
  31.  
  32.  
  33. const addAudio = () => {
  34. document.body.appendChild(audio);
  35. }
  36.  
  37. const playSound = () => {
  38. audio.play();
  39. }
  40.  
  41. /*
  42. * When the timer element becomes visible
  43. * If sound has not been played yet
  44. * This will check if the guess was from the user or not
  45. * Then it will check if "userGuess" is true, and play sound accordingly
  46. */
  47.  
  48. let played = false;
  49.  
  50. const checkTeamDuels = () => {
  51. if (!location.pathname.startsWith("/team-duels")) return false;
  52.  
  53. const chatmsgs = document.querySelectorAll("[class^=chat-message_sharedRoot__]");
  54.  
  55. for (const m of chatmsgs) {
  56. let isHidden = false; // Initialize the isHidden flag
  57. let isSystem = false;
  58.  
  59. m.classList.forEach(c => {
  60. if (c.startsWith("chat-message_systemMessageRoot__")) {
  61. isSystem = true;
  62. isHidden = m.classList.contains("chat-message_isHidden__FnZCR"); // Check if the element has the hidden class
  63. }
  64. });
  65.  
  66. if (isHidden === false && isSystem) {
  67. return true;
  68. }
  69. }
  70.  
  71. return false;
  72. }
  73.  
  74. const checkStatus = () => {
  75. if (!(location.pathname.startsWith("/duels") || location.pathname.startsWith("/team-duels"))) {
  76. return;
  77. }
  78. let timer = document.querySelector("[class^='clock-timer_timerContainer__']");
  79. let stress = document.querySelector("[class^='stress-indicator_container__']");
  80. if ((timer !== null) && !played && (userGuess ? true : (stress !== null || checkTeamDuels()))) {
  81. addAudio();
  82. playSound();
  83. played = true;
  84. } else if (timer == null) {
  85. played = false;
  86. }
  87. }
  88.  
  89. // For testing
  90.  
  91. //document.addEventListener('mousedown', () => {
  92. // addAudio();
  93. // playSound();
  94. //});
  95.  
  96. new MutationObserver(async (mutations) => {
  97. checkStatus();
  98. }).observe(document.body, { subtree: true, childList: true });

QingJ © 2025

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