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 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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
            }
        }
    });
})();