forked from mylovedonotcry/bienaoccc_hym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iQIYI-bak.js
336 lines (309 loc) · 11.8 KB
/
iQIYI-bak.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/*
爱奇艺会员签到脚本
更新时间: 2020.9.6
脚本兼容: QuantumultX, Surge4, Loon, JsBox, Node.js
电报频道: @NobyDa
问题反馈: @NobyDa_bot
获取Cookie说明:
打开爱奇艺App后(AppStore中国区),点击"我的", 如通知成功获取cookie, 则可以使用此签到脚本.
获取Cookie后, 请将Cookie脚本禁用并移除主机名,以免产生不必要的MITM.
脚本将在每天上午9:00执行, 您可以修改执行时间。
如果使用Node.js, 需自行安装'request'模块. 例: npm install request -g
JsBox, Node.js用户抓取Cookie说明:
开启抓包, 打开爱奇艺App后(AppStore中国区),点击"我的" 返回抓包App 搜索请求头关键字 psp_cki= 或 P00001= 或 authcookie=
提取字母数字混合字段, 到&结束, 填入以下单引号内即可.
*/
var cookie = ''
/*********************
QuantumultX 远程脚本配置:
**********************
[task_local]
# 爱奇艺会员签到
0 9 * * * https://raw.githubusercontent.com/NobyDa/Script/master/iQIYI-DailyBonus/iQIYI.js
[rewrite_local]
# 获取Cookie
^https?:\/\/iface(\d)?\.iqiyi\.com\/ url script-request-header https://raw.githubusercontent.com/NobyDa/Script/master/iQIYI-DailyBonus/iQIYI.js
[mitm]
hostname= ifac*.iqiyi.com
**********************
Surge 4.2.0+ 脚本配置:
**********************
[Script]
爱奇艺签到 = type=cron,cronexp=0 9 * * *,script-path=https://raw.githubusercontent.com/NobyDa/Script/master/iQIYI-DailyBonus/iQIYI.js
爱奇艺获取Cookie = type=http-request,pattern=^https?:\/\/iface(\d)?\.iqiyi\.com\/,script-path=https://raw.githubusercontent.com/NobyDa/Script/master/iQIYI-DailyBonus/iQIYI.js
[MITM]
hostname= ifac*.iqiyi.com
************************
Loon 2.1.0+ 脚本配置:
************************
[Script]
# 爱奇艺签到
cron "0 9 * * *" script-path=https://raw.githubusercontent.com/NobyDa/Script/master/iQIYI-DailyBonus/iQIYI.js
# 获取Cookie
http-request ^https?:\/\/iface(\d)?\.iqiyi\.com\/ script-path=https://raw.githubusercontent.com/NobyDa/Script/master/iQIYI-DailyBonus/iQIYI.js
[Mitm]
hostname= ifac*.iqiyi.com
*/
var LogDetails = false; // 响应日志
var out = 10000; // 超时 (毫秒) 如填写, 则不少于3000
var $nobyda = nobyda();
(async () => {
out = $nobyda.read("iQIYI_TimeOut") || out
cookie = cookie || $nobyda.read("CookieQY")
LogDetails = $nobyda.read("iQIYI_LogDetails") === "true" ? true : LogDetails
if ($nobyda.isRequest) {
GetCookie()
} else if (cookie) {
await login();
await Checkin();
await Lottery(500);
await $nobyda.time();
} else {
$nobyda.notify("爱奇艺会员", "", "签到终止, 未获取Cookie");
}
})().finally(() => {
$nobyda.done();
})
function login() {
return new Promise(resolve => {
var URL = {
url: 'https://cards.iqiyi.com/views_category/3.0/vip_home?secure_p=iPhone&scrn_scale=0&dev_os=0&ouid=0&layout_v=6&psp_cki=' + cookie + '&page_st=suggest&app_k=8e48946f144759d86a50075555fd5862&dev_ua=iPhone8%2C2&net_sts=1&cupid_uid=0&xas=1&init_type=6&app_v=11.4.5&idfa=0&app_t=0&platform_id=0&layout_name=0&req_sn=0&api_v=0&psp_status=0&psp_uid=451953037415627&qyid=0&secure_v=0&req_times=0',
headers: {
sign: '7fd8aadd90f4cfc99a858a4b087bcc3a',
t: '479112291'
}
}
$nobyda.get(URL, function(error, response, data) {
const Details = LogDetails ? data ? `response:\n${data}` : '' : ''
if (!error && data.match(/\"text\":\"\d.+?\u5230\u671f\"/)) {
$nobyda.expire = data.match(/\"text\":\"(\d.+?\u5230\u671f)\"/)[1]
console.log(`爱奇艺-查询成功: ${$nobyda.expire} ${Details}`)
} else {
console.log(`爱奇艺-查询失败${error || ': 无到期数据 ⚠️'} ${Details}`)
}
resolve()
})
if (out) setTimeout(resolve, out)
})
}
function Checkin() {
return new Promise(resolve => {
var URL = {
url: 'https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask?autoSign=yes&P00001=' + cookie
}
$nobyda.get(URL, function(error, response, data) {
if (error) {
$nobyda.data = "签到失败: 接口请求出错 ‼️"
console.log(`爱奇艺-${$nobyda.data} ${error}`)
} else {
if(!isJSON_test(data)){
return false;
}
const obj = JSON.parse(data)
const Details = LogDetails ? `response:\n${data}` : ''
if (obj.msg === "成功") {
if (obj.data.signInfo.code === "A00000") {
var AwardName = obj.data.signInfo.data.rewards[0].name;
var quantity = obj.data.signInfo.data.rewards[0].value;
var continued = obj.data.signInfo.data.continueSignDaysSum;
$nobyda.data = "签到成功: " + AwardName + quantity + ", 已连签" + continued + "天 🎉"
console.log(`爱奇艺-${$nobyda.data} ${Details}`)
} else {
$nobyda.data = "签到失败: " + obj.data.signInfo.msg + " ⚠️"
console.log(`爱奇艺-${$nobyda.data} ${Details}`)
}
} else {
$nobyda.data = "签到失败: Cookie无效 ⚠️"
console.log(`爱奇艺-${$nobyda.data} ${Details}`)
}
}
resolve()
})
if (out) setTimeout(resolve, out)
})
}
function Lottery(s) {
return new Promise(resolve => {
$nobyda.times++
const URL = {
url: 'https://iface2.iqiyi.com/aggregate/3.0/lottery_activity?app_k=0&app_v=0&platform_id=0&dev_os=0&dev_ua=0&net_sts=0&qyid=0&psp_uid=0&psp_cki=' + cookie + '&psp_status=0&secure_p=0&secure_v=0&req_sn=0'
}
setTimeout(() => {
$nobyda.get(URL, async function(error, response, data) {
if (error) {
$nobyda.data += "\n抽奖失败: 接口请求出错 ‼️"
console.log(`爱奇艺-抽奖失败: 接口请求出错 ‼️ ${error} (${$nobyda.times})`)
//$nobyda.notify("爱奇艺", "", $nobyda.data)
} else {
const obj = JSON.parse(data);
const Details = LogDetails ? `response:\n${data}` : ''
$nobyda.last = data.match(/(机会|已经)用完/) ? true : false
if (obj.awardName && obj.code === 0) {
$nobyda.data += !$nobyda.last ? `\n抽奖成功: ${obj.awardName.replace(/《.+》/, "未中奖")} 🎉` : `\n抽奖失败: 今日已抽奖 ⚠️`
console.log(`爱奇艺-抽奖明细: ${obj.awardName.replace(/《.+》/, "未中奖")} 🎉 (${$nobyda.times}) ${Details}`)
} else if (data.match(/\"errorReason\"/)) {
msg = data.match(/msg=.+?\)/) ? data.match(/msg=(.+?)\)/)[1].replace(/用户(未登录|不存在)/, "Cookie无效") : ""
$nobyda.data += `\n抽奖失败: ${msg || `未知错误`} ⚠️`
console.log(`爱奇艺-抽奖失败: ${msg || `未知错误`} ⚠️ (${$nobyda.times}) ${msg ? Details : `response:\n${data}`}`)
console.log(data)
s = s + 500;
if(s <= 4500){
await Lottery(s)
}
} else {
$nobyda.data += "\n抽奖错误: 已输出日志 ⚠️"
console.log(`爱奇艺-抽奖失败: \n${data} (${$nobyda.times})`)
}
}
if (!$nobyda.last && $nobyda.times < 3) {
await Lottery(s)
} else {
const expires = $nobyda.expire ? $nobyda.expire.replace(/\u5230\u671f/, "") : "获取失败 ⚠️"
if (!$nobyda.isNode) $nobyda.notify("爱奇艺", "到期时间: " + expires, $nobyda.data)
}
resolve()
})
}, s)
if (out) setTimeout(resolve, out + s)
})
}
function GetCookie() {
var CKA = $request.url.match(/(psp_cki=|P00001=|authcookie=)([A-Za-z0-9]+)/)
var CKB = JSON.stringify($request.headers).match(/(psp_cki=|P00001=|authcookie=)([A-Za-z0-9]+)/)
var iQIYI = CKA || CKB || null
var RA = $nobyda.read("CookieQY")
if (iQIYI) {
if (RA !== iQIYI[2]) {
var OldTime = $nobyda.read("CookieQYTime")
if (!$nobyda.write(iQIYI[2], "CookieQY")) {
$nobyda.notify(`${RA?`更新`:`首次写入`}爱奇艺签到Cookie失败‼️`, "", "")
} else {
if (!OldTime || OldTime && (Date.now() - OldTime) / 1000 >= 21600) {
$nobyda.write(JSON.stringify(Date.now()), "CookieQYTime")
$nobyda.notify(`${RA?`更新`:`首次写入`}爱奇艺签到Cookie成功 🎉`, "", "")
} else {
console.log(`\n更新爱奇艺Cookie成功! 🎉\n检测到频繁通知, 已转为输出日志`)
}
}
} else {
console.log("\n爱奇艺-与本机储存Cookie相同, 跳过写入 ⚠️")
}
} else {
console.log("\n爱奇艺-请求不含Cookie, 跳过写入 ‼️")
}
}
function nobyda() {
const times = 0
const start = Date.now()
const isRequest = typeof $request != "undefined"
const isSurge = typeof $httpClient != "undefined"
const isQuanX = typeof $task != "undefined"
const isLoon = typeof $loon != "undefined"
const isJSBox = typeof $app != "undefined" && typeof $http != "undefined"
const isNode = typeof require == "function" && !isJSBox;
const node = (() => {
if (isNode) {
const request = require('request');
return ({
request
})
} else {
return (null)
}
})()
const notify = (title, subtitle, message) => {
if (isQuanX) $notify(title, subtitle, message)
if (isSurge) $notification.post(title, subtitle, message)
if (isNode) log('\n' + title + '\n' + subtitle + '\n' + message)
if (isJSBox) $push.schedule({
title: title,
body: subtitle ? subtitle + "\n" + message : message
})
}
const write = (value, key) => {
if (isQuanX) return $prefs.setValueForKey(value, key)
if (isSurge) return $persistentStore.write(value, key)
}
const read = (key) => {
if (isQuanX) return $prefs.valueForKey(key)
if (isSurge) return $persistentStore.read(key)
}
const adapterStatus = (response) => {
if (response) {
if (response.status) {
response["statusCode"] = response.status
} else if (response.statusCode) {
response["status"] = response.statusCode
}
}
return response
}
const get = (options, callback) => {
if (isQuanX) {
if (typeof options == "string") options = {
url: options
}
options["method"] = "GET"
$task.fetch(options).then(response => {
callback(null, adapterStatus(response), response.body)
}, reason => callback(reason.error, null, null))
}
if (isSurge) $httpClient.get(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
if (isNode) {
node.request(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
}
if (isJSBox) {
if (typeof options == "string") options = {
url: options
}
options["header"] = options["headers"]
options["handler"] = function(resp) {
let error = resp.error;
if (error) error = JSON.stringify(resp.error)
let body = resp.data;
if (typeof body == "object") body = JSON.stringify(resp.data);
callback(error, adapterStatus(resp.response), body)
};
$http.get(options);
}
}
const log = (message) => console.log(message)
const time = () => {
const end = ((Date.now() - start) / 1000).toFixed(2)
return console.log('\n签到用时: ' + end + ' 秒')
}
const done = (value = {}) => {
if (isQuanX) return $done(value)
if (isSurge) isRequest ? $done(value) : $done()
}
return {
isRequest,
isNode,
notify,
write,
read,
get,
log,
time,
times,
done
}
};
function isJSON_test(str) {
if (typeof str == 'string') {
try {
var obj=JSON.parse(str);
//console.log('转换成功:'+obj);
return true;
} catch(e) {
console.log('no json');
console.log('error:'+str+'!!!'+e);
return false;
}
}
//console.log('It is not a string!')
}