forked from chavyleung/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10010.js
253 lines (237 loc) · 9.97 KB
/
10010.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
const chavy = init()
const cookieName = '中国联通'
const KEY_loginurl = 'chavy_tokenurl_10010'
const KEY_loginheader = 'chavy_tokenheader_10010'
const KEY_signurl = 'chavy_signurl_10010'
const KEY_signheader = 'chavy_signheader_10010'
const KEY_loginlotteryurl = 'chavy_loginlotteryurl_10010'
const KEY_loginlotteryheader = 'chavy_loginlotteryheader_10010'
const KEY_findlotteryurl = 'chavy_findlotteryurl_10010'
const KEY_findlotteryheader = 'chavy_findlotteryheader_10010'
const signinfo = {}
let VAL_loginurl = chavy.getdata(KEY_loginurl)
let VAL_loginheader = chavy.getdata(KEY_loginheader)
let VAL_signurl = chavy.getdata(KEY_signurl)
let VAL_signheader = chavy.getdata(KEY_signheader)
let VAL_loginlotteryurl = chavy.getdata(KEY_loginlotteryurl)
let VAL_loginlotteryheader = chavy.getdata(KEY_loginlotteryheader)
let VAL_findlotteryurl = chavy.getdata(KEY_findlotteryurl)
let VAL_findlotteryheader = chavy.getdata(KEY_findlotteryheader)
;(sign = async () => {
chavy.log(`🔔 ${cookieName}`)
await loginapp()
await signapp()
if (VAL_loginlotteryurl && VAL_findlotteryurl) await loginlottery()
if (signinfo.encryptmobile) {
await findlottery()
if (signinfo.findlottery && signinfo.findlottery.acFrequency && signinfo.findlottery.acFrequency.usableAcFreq) {
for (let i = 0; i < signinfo.findlottery.acFrequency.usableAcFreq; i++) {
await lottery()
}
}
}
await getinfo()
showmsg()
chavy.done()
})().catch((e) => chavy.log(`❌ ${cookieName} 签到失败: ${e}`), chavy.done())
function loginapp() {
return new Promise((resolve, reject) => {
const url = { url: VAL_loginurl, headers: JSON.parse(VAL_loginheader) }
chavy.post(url, (error, response, data) => {
try {
resolve()
} catch (e) {
chavy.msg(cookieName, `登录结果: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} loginapp - 登录失败: ${e}`)
chavy.log(`❌ ${cookieName} loginapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function signapp() {
return new Promise((resolve, reject) => {
if (VAL_signurl.endsWith('.do')) VAL_signurl = VAL_signurl.replace('.do', '')
const url = { url: 'https://act.10010.com/SigninApp/signin/daySign', headers: JSON.parse(VAL_signheader) }
chavy.post(url, (error, response, data) => {
try {
signinfo.signapp = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} signapp - 签到失败: ${e}`)
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function loginlottery() {
return new Promise((resolve, reject) => {
const url = { url: VAL_loginlotteryurl, headers: JSON.parse(VAL_loginlotteryheader) }
chavy.get(url, (error, response, data) => {
try {
const encryptmobileMatch = data.match(/encryptmobile=([^('|")]*)/)
if (encryptmobileMatch) {
signinfo.encryptmobile = encryptmobileMatch[1]
} else {
chavy.msg(cookieName, `获取抽奖令牌: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} loginlottery - 获取抽奖令牌失败: ${e}`)
chavy.log(`❌ ${cookieName} loginlottery - response: ${JSON.stringify(response)}`)
}
resolve()
} catch (e) {
chavy.msg(cookieName, `登录抽奖: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} loginlottery - 登录抽奖失败: ${e}`)
chavy.log(`❌ ${cookieName} loginlottery - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function findlottery() {
return new Promise((resolve, reject) => {
VAL_findlotteryurl = VAL_findlotteryurl.replace(/encryptmobile=[^(&|$)]*/, `encryptmobile=${signinfo.encryptmobile}`)
VAL_findlotteryurl = VAL_findlotteryurl.replace(/mobile=[^(&|$)]*/, `mobile=${signinfo.encryptmobile}`)
const url = { url: VAL_findlotteryurl, headers: JSON.parse(VAL_findlotteryheader) }
chavy.get(url, (error, response, data) => {
try {
signinfo.findlottery = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `获取抽奖次数: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} findlottery - 获取抽奖次数失败: ${e}`)
chavy.log(`❌ ${cookieName} findlottery - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function lottery() {
return new Promise((resolve, reject) => {
const url = { url: `https://m.client.10010.com/dailylottery/static/doubleball/choujiang?usernumberofjsp=${signinfo.encryptmobile}`, headers: JSON.parse(VAL_loginlotteryheader) }
url.headers['Referer'] = `https://m.client.10010.com/dailylottery/static/doubleball/firstpage?encryptmobile=${signinfo.encryptmobile}`
chavy.post(url, (error, response, data) => {
try {
signinfo.lotterylist = signinfo.lotterylist ? signinfo.lotterylist : []
signinfo.lotterylist.push(JSON.parse(data))
resolve()
} catch (e) {
chavy.msg(cookieName, `抽奖结果: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} lottery - 抽奖失败: ${e}`)
chavy.log(`❌ ${cookieName} lottery - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function gettel() {
const reqheaders = JSON.parse(VAL_signheader)
const reqreferer = reqheaders.Referer
const reqCookie = reqheaders.Cookie
let tel = ''
if (reqreferer.indexOf(`desmobile=`) >= 0) tel = reqreferer.match(/desmobile=(.*?)(&|$)/)[1]
if (tel == '' && reqCookie.indexOf(`u_account=`) >= 0) tel = reqCookie.match(/u_account=(.*?);/)[1]
return tel
}
function getinfo() {
return new Promise((resolve, reject) => {
const url = { url: `https://mina.10010.com/wxapplet/bind/getIndexData/alipay/alipaymini?user_id=${gettel()}` }
chavy.get(url, (error, response, data) => {
try {
signinfo.info = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `获取余量: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} getinfo - 获取余量失败: ${e}`)
chavy.log(`❌ ${cookieName} getinfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
let subTitle = ''
let detail = ''
// 签到结果
if (signinfo.signapp.signinMedal) {
subTitle = `签到: 成功`
detail = `积分: +${signinfo.signapp.prizeCount}, 成长值: +${signinfo.signapp.growthV}, 鲜花: +${signinfo.signapp.flowerCount}`
} else if (JSON.stringify(signinfo.signapp) == '{}') {
subTitle = `签到: 重复`
} else {
subTitle = `签到: 失败`
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(signinfo.signapp)}`)
}
if (signinfo.info.code == '0000') {
// 基本信息
detail = detail ? `${detail}\n` : ``
const free = signinfo.info.dataList[0]
const flow = signinfo.info.dataList[1]
const voice = signinfo.info.dataList[2]
detail = `话费: ${free.number}${free.unit}, 已用: ${flow.number}${flow.unit}, 剩余: ${voice.number}${voice.unit}`
} else {
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(signinfo.info)}`)
}
if (signinfo.findlottery && signinfo.findlottery.acFrequency && signinfo.lotterylist) {
subTitle += `; 抽奖: ${signinfo.findlottery.acFrequency.usableAcFreq}次`
detail += '\n查看详情\n'
for (let i = 0; i < signinfo.findlottery.acFrequency.usableAcFreq; i++) {
detail += `\n抽奖 (${i + 1}): ${signinfo.lotterylist[i].RspMsg}`
}
} else {
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(signinfo.findlottery)}`)
}
chavy.msg(cookieName, subTitle, detail)
}
function init() {
isSurge = () => {
return undefined === this.$httpClient ? false : true
}
isQuanX = () => {
return undefined === this.$task ? false : true
}
getdata = (key) => {
if (isSurge()) return $persistentStore.read(key)
if (isQuanX()) return $prefs.valueForKey(key)
}
setdata = (key, val) => {
if (isSurge()) return $persistentStore.write(key, val)
if (isQuanX()) return $prefs.setValueForKey(key, val)
}
msg = (title, subtitle, body) => {
if (isSurge()) $notification.post(title, subtitle, body)
if (isQuanX()) $notify(title, subtitle, body)
}
log = (message) => console.log(message)
get = (url, cb) => {
if (url['headers'] != undefined) {
delete url['headers']['Content-Length']
console.log(url['headers'])
}
if (isSurge()) {
$httpClient.get(url, cb)
}
if (isQuanX()) {
url.method = 'GET'
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
}
}
post = (url, cb) => {
if (url['headers'] != undefined) {
delete url['headers']['Content-Length']
console.log(url['headers'])
}
if (isSurge()) {
$httpClient.post(url, cb)
}
if (isQuanX()) {
url.method = 'POST'
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
}
}
done = (value = {}) => {
$done(value)
}
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
}