Greasy Fork

Greasy Fork is available in English.

glados_checkin

glados每日签到-LGY

当前为 2022-10-04 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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
// ==/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')
  }
})()