GeoGuessr Return Old Team Duels UI

This script returns the old GeoGuessr Team Duels UI but only when on the teams page.

当前为 2025-05-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GeoGuessr Return Old Team Duels UI
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description This script returns the old GeoGuessr Team Duels UI but only when on the teams page.
  6. // @author AaronThug
  7. // @match https://www.geoguessr.com/*
  8. // @icon https://www.geoguessr.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fteam-duels.52be0df6.webp&w=64&q=75
  9. // @grant none
  10. // @run-at document-end
  11. // @license MIT
  12. // ==/UserScript==
  13. (function() {
  14. 'use strict';
  15. const modifiedButtons = new Set();
  16. let observerActive = false;
  17. const playButtonLabels = {
  18. 'English': 'Play',
  19. 'Deutsch': 'Spielen',
  20. 'Español': 'Jugar',
  21. 'Français': 'Jouer',
  22. 'Italiano': 'Gioca',
  23. 'Nederlands': 'Spelen',
  24. 'Português': 'Jogar',
  25. 'Svenska': 'Spela',
  26. 'Türkçe': 'Oyna',
  27. '日本語': 'プレイ',
  28. 'Polski': 'Graj'
  29. };
  30. function modifyPlayButton() {
  31. if (!window.location.href.includes('/multiplayer/teams')) {
  32. return;
  33. }
  34. const playButtons = document.querySelectorAll('button.button_button__aR6_e.button_variantPrimary__u3WzI');
  35. playButtons.forEach(button => {
  36. if (modifiedButtons.has(button)) {
  37. return;
  38. }
  39. const buttonText = button.querySelector('.button_label__ERkjz');
  40. if (buttonText && Object.values(playButtonLabels).includes(buttonText.textContent)) {
  41. modifiedButtons.add(button);
  42. const newButton = button.cloneNode(true);
  43. button.parentNode.replaceChild(newButton, button);
  44. newButton.addEventListener('click', handlePlayButtonClick, true);
  45. modifiedButtons.add(newButton);
  46. }
  47. });
  48. }
  49. function handlePlayButtonClick(e) {
  50. e.preventDefault();
  51. e.stopPropagation();
  52. const avatarContainer = document.querySelector('#planet-anchor-container > div.team-section_avatarContainer__bHGNz');
  53. if (!avatarContainer) {
  54. redirectToDefault();
  55. return;
  56. }
  57. const friendContainer = avatarContainer.querySelector('div > div.team-avatars_friendContainer__29kpm');
  58. if (!friendContainer) {
  59. redirectToDefault();
  60. return;
  61. }
  62. const canvas = friendContainer.querySelector('canvas.team-avatars_friend__ITCMj');
  63. if (!canvas) {
  64. redirectToDefault();
  65. return;
  66. }
  67. const userId = canvas.id.split('_local')[0];
  68. if (!userId) {
  69. redirectToDefault();
  70. return;
  71. }
  72. window.location.href = `https://www.geoguessr.com/matchmaking?id=${userId}`;
  73. }
  74. function redirectToDefault() {
  75. window.location.href = 'https://www.geoguessr.com/multiplayer/teams';
  76. }
  77. function setupObserver() {
  78. if (observerActive) {
  79. return;
  80. }
  81. observerActive = true;
  82. const observer = new MutationObserver(function(mutations) {
  83. if (!window.location.href.includes('/multiplayer/teams')) {
  84. return;
  85. }
  86. const hasNewNodes = mutations.some(mutation =>
  87. mutation.type === 'childList' && mutation.addedNodes.length > 0
  88. );
  89. if (hasNewNodes) {
  90. modifyPlayButton();
  91. }
  92. });
  93. observer.observe(document.body, {
  94. childList: true,
  95. subtree: true
  96. });
  97. }
  98. function init() {
  99. modifyPlayButton();
  100. setupObserver();
  101. }
  102. if (document.readyState === 'loading') {
  103. document.addEventListener('DOMContentLoaded', init);
  104. } else {
  105. init();
  106. }
  107. })();