site nightcafe - Claim Button Clicker

Automatically clicks the claim button on NightCafe

当前为 2024-07-16 提交的版本,查看 最新版本

// ==UserScript==
// @name         site nightcafe - Claim Button Clicker
// @namespace    http://greasyfork.org
// @version      2024.07.16.2311
// @description  Automatically clicks the claim button on NightCafe
// @author       hg42
// @license      MIT
// @match        https://creator.nightcafe.studio/*claim*
// @grant        none
// @run-at       document-end
// @require      http://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    const checkInterval = 3; // hour
    const interval = checkInterval / 3;

    function clickClaimButton() {
        const claimButton = $("button:has(:contains('Claim'))");
        if (claimButton) {
            claimButton.click();
            console.log("Claim button clicked!");
        } else {
            console.log("Claim button not found.");
        }
    }

    function check() {
        const now = new Date();
        const lastCheck = localStorage.getItem('lastCheck');

        if (lastCheck) {
            //const lastCheckDate = new Date(lastCheck);
            //const hoursDiff = (now - lastCheckDate) / (60 * 60 * 1000);

            //if (hoursDiff >= checkInterval) {
                clickClaimButton();
                localStorage.setItem('lastCheck', now);
            //} else {
            //    console.log(`Last check was ${hoursDiff} hours ago. Checking again in 3 hours.`);
            //}
        } else {
            clickClaimButton();
            localStorage.setItem('lastCheck', now);
        }

        setInterval(check, interval * 60 * 60 * 1000);
    }

    setInterval(check, 10000);
})();