-
Notifications
You must be signed in to change notification settings - Fork 2
/
auto_task.js
69 lines (56 loc) · 2.18 KB
/
auto_task.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ==UserScript==
// @name North-Plus Auto Task
// @namespace https://github.com/sssssssl/NP-scripts
// @version 0.4
// @description 自动领取和完成北+日常和周常任务
// @author sl
// @match https://*.white-plus.net
// @match https://*.white-plus.net/index.php
// @match https://*.south-plus.net
// @match https://*.white-plus.net/index.php
// @match https://*.imoutolove.me
// @match https://*.imoutolove.me/index.php
// @require https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function () {
'use strict';
// Your code here...
var taskBaseURL = 'plugin.php?H_name=tasks&action=ajax&actions=job&cid=';
var rewardBaseURL = 'plugin.php?H_name=tasks&action=ajax&actions=job2&cid=';
var taskDailyID = '15';
var taskWeeklyID = '14';
var taskDailyKey = 'lastTaskDaily';
var taskWeeklyKey = 'lastTaskWeekly';
var taskDailyInterval = 1000 * 60 * 60 * 24;
var taskWeeklyInterval = taskDailyInterval * 7;
function checkTask(now, taskID, taskKey, taskInterval) {
var lastSignIn = GM_getValue(taskKey);
if (lastSignIn === undefined || (now - lastSignIn) > taskInterval) {
// 领取任务
$.get(taskBaseURL + taskID, function (data, status) {
console.log(data);
console.log(status);
setTimeout(function () {
// 等 1.5s,领取奖励
$.get(rewardBaseURL + taskID, function (data, status) {
console.log(data);
console.log(status);
GM_setValue(taskKey, now);
});
}, 1500);
});
}
else {
// do nothing.
var interval = (now - lastSignIn) / (1000);
console.log('距离上次任务过了 ' + interval + ' 秒');
}
}
var now = Date.now();
checkTask(now, taskDailyID, taskDailyKey, taskDailyInterval);
setTimeout(function () {
checkTask(now, taskWeeklyID, taskWeeklyKey, taskWeeklyInterval);
}, 1500);
})();