Greasy Fork

Greasy Fork is available in English.

PTHome自动签到

PTHome自动签到脚本

当前为 2019-05-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name PTHome自动签到
// @namespace Violentmonkey Scripts
// @match *://www.pthome.net/*
// @run-at document-idle
// @grant GM_xmlhttpRequest
// @version 0.0.1.20190517134736
// @description PTHome自动签到脚本
// ==/UserScript==
(function () {
    'use strict';
    var keyName = "pthome-attend-date";
    function attend() {
        var todayStr = new Date().toLocaleDateString();
        var storeStr = localStorage.getItem(keyName);
        if (storeStr === undefined || storeStr === null || todayStr != storeStr) {
            GM_xmlhttpRequest({
                method: "GET",
                url: window.location.origin + '/attendance.php',
                onload: function (response) {
                    if (response.status === 200 && (response.responseText.indexOf("您今天已经签到过了") !== -1 || response.responseText.indexOf("签到成功") !== -1)) {
                        localStorage.setItem(keyName, todayStr);
                        console.log('attend at ' + new Date().toLocaleString());
                    } else {
                        console.log('attend failed. status=' + response.status);
                    }
                }
            });
        }

    }
    attend();
    setInterval(attend, 6 * 60 * 60 * 1000);
})();