Sun vs Moon Auto Click (For Sun)

Automatically clicks the Sun Button on pressing "S" and Stops Clicking when pressing "M" on https://neal.fun/sun-vs-moon/

当前为 2024-11-03 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Sun vs Moon Auto Click (For Sun)
// @namespace    http://tampermonkey.net/
// @version      3.0 Beta
// @description  Automatically clicks the Sun Button on pressing "S" and Stops Clicking when pressing "M" on https://neal.fun/sun-vs-moon/
// @author       Lav1nRulez
// @match        https://neal.fun/sun-vs-moon/
// @grant        none
// @icon         https://i.ibb.co/QXR89nv/2024-11-03-0z1-Kleki.png
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let clickInterval; // Variable to store the interval ID

    // Function to display on-screen messages
    function showMessage(text) {
        // Check if a message div already exists, if not create it
        let messageDiv = document.getElementById("autoclicker-message");
        if (!messageDiv) {
            messageDiv = document.createElement("div");
            messageDiv.id = "autoclicker-message";
            messageDiv.style.position = "fixed";
            messageDiv.style.bottom = "20px";
            messageDiv.style.right = "20px";
            messageDiv.style.padding = "10px 20px";
            messageDiv.style.backgroundColor = "rgba(0, 0, 0, 0.7)";
            messageDiv.style.color = "white";
            messageDiv.style.fontSize = "16px";
            messageDiv.style.borderRadius = "5px";
            messageDiv.style.zIndex = "1000";
            document.body.appendChild(messageDiv);
        }
        
        // Set the text and display the message
        messageDiv.textContent = text;
        messageDiv.style.display = "block";

        // Hide the message after 2 seconds
        setTimeout(() => {
            messageDiv.style.display = "none";
        }, 2000);
    }

    // Add event listener for keydown events
    document.addEventListener('keydown', function(event) {
        if (event.key === 'S' || event.key === 's') {
            // If "S" is pressed, start the auto-clicker
            if (!clickInterval) {  // Only start if it's not already running
                clickInterval = setInterval(() => {
                    const sunButton = document.getElementById("sun-btn");
                    if (sunButton) {
                        sunButton.click();
                    }
                }, 1);  // 1 millisecond interval
                showMessage("Autoclicker Started"); // Show on-screen message
            }
        } else if (event.key === 'M' || event.key === 'm') {
            // If "M" is pressed, stop the auto-clicker
            if (clickInterval) {
                clearInterval(clickInterval);  // Clear the interval
                clickInterval = null;  // Reset the interval variable
                showMessage("Autoclicker Stopped"); // Show on-screen message
            }
        }
    });
})();