-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMIUI历史版本签到.user.js
130 lines (123 loc) · 4.27 KB
/
MIUI历史版本签到.user.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// ==UserScript==
// @name MIUI历史版本签到
// @namespace https://github.com/geoi6sam1
// @version 0.3.8
// @description MIUI历史版本每日自动签到,支持自动登录
// @author [email protected]
// @icon https://miuiver.com/favicon.ico
// @supportURL https://github.com/geoi6sam1/FuckScripts/issues
// @crontab * * once * *
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @grant GM_openInTab
// @grant GM_getValue
// @grant GM_log
// @connect miuiver.com
// @license GPL-3.0
// ==/UserScript==
/* ==UserConfig==
Login:
log:
title: 账号
pwd:
title: 密码
password: true
==/UserConfig== */
let reLogTimes = 0
let userLog = encodeURIComponent(GM_getValue("Login.log"))
let userPwd = encodeURIComponent(GM_getValue("Login.pwd"))
return new Promise((resolve, reject) => {
function getRs(callback) {
GM_xmlhttpRequest({
method: "GET",
url: "https://miuiver.com/user-profile",
onload(xhr) {
var res = xhr.responseText
var rewards = res.match(/<b>(.*?)<\/b>/)
if (rewards) {
callback(rewards[1])
} else {
callback("获取失败")
}
}
})
}
function login() {
reLogTimes++
GM_xmlhttpRequest({
method: "POST",
url: "https://miuiver.com/wp-login.php",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "https://miuiver.com/wp-login.php",
},
data: `log=${userLog}&pwd=${userPwd}&rememberme=forever&wp-submit=%E7%99%BB%E5%BD%95&redirect_to=https%3A%2F%2Fmiuiver.com%2Fwp-admin%2F&testcookie=1`,
responseType: "json",
onload(xhr) {
var stat = xhr.status
if (stat == 200) {
if (reLogTimes > 2) {
pushMsg("失败", "登录失败,请检查账号密码!")
resolve()
} else {
main()
}
} else if (stat == 503) {
pushMsg("失败", "登录请求频繁,请稍后再登录!")
resolve()
} else {
pushMsg("失败", "登录请求失败!状态码:" + stat)
reject(xhr)
}
}
})
}
function main() {
GM_xmlhttpRequest({
method: "POST",
url: "https://miuiver.com/wp-admin/admin-ajax.php",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "https://miuiver.com/user-profile/",
},
data: "action=epd_checkin",
responseType: "json",
onload(xhr) {
var stat = xhr.status
if (stat == 200) {
var status = xhr.response.status
switch (status) {
case 200:
getRs((rewards) => {
pushMsg("成功", "签到成功,当前积分:" + rewards)
resolve()
})
break
case 201:
getRs((rewards) => {
pushMsg("重复", "签到重复,当前积分:" + rewards)
resolve()
})
break
}
} else if (stat == 400) {
login()
} else {
pushMsg("失败", "签到请求失败!状态码:" + stat)
reject(xhr)
}
}
})
}
main()
})
function pushMsg(title, text) {
GM_notification({
text: text,
title: "MIUI历史版本签到" + title,
image: "https://miuiver.com/favicon.ico",
onclick: () => {
GM_openInTab("https://miuiver.com/user-profile", { active: true, insert: true, setParent: true })
}
})
}