-
Notifications
You must be signed in to change notification settings - Fork 3
/
ck_kjwj.js
140 lines (133 loc) · 3.69 KB
/
ck_kjwj.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
131
132
133
134
135
136
137
138
139
140
/*
31 7 * * * ck_kjwj.js
请提前在依赖管理-nodejs中安装qs
*/
const utils = require('./utils');
const Qs = require('qs');
const Env = utils.Env;
const getData = utils.getData;
const $ = new Env('科技玩家');
const notify = require('./sendNotify');
const AsVow = getData().KJWJ;
var info = '';
var desp = '';
var token = '';
const headers = {
'Host': 'www.kejiwanjia.com',
'Referer': 'https://www.kejiwanjia.com/mission/today',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
};
const data = {
'username': '',
'password': ''
};
kjwj();
async function kjwj() {
if (AsVow) {
for (i in AsVow) {
username = AsVow[i].username;
password = AsVow[i].password;
data['username'] = username;
data['password'] = password;
if (username && password) {
head = `=== 正对在 ${username} 的账号签到===\n`;
info += `\n${head}`;
await getauth();
await pre_sign();
await sign();
desp += info;
info = '';
}
}
info += desp;
console.log(info);
notify.sendNotify('科技玩家', info);
} else {
info = '签到失败:请先获取Cookie⚠️';
console.log(info);
notify.sendNotify('科技玩家', info);
}
$.done()
}
function getauth() {
url = 'https://www.kejiwanjia.com/wp-json/jwt-auth/v1/token';
headers['Referer'] = 'https://www.kejiwanjia.com/';
headers['Content-Type'] = 'application/x-www-form-urlencoded';
const request = {
url: url,
headers: headers,
body: Qs.stringify(data)
};
return new Promise(resolve => {
$.http.post(request)
.then(async (resp) => {
resdata = $.toObj(resp.body);
info += `账号:${resdata.name}\n`;
info += `ID:${resdata.id}\n`;
info += `金币:${resdata.credit}\n`;
info += `等级:${resdata.lv.lv.name}\n`;
token = resdata.token;
})
.catch((err) => {
const error = '账号信息获取失败⚠️';
console.log(error + '\n' + err);
})
.finally(() => {
resolve();
});
});
}
function pre_sign() {
url = 'https://www.kejiwanjia.com/wp-json/b2/v1/getUserMission';
headers['Content-Type'] = 'application/x-www-form-urlencoded';
headers['Origin'] = 'https://www.kejiwanjia.com/';
headers['Authorization'] = `Bearer ${token}`;
suff = 'count=10&paged=1';
const request = {
url: url,
headers: headers,
body: suff
};
return new Promise(resolve => {
$.http.post(request)
.then(async (resp) => {
resdata = $.toObj(resp.body);
if (resdata.mission.credit != "0") {
info += `今天已签到:获得${resdata.mission.credit}金币\n\n`;
}
})
.catch((err) => {
const error = '🆕--签到前--状态获取失败⚠️';
console.log(error + '\n' + err);
})
.finally(() => {
resolve();
});
});
}
function sign() {
url = 'https://www.kejiwanjia.com/wp-json/b2/v1/userMission';
headers['Origin'] = 'https://www.kejiwanjia.com/';
headers['Authorization'] = `Bearer ${token}`;
const request = {
url: url,
headers: headers
};
return new Promise(resolve => {
$.http.post(request)
.then(async (resp) => {
resdata = $.toObj(resp.body);
if ((typeof resdata) != 'string') {
info += `每日首次签到成功:获得${resdata.credit}金币\n\n`;
}
})
.catch((err) => {
const error = '🆕--签到--状态获取失败⚠️';
console.log(error + '\n' + err);
})
.finally(() => {
resolve();
});
});
}
module.exports = kjwj;