Greasy Fork is available in English.

致美化签到

全自动静默签到,每 8 小时执行 1 次(错时补签),通过桌面通知反馈签到状态。

// ==UserScript==
// @name         致美化签到
// @author       Cairl
// @description  全自动静默签到,每 8 小时执行 1 次(错时补签),通过桌面通知反馈签到状态。
// @match        *://*/*
// @version 1.0
// @grant        GM_xmlhttpRequest
// @grant        GM_notification
// @grant        GM_setValue
// @grant        GM_getValue
// @cloudCat
// @license
// @exportCookie domain=.zhutix.com
// @namespace https://greasyfork.org/users/241490
// @license      MIT
// ==/UserScript==

(function() {
    const now = Date.now();
    if (now - GM_getValue('lastExecuted', 0) < 8 * 60 * 60 * 1000) return;
    GM_setValue('lastExecuted', now);

    const username = "";  //填入账号
    const password = "";  //填入密码

    // 获取 token 并签到
    GM_xmlhttpRequest({
        method: 'POST',
        url: 'https://zhutix.com/wp-json/jwt-auth/v1/token',
        data: `username=${username}&password=${password}`,
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
        responseType: "json",
        onload: function(response) {
            if (response.status !== 200) return showError();
            const token = JSON.parse(response.responseText).token;

            GM_xmlhttpRequest({
                method: 'POST',
                url: 'https://zhutix.com/wp-json/b2/v1/getTaskData',
                headers: { "Authorization": `Bearer ${token}` },
                responseType: "json",
                onload: function(data) {
                    const taskData = JSON.parse(data.responseText).task;
                    if (taskData.task_mission.finish === 0) signIn(token);
                    else GM_notification({ title: '致美化签到', text: '今日已签到过,明天再来吧!', timeout: 3000 });
                },
                onerror: showError
            });
        },
        onerror: showError
    });

    function signIn(token) {
        GM_xmlhttpRequest({
            method: 'POST',
            url: 'https://zhutix.com/wp-json/b2/v1/userMission',
            headers: { "Authorization": `Bearer ${token}` },
            responseType: "text",
            onload: function(response) {
                const points = response.responseText.match(/bs.*?(\d+)/);
                const pointsText = points ? `,获取到:${points[1]}积分` : '';
                GM_notification({ title: '致美化签到', text: `今日签到成功${pointsText}`, timeout: 3000 });
            },
            onerror: showError
        });
    }

    function showError() {
        GM_notification({ title: '致美化签到', text: '签到失败:网络错误或未登录' });
    }
})();