Greasy Fork

Greasy Fork is available in English.

🤖IMYAI网站点击按钮快速每日签到 Daily Sign-in Automation in IMYAI

每天只需点击一个按钮即可签到 Automate daily sign-in with a click of a button

当前为 2023-12-12 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         🤖IMYAI网站点击按钮快速每日签到 Daily Sign-in Automation in IMYAI
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  每天只需点击一个按钮即可签到 Automate daily sign-in with a click of a button
// @author       GPT4.0
// @match        https://ai.imyai.top/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to simulate a mouse click
    function simulateClick(element) {
        const mouseClickEvents = ['mousedown', 'click', 'mouseup'];
        mouseClickEvents.forEach(mouseEventType =>
            element.dispatchEvent(
                new MouseEvent(mouseEventType, {
                    view: window,
                    bubbles: true,
                    cancelable: true,
                    buttons: 1
                })
            )
        );
    }

    // Function to add the new button to the page
    function addButton() {
        const newButton = document.createElement('button');
        newButton.innerText = '快速签到';
        // Add styles to make the button orange and prominent
        newButton.style.cssText = `
            position: fixed;
            top: 10px;
            left: 10px;
            z-index: 10000;
            padding: 10px 20px;
            background-color: orange;
            color: white;
            border: none;
            border-radius: 5px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            font-weight: bold;
            cursor: pointer;
            transition: background-color 0.3s, box-shadow 0.3s;
        `;

        newButton.onclick = function() {
            // Query for the first sign-in button
            const firstSignInButton = document.querySelector('svg.iconify--noto');
            if (firstSignInButton) {
                simulateClick(firstSignInButton);
            }

            // Check for the second button and the close button every half second
            const checkExist = setInterval(function() {
                const secondSignInButton = document.querySelector('div.flex.mt-3.w-full.mt-14 > button.n-button--info-type');
                const closeButton = document.querySelector('.n-base-close.n-base-close--absolute.n-card-header__close'); // This selects the close button using the classes provided
                if (secondSignInButton) {
                    simulateClick(secondSignInButton);
                    // Wait for half a second before attempting to click the close button
                    setTimeout(() => {
                        if (closeButton) {
                            simulateClick(closeButton);
                        }
                    }, 500);
                    clearInterval(checkExist); // Stop checking once the button has been clicked
                }
            }, 500); // Check every 500ms
        };

        document.body.appendChild(newButton);
    }

    // Add the button after the DOM is fully loaded
    if (document.readyState === 'complete') {
        addButton();
    } else {
        window.addEventListener('load', addButton);
    }
})();