您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a fullscreen mode button to Seterra by GeoGuessr
当前为
- // ==UserScript==
- // @name Seterra (by GeoGuessr) Fullscreen Mode
- // @namespace http://tampermonkey.net/
- // @version 1.1
- // @description Adds a fullscreen mode button to Seterra by GeoGuessr
- // @author TWolf01
- // @license MIT
- // @match https://www.geoguessr.com/vgp/*
- // @match https://www.geoguessr.com/*/vgp/*
- // @icon https://www.geoguessr.com/favicon.ico
- // @run-at document-end
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- const GAME_MAP_SELECTOR = "[class^='game-area_mapWrapper__']";
- const FOOTER_BUTTONS_SELECTOR = "[class^='game-footer_buttons__']";
- const FULLSCREEN_STYLE_CLASS = "custom-fullscreen-style";
- const FULLSCREEN_BUTTON_CLASS = "custom-fullscreen-button";
- function updateStyle(stylesheet, selectors, padding) {
- const content = `${selectors} { padding-left: ${padding}px; padding-right: ${padding}px; }`;
- if (stylesheet) {
- if (!stylesheet.textContent.includes(`padding-left: ${padding}px`)) stylesheet.textContent = content;
- } else {
- const style = document.createElement('style');
- style.className = FULLSCREEN_STYLE_CLASS;
- style.textContent = content;
- document.head.appendChild(style);
- }
- }
- function createFullscreenStyles(gameMap) {
- const heightRatio = (window.screen.height - gameMap.clientHeight) / gameMap.clientHeight;
- const padding = (window.screen.width - (gameMap.clientWidth * (1 + heightRatio))) / 2;
- if (padding > 5 && padding < 100000) {
- const selectors = `
- :fullscreen,
- :fullscreen div[class^='game-header_wrapper'],
- :fullscreen div[class^='corner-image_wrapper'],
- :fullscreen div[class^='game-area_mapWrapper']`;
- updateStyle(document.head.querySelector(`style.${FULLSCREEN_STYLE_CLASS}`), selectors, padding);
- }
- }
- function createFullscreenButton(footerContainer, gameMap) {
- if (footerContainer.querySelector(`.${FULLSCREEN_BUTTON_CLASS}`)) return;
- const button = document.createElement("button");
- button.textContent = "Fullscreen";
- button.className = FULLSCREEN_BUTTON_CLASS;
- Object.assign(button.style, {
- padding: "10px", backgroundColor: "blue", color: "white",
- border: "none", borderRadius: "5px", cursor: "pointer",
- });
- button.addEventListener("click", () => {
- gameMap.requestFullscreen?.() || gameMap.webkitRequestFullscreen?.() || gameMap.msRequestFullscreen?.();
- });
- footerContainer.appendChild(button);
- }
- function initializeFullscreenButton() {
- const gameMap = document.querySelector(GAME_MAP_SELECTOR);
- const footerButtons = document.querySelector(FOOTER_BUTTONS_SELECTOR);
- if (gameMap && footerButtons) {
- createFullscreenStyles(gameMap);
- createFullscreenButton(footerButtons, gameMap);
- }
- }
- new MutationObserver(initializeFullscreenButton).observe(document.body, { childList: true, subtree: true });
- initializeFullscreenButton();
- })();