Hotkey zoom for GeoGuessr

Zoom in on 'v' and out on 'x', works for both map and game. Only tested on chrome.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Hotkey zoom for GeoGuessr
// @namespace    http://tampermonkey.net/
// @version      2024-03-09
// @description  Zoom in on 'v' and out on 'x', works for both map and game. Only tested on chrome.
// @author       github.com/hallunbaek
// @match        https://www.geoguessr.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=geoguessr.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var event;

    document.addEventListener('mousemove', e => {
        event = e;
    }, {passive: true});

    var interval;

    const scroller = (up) => {
        if (interval) window.clearInterval(interval);
        interval = window.setInterval(() => {
            event.initEvent('wheel', true, true);
            event.deltaY = up ? 1 : -1;
            document.elementFromPoint(event.clientX, event.clientY).dispatchEvent(event);
        }, 10);
    };

    window.addEventListener('keydown', (e) => {
        if (e.key == "x"){
            scroller(true);
        } else if (e.key == "v"){
            scroller(false);
        }
    });

    window.addEventListener('keyup', () => window.clearInterval(interval));
})();