// ==UserScript== // @name glados_checkin // @namespace http://tampermonkey.net/ // @version 0.0.1 // @description glados每日签到-LGY // @author mar // @match *://*/* // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest // @license MIT // @downloadURL none // ==/UserScript== (function () { 'use strict' console.log('test') const storageKey = 'last_sign_timestamp' // 获取上一次签到的日子 const lastSignNumberOfDays = GM_getValue(storageKey, 0) // 计算现在所在的日子 const currentNumberOfDays = Math.floor( new Date().valueOf() / 1000 / 60 / 60 / 24 ) // 如果今天已经请求过,不再请求 if (currentNumberOfDays !== lastSignNumberOfDays) { GM_xmlhttpRequest({ url: 'https://api.juejin.cn/growth_api/v1/check_in', method: 'POST', headers: { 'content-type': 'application/json', 'user-agent': navigator.userAgent, }, body: { token: 'glados.network', }, responseType: 'json', onload(response) { if (response.status === 200) { const data = response.response if (data.data === 'success') { console.log('glados checkin done!') } else { alert(data.err_msg) } // 更新最近一次签到的日子 GM_setValue(storageKey, currentNumberOfDays) } }, }) } else { console.log('You already checked in today') } })()