// ==UserScript== // @name Geoguessr Team Duels Advanced Options // @description Adds extra options to team duel settings. // @version 0.1.1 // @author macca#8949 // @license MIT // @match https://www.geoguessr.com/* // @run-at document-start // @grant none // @namespace https://greasyfork.org/en/scripts/452579-geoguessr-team-duels-advanced-options // @downloadURL none // ==/UserScript== const getGameId = () => { return window.location.href.split('/')[4]; } window.modifySetting = (e, settingName) => { let newValue = e.value; if (settingName === 'multiplierIncrement') { newValue *= 10; newValue = Math.round(newValue); } // Fetch the game options fetch(`https://game-server.geoguessr.com/api/lobby/${getGameId()}/join`, { "headers": { "accept": "*/*", "accept-language": "en-US,en;q=0.8", "content-type": "application/json", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site", "sec-gpc": "1", "x-client": "web" }, "referrer": "https://www.geoguessr.com/", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{}", "method": "POST", "mode": "cors", "credentials": "include" }).then((response) => response.json()) .then((data) => { let gameOptions = data.gameOptions; gameOptions[settingName] = newValue; fetch(`https://game-server.geoguessr.com/api/lobby/${getGameId()}/options`, { "headers": { "accept": "*/*", "accept-language": "en-US,en;q=0.8", "content-type": "application/json", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site", "sec-gpc": "1", "x-client": "web" }, "referrer": "https://www.geoguessr.com/", "referrerPolicy": "strict-origin-when-cross-origin", "body": JSON.stringify(gameOptions), "method": "PUT", "mode": "cors", "credentials": "include" }); }); } let observer = new MutationObserver((mutations) => { if (document.querySelector('.game-options_lives__wNSwd') && window.location.href.includes('team-duels')) { let healthElement = document.querySelector('.game-options_lives__wNSwd').parentElement; healthElement.innerHTML = `
`; healthElement.style = "display: flex; flex-direction: column; align-items: center; justify-content: center;"; let multiplierIncrementBox = document.createElement('label'); multiplierIncrementBox.className = "game-options_option__eCz9o game-options_editableOption__Mpvar"; multiplierIncrementBox.innerHTML = ` `; multiplierIncrementBox.style = "display: flex; flex-direction: column; align-items: center; justify-content: center;"; let multiplierBox = document.querySelector('img[alt="damage multiplier icon"]').parentNode.parentNode; multiplierBox.parentNode.insertBefore(multiplierIncrementBox, multiplierBox.nextSibling); // Make inputs readonly if not host if (!document.querySelector('.lobby_discardButton__e3luy')) { document.querySelector('#health-input').readOnly = true; document.querySelector('#increment-input').readOnly = true; } fetch(`https://game-server.geoguessr.com/api/lobby/${getGameId()}/join`, { "headers": { "accept": "*/*", "accept-language": "en-US,en;q=0.8", "content-type": "application/json", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site", "sec-gpc": "1", "x-client": "web" }, "referrer": "https://www.geoguessr.com/", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{}", "method": "POST", "mode": "cors", "credentials": "include" }).then((response) => response.json()) .then((data) => { document.querySelector('#health-input').value = data.gameOptions.initialHealth; document.querySelector('#increment-input').value = data.gameOptions.multiplierIncrement / 10; }); } }); observer.observe(document.body, { characterDataOldValue: false, subtree: true, childList: true, characterData: false });