Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save myanbin/782ab2d588e57cd28b86bed09d33e0a3 to your computer and use it in GitHub Desktop.
Save myanbin/782ab2d588e57cd28b86bed09d33e0a3 to your computer and use it in GitHub Desktop.
给兮兮写的签到签退代码
// ==UserScript==
// @name AutoSign Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 给兮兮写的签到签退代码
// @author Yanbin Ma ([email protected])
// @match https://web.jingoal.com/*
// @grant none
// @require https://cdn.bootcss.com/jquery/2.0.1/jquery.min.js
// ==/UserScript==
(function() {
'use strict';
// 给兮兮的代码。-- 牛牛
var signButton, signInTime, signOutTime;
setTimeout(function () {
console.log('脚本初始化完成,正在运行中 ...');
signButton = $('.clockbtn.clockbtn_0_0');
setInterval(autoSign, 50 * 1000);
}, 60 * 1000);
var autoSign = function () {
var signButtonText = signButton.text().trim();
var _now = new Date();
var now = _now.getHours() * 60 + _now.getMinutes();
if (now > 2 * 60 && now < 3 * 60) {
// 凌晨 2 点自动重置签到和签退时间
signInTime = undefined;
signOutTime = undefined;
}
if (signButtonText.indexOf('签到') !== -1) {
console.log('当前时间', _now.toTimeString(), signInTime === undefined ? '待签到' : '已签到');
// 如果未签到且时间刚过 10 点,则自动触发签到按钮
if (signInTime === undefined && now > 10 * 60 - Math.random() * 20) {
signButton.click();
signInTime = now;
console.log('签到时间', _now.toTimeString());
}
} else if (signButtonText.indexOf('签退') !== -1) {
console.log('当前时间', _now.toTimeString(), signOutTime === undefined ? '待签退' : '已签退');
// 如果未签退且时间刚过 19 点,则自动触发签退按钮
if (signOutTime === undefined && now > 19 * 60 - Math.random() * 20) {
signButton.click();
signOutTime = now;
console.log('签退时间', _now.toTimeString());
}
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment