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-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         Sun vs Moon Auto Click (For Sun)
// @namespace    http://tampermonkey.net/
// @version      3.1.2 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) {
        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 a persistent label at the top-left corner with author name
    function addAuthorLabel() {
        let authorLabel = document.getElementById("author-label");
        if (!authorLabel) {
            authorLabel = document.createElement("div");
            authorLabel.id = "author-label";
            authorLabel.textContent = "Made by Lav1nRulez";
            authorLabel.style.position = "fixed";
            authorLabel.style.bottom = "10px";
            authorLabel.style.left = "10px";
            authorLabel.style.padding = "5px 10px";
            authorLabel.style.backgroundColor = "rgba(0, 0, 0, 0.7)";
            authorLabel.style.color = "white";
            authorLabel.style.fontSize = "12px";
            authorLabel.style.borderRadius = "5px";
            authorLabel.style.zIndex = "1000";
            document.body.appendChild(authorLabel);
        }
    }

    // Run the author label function to display it immediately
    addAuthorLabel();

    // Add event listener for keydown events
    document.addEventListener('keydown', function(event) {
        if (event.key === 'S' || event.key === 's') {
            if (!clickInterval) {
                clickInterval = setInterval(() => {
                    const sunButton = document.getElementById("sun-btn");
                    if (sunButton) {
                        sunButton.click();
                    }
                }, 1);  // 1 millisecond interval
                showMessage("Autoclicker Started");
            }
        } else if (event.key === 'M' || event.key === 'm') {
            if (clickInterval) {
                clearInterval(clickInterval);
                clickInterval = null;
                showMessage("Autoclicker Stopped");
            }
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址