World Geography Quiz AutoPlay with Slider

Auto-complete flag game with adjustable interval via slider

当前为 2025-10-02 提交的版本,查看 最新版本

// ==UserScript==
// @name         World Geography Quiz AutoPlay with Slider
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Auto-complete flag game with adjustable interval via slider
// @author       OmniSec
// @match        https://world-geography-games.com/en/*
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // --- Core Auto-Play Function ---
    window.autoPlayFlagQuiz = function() {
        if (typeof buttons !== "undefined" && typeof correct_answer !== "undefined") {
            buttons.forEach(function(btn){
                if (btn.name === correct_answer && can_tap === true) {
                    tap_country(btn);
                }
            });

            if (button_next && button_next.inputEnabled) {
                next_flag();
            }
        }
    }

    window.autoPlayIntervalTime = 500;
    window.autoPlayIntervalID = setInterval(window.autoPlayFlagQuiz, window.autoPlayIntervalTime);

    // --- Stop function ---
    window.stopAutoPlay = function() {
        clearInterval(window.autoPlayIntervalID);
        console.log("Auto-play stopped");
    }

    // --- Create Slider UI ---
    const sliderContainer = document.createElement('div');
    sliderContainer.innerHTML = `
        <label for="autoSpeedSlider" style="color:#000;font-weight:bold;">Auto-Play Speed (ms): </label>
        <input type="range" min="100" max="2000" value="${window.autoPlayIntervalTime}" step="50" id="autoSpeedSlider">
        <span id="sliderValue">${window.autoPlayIntervalTime}</span>
    `;
    sliderContainer.style.position = 'fixed';
    sliderContainer.style.bottom = '10px';
    sliderContainer.style.right = '10px';
    sliderContainer.style.background = '#fff';
    sliderContainer.style.padding = '10px';
    sliderContainer.style.border = '2px solid #000';
    sliderContainer.style.borderRadius = '8px';
    sliderContainer.style.zIndex = '9999';
    document.body.appendChild(sliderContainer);

    const slider = document.getElementById('autoSpeedSlider');
    const sliderValue = document.getElementById('sliderValue');

    slider.addEventListener('input', function() {
        const newInterval = parseInt(slider.value);
        sliderValue.textContent = newInterval;

        clearInterval(window.autoPlayIntervalID);
        window.autoPlayIntervalTime = newInterval;
        window.autoPlayIntervalID = setInterval(window.autoPlayFlagQuiz, window.autoPlayIntervalTime);
    });

})();