Sun vs Moon Auto Click (Switchable)

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

目前為 2024-11-04 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Sun vs Moon Auto Click (Switchable)
// @namespace    http://tampermonkey.net/
// @version      3.2.1Beta
// @description  Automatically clicks either the Sun or Moon Button on pressing "S" and Stops Clicking on 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
    let targetButtonId = "sun-btn"; // Default to "Sun" button

    // Function to display on-screen messages with color customization
    function showMessage(text, color) {
        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.color = "white";
            messageDiv.style.fontSize = "16px";
            messageDiv.style.borderRadius = "5px";
            messageDiv.style.zIndex = "1000";
            document.body.appendChild(messageDiv);
        }

        // Set the text, background color, and display the message
        messageDiv.textContent = text;
        messageDiv.style.backgroundColor = color;
        messageDiv.style.display = "block";

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

    // Function to toggle the target button between "sun-btn" and "moon-btn"
    function toggleTargetButton() {
        targetButtonId = targetButtonId === "sun-btn" ? "moon-btn" : "sun-btn";
        toggleButton.textContent = `Switch to ${targetButtonId === "sun-btn" ? "Moon Clicker" : "Sun Clicker"}`;

        // Show message with orange for Sun and blue for Moon
        const targetColor = targetButtonId === "sun-btn" ? "orange" : "blue";
        showMessage(`Now targeting ${targetButtonId === "sun-btn" ? "Sun" : "Moon"}`, targetColor);
    }

    // Add a toggle button at the top-right corner
    let toggleButton = document.createElement("button");
    toggleButton.id = "toggle-button";
    toggleButton.textContent = "Switch to Moon Clicker";
    toggleButton.style.position = "fixed";
    toggleButton.style.top = "10px";
    toggleButton.style.right = "10px";
    toggleButton.style.padding = "10px 15px";
    toggleButton.style.backgroundColor = "#333";
    toggleButton.style.color = "white";
    toggleButton.style.fontSize = "14px";
    toggleButton.style.border = "none";
    toggleButton.style.borderRadius = "5px";
    toggleButton.style.cursor = "pointer";
    toggleButton.style.zIndex = "1000";
    toggleButton.addEventListener("click", toggleTargetButton);
    document.body.appendChild(toggleButton);

    // Add a persistent label at the bottom-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 targetButton = document.getElementById(targetButtonId);
                    if (targetButton) {
                        targetButton.click();
                    }
                }, 1); // 1 millisecond interval
                showMessage("Autoclicker Started", "green"); // Green for start
            }
        } else if (event.key === 'M' || event.key === 'm') {
            if (clickInterval) {
                clearInterval(clickInterval);
                clickInterval = null;
                showMessage("Autoclicker Stopped", "red"); // Red for stop
            }
        }
    });
})();

QingJ © 2025

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