Greasy Fork

Greasy Fork is available in English.

glados_checkin

owned by LGY_lab

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         glados_checkin
// @namespace    http://tampermonkey.net/
// @version      0.4.0
// @description  owned by LGY_lab
// @author       mar
// @connect      *
// @grant        GM_xmlhttpRequest
// @grant        GM_getValue
// @grant        GM_setValue
// @run-at       document-body
// @match      https://*/*
// @license      MIT
// ==/UserScript==

;(function () {
  'use strict'

  var autoSign = true
function onSignIn(isAuto = false) {
  return GM_xmlhttpRequest({
    url: 'https://glados.rocks/api/user/checkin',
    method: 'POST',
    headers: {
      'content-type': 'application/json',
      'user-agent': navigator.userAgent,
    },
    data: '{"token": "glados.network"}',
    responseType: 'json',
    onload(response) {
      const data = response.response
      console.log('data', data)
      if (data.code !== 0) {
        if(data.code == 1) {
          GM_setValue('signDate', today())
          console.log('glados | try tomorrow')
        } else {
          console.log(data)
          throw new Error('new error!!!')
        }
      } else if(data.code == 0){
        GM_setValue('signDate', today())
        console.log('glados 签到成功')
      }
    }
  })
}


  //获取今天的日期
  function today() {
    var date = new Date()
    var seperator1 = '-'
    var seperator2 = ':'
    var month = date.getMonth() + 1
    var strDate = date.getDate()
    if (month >= 1 && month <= 9) {
      month = '0' + month
    }
    if (strDate >= 0 && strDate <= 9) {
      strDate = '0' + strDate
    }
    var currentdate =
      date.getFullYear() + seperator1 + month + seperator1 + strDate
    return currentdate
  }

  //自动签到
  function autoSignHandle() {
    let signDate = GM_getValue('signDate')
    console.log('signDate', signDate)
    console.log('today', today())
    if (autoSign && (!signDate || signDate < today())) {
      onSignIn(true)
    } else {
      console.log('glados checkin success, try tomorrow.')
    }
  }

  autoSignHandle()
})()