-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTencent.js
More file actions
695 lines (656 loc) · 35.2 KB
/
Tencent.js
File metadata and controls
695 lines (656 loc) · 35.2 KB
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
/**
*@file 腾讯视频
*@desp 本脚本仅适用于腾讯视频及体育会员每日签到,仅测试Quantumult X、青龙(只支持单账号)
*@env txspCookie、txspRefreshCookie、txspRefreshBody、dayOfGetMonthTicket、isSkipTxspCheckIn、isLottery
🌟 环境变量说明
txspCookie:腾讯视频app的Cookie
txspRefreshCookie、txspRefreshBody:腾讯视频网页NewRefresh接口中的数据,用来刷新Cookie中的vqq_vusession
dayOfGetMonthTicket:每月几号领取每月球票,默认为每月1号
isSkipTxspCheckIn:值域[true, false] 默认为false表示正常进行腾讯视频会员签到,用于特殊情况下(账号需要获取短信验证码或者需要过滑块验证码)时开启
isLottery: 值域[true, false] 默认为false表示不抽奖,抽抽乐于2024年2月29日10点下线,建议不开启,反正也抽不到
❗ 本脚本只能给腾讯视频正常账号签到,如有验证请设置isSkipTxspCheckIn为true,直到手动签到无验证为止
❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖❖
详细功能:
🔵 腾讯视频会员签到领V力值
🔵 腾讯体育会员签到领热爱值
🔵 腾讯体育领取每日球票
🔵 腾讯体育领取每月球票
📌 获取Cookie:(重写需要获取3个值:txspCookie、txspRefreshCookie、txspRefreshBody)
- 进入腾讯视频app,点击右下角我的,点击头像下的视频VIP进入会员中心看到系统消息提示获取txspCookie成功即可
- 浏览器进入腾讯视频网页版,登录后切换成桌面版,刷新网页看到系统消息提示获取txspRefreshCookie、txspRefreshBody成功即可
- 获取Cookie后, 请将Cookie脚本禁用并移除主机名,以免产生不必要的MITM
-----------------------------------------
【免责声明】
1、此脚本仅用于学习研究,不保证其合法性、准确性、有效性,请根据情况自行判断,本人对此不承担任何保证责任。
2、由于此脚本仅用于学习研究,您必须在下载后 24 小时内将所有内容从您的计算机或手机或任何存储设备中完全删除,若违反规定引起任何事件本人对此均不负责。
3、请勿将此脚本用于任何商业或非法目的,若违反规定请自行对此负责。
4、此脚本涉及应用与本人无关,本人对因此引起的任何隐私泄漏或其他后果不承担任何责任。
5、本人对任何脚本引发的问题概不负责,包括但不限于由脚本错误引起的任何损失和损害。
6、如果任何单位或个人认为此脚本可能涉嫌侵犯其权利,应及时通知并提供身份证明,所有权证明,我们将在收到认证文件确认后删除此脚本。
7、所有直接或间接使用、查看此脚本的人均应该仔细阅读此声明。本人保留随时更改或补充此声明的权利。一旦您使用或复制了此脚本,即视为您已接受此免责声明。
圈x配置
[MITM]
hostname = vip.video.qq.com, pbaccess.video.qq.com
[rewrite_local]
^https:\/\/vip\.video\.qq\.com\/rpc\/trpc\.new_task_system\.task_system\.TaskSystem\/ReadTaskList\? url script-request-header https://raw.githubusercontent.com/dream385/Script/main/Tencent.js
^https:\/\/pbaccess\.video\.qq\.com\/trpc\.videosearch\.hot_rank\.HotRankServantHttp\/HotRankHttp url script-request-header https://raw.githubusercontent.com/dream385/Script/main/Tencent.js
^https:\/\/pbaccess\.video\.qq\.com\/trpc\.video_account_login\.web_login_trpc\.WebLoginTrpc\/NewRefresh url script-request-body https://raw.githubusercontent.com/dream385/Script/main/Tencent.js
[task_local]
5 7 * * * https://raw.githubusercontent.com/dream385/Script/main/Tencent.js, tag=腾讯视频
**/
const $ = new Env("腾讯视频");
let txspCookie = ($.isNode() ? process.env.txspCookie : $.getdata('txspCookie')) || "";
let txspRefreshCookie = ($.isNode() ? process.env.txspRefreshCookie : $.getdata('txspRefreshCookie')) || "";
let txspRefreshBody = ($.isNode() ? process.env.txspRefreshBody : $.getdata('txspRefreshBody')) || "";
let dayOfGetMonthTicket = ($.isNode() ? process.env.dayOfGetMonthTicket : $.getdata('dayOfGetMonthTicket')) || 1;
let isSkipTxspCheckIn = $.isNode() ? process.env.isSkipTxspCheckIn : (($.getdata('isSkipTxspCheckIn') !== undefined && $.getdata('isSkipTxspCheckIn') !== '') ? JSON.parse($.getdata('isSkipTxspCheckIn')) : false);
let isLottery = $.isNode() ? process.env.isLottery : (($.getdata('isLottery') !== undefined && $.getdata('isLottery') !== '') ? JSON.parse($.getdata('isLottery')) : false);
const Notify = 1; //0为关闭通知,1为打开通知,默认为1
const notify = $.isNode() ? require("./sendNotify") : "";
let currentVersion = "v2.0", latestVersion = "";
let nickname = "";
let isTxspVip = false, isTxspSvip = false, isTxSportsVip = false, isTxSportsSvip = false;
let endTime = "", svipEndTime = "", txSportsEndTime = "", txSportsSvipEndTime = "";
let level = "", txSportsLevel = "";
let score = "", txSportsScore = "";
let month_received_score = "", month_limit = "";
let isTxspCheckIn = "", isTxSportsCheckIn = "";
let originalInfo = $.info;
let originalWarn = $.warn;
let originalError = $.error;
let message = "";
$.desc = "", $.taskInfo = "";
$.info=function(message){originalInfo.call($,message);$.desc+=message+"\n"};$.warn=function(message){originalWarn.call($,message);$.desc+=message+"\n"};$.error=function(message){originalError.call($,message);$.desc+=message+"\n"};
if ((isGetCookie = typeof $request !== `undefined`)) {
getCookie();
$.done();
} else if (!$.isNode() && !txspCookie){
$.msg($.name, "您未获取腾讯视频Cookie", "点击此条跳转到腾讯视频获取Cookie", { 'open-url': 'tenvideo://', 'media-url': 'https://raw.githubusercontent.com/WowYiJiu/Personal/main/icon/videoqq.png' });
$.done();
} else {
!(async () => {
await getNotice();
await getVersion();
$.log(`\n当前版本:${currentVersion} 最新版本:${latestVersion}\n`);
$.version = `\n当前版本:${currentVersion} 最新版本:${latestVersion}\n`;
if(!txspCookie){
$.warn(`未填写txspCookie环境变量`);
return;
}
$.info("---- 开始 刷新vusession ----");
await refresh_vusession();
$.info(`--------- 结束 ---------\n`);
$.info(`用户昵称:${nickname}`);
await getVipInfo();
if (isTxspVip){
$.info(`---- 腾讯视频VIP信息 ----`);
if (isTxspSvip){
$.info(`当前是腾讯视频SVIP`);
} else {
$.info(`当前是腾讯视频VIP`);
}
$.info(`当前等级:${level}`);
$.info(`当前成长:${score}`);
if (isTxspSvip){
$.info(`SVIP到期时间:${svipEndTime}`);
}
$.info(`VIP到期时间:${endTime}`);
$.info(`--------- 结束 ---------\n`);
}
if (isTxSportsVip){
$.info(`--- 腾讯体育VIP信息 ---`);
if (isTxSportsSvip){
$.info(`当前是腾讯体育超级VIP`);
} else {
$.info(`当前是腾讯体育VIP`);
}
$.info(`当前等级:${txSportsLevel}`);
$.info(`当前成长:${txSportsScore}`);
if (isTxSportsSvip){
$.info(`SVIP到期时间:${txSportsSvipEndTime}`);
}
$.info(`VIP到期时间:${txSportsEndTime}`);
$.info(`--------- 结束 ---------\n`);
}
if (isTxspVip){
$.info(`---- 开始 腾讯视频签到 ----`);
if (isSkipTxspCheckIn){
$.info(`当前设置为不进行腾讯视频签到,跳过`);
} else {
await readTxspTaskList();
await waitRandom(1000, 2000);
if (month_received_score === month_limit){
$.info(`本月活跃任务已满${month_limit}V力值,下个月再来哦`);
} else if (isTxspCheckIn){
$.info(`今天已签到, 明日再来吧`);
} else {
await txspCheckIn();
await waitRandom(1000, 2000);
}
}
$.info(`--------- 结束 ---------\n`);
}
if (isTxSportsVip){
$.info(`---- 开始 腾讯体育签到 ----`);
await readTxSportsTaskList();
await waitRandom(1000, 2000);
if (isTxSportsCheckIn){
$.info(`今天已签到, 明日再来吧`);
} else {
await txSportsCheckIn();
await waitRandom(1000, 2000);
}
$.info(`--------- 结束 ---------\n`);
$.info(`---- 开始 领取每日球票 ----`);
await getDayTicket();
await waitRandom(1000, 2000);
$.info(`--------- 结束 ---------\n`);
$.info(`---- 开始 领取每月球票 ----`);
var today = new Date();
var date = today.getDate();
if (date !== dayOfGetMonthTicket){
$.info(`目标日期:${dayOfGetMonthTicket}号`);
$.info(`今天是${date}号`);
$.info(`跳过`);
} else {
$.info(`目标日期:${dayOfGetMonthTicket}号`);
$.info(`今天是${date}号`);
await getMonthTicket();
}
$.info(`--------- 结束 ---------\n`);
if (isLottery) {
$.info(`---- 开始 抽抽乐 ----`);
await lottery();
await waitRandom(1000, 2000);
$.info(`--------- 结束 ---------`);
}
}
await SendMsg();
})()
.catch((e) => $.error(e))
.finally(() => $.done());
}
async function refresh_vusession() {
return new Promise((resolve) => {
let opt = {
url: `https://pbaccess.video.qq.com/trpc.video_account_login.web_login_trpc.WebLoginTrpc/NewRefresh`,
headers: {
cookie: txspRefreshCookie,
origin: 'https://v.qq.com',
referer: 'https://v.qq.com/',
'Content-Type': 'application/json'
},
body: txspRefreshBody
};
$.post(opt, async (error, resp, data) => {
if (safeGet(data)) {
var obj = JSON.parse(data);
if (obj.data.errcode === 0) {
let vqq_vusession = obj.data.vusession;
nickname = decodeURIComponent(obj.data.nick);
if (txspCookie.match(/main_login=([^;]*)/)[1] === "qq"){
txspCookie = txspCookie.replace(/(vqq_vusession=)[^;]*/, `$1${vqq_vusession}`);
} else if(txspCookie.match(/main_login=([^;]*)/)[1] === "wx"){
txspCookie = txspCookie.replace(/(vusession=)[^;]*/, `$1${vusession}`);
}
$.info("刷新vusession成功")
} else {
$.warn("刷新vusession失败");
}
resolve();
}
}
)
})
}
async function getVipInfo() {
return new Promise((resolve, reject) => {
let opt = {
url: `https://vip.video.qq.com/rpc/trpc.query_vipinfo.vipinfo.QueryVipInfo/GetVipUserInfoH5`,
headers: {
cookie: txspCookie,
'Content-Type': 'application/json'
},
body: JSON.stringify({"geticon":1,"viptype":"svip|sports|nfl","platform":5})
};
$.post(opt, async (error, resp, data) => {
try {
if (safeGet(data)) {
var obj = JSON.parse(data);
if (!obj.servicetype) {
throw new Error(`Cookie已失效`);
} else {
if (obj.vip === 1){
isTxspVip = true;
endTime = obj.endTime;
level = obj.level;
score = obj.score;
}
if (obj.svip_info.vip === 1){
isTxspSvip = true;
svipEndTime = obj.svip_info.endTime;
}
if (obj.sports.vip.vip === 1){
isTxSportsVip = true;
txSportsEndTime = obj.sports.vip.endTime;
txSportsLevel = obj.sports.vip.level;
txSportsScore = obj.sports.vip.score;
}
if (obj.sports.svip.vip === 1){
isTxSportsSvip = true;
txSportsSvipEndTime = obj.sports.svip.endTime;
}
}
resolve();
}
} catch (e) {
$.error(e);
reject(`该账号本次跳过执行\n`);
}
}
)
})
}
/**
* 获取腾讯视频任务列表
* @async
* @function readTxspTaskList
* @returns
*/
async function readTxspTaskList() {
return new Promise((resolve) => {
let opt = {
url: `https://vip.video.qq.com/rpc/trpc.new_task_system.task_system.TaskSystem/ReadTaskList?rpc_data={"business_id":"1","platform":5}`,
headers: {
Referer: "https://film.video.qq.com/x/grade/?ptag=user.apho&ovscroll=0&hidetitlebar=1&aid=V0$$1:0$2:7$3:8.11.01.25068$4:0$8:4&isDarkMode=1&uiType=REGULAR",
Cookie: txspCookie,
},
};
$.get(opt, async (error, resp, data) => {
try {
if (safeGet(data)) {
var obj = JSON.parse(data);
var code = obj.ret;
let task_maintitle = "";
if (code === 0) {
month_received_score = obj.limit_info.month_received_score;
month_limit = obj.limit_info.month_limit;
let taskList = obj.task_list;
let txspCheckInTask = taskList && taskList.find(task => task.task_maintitle === "VIP会员每日签到");
isTxspCheckIn = txspCheckInTask.task_status;
} else {
$.warn(`获取腾讯视频任务列表失败,异常详细信息如下\n${data}`);
}
resolve();
}
} catch (e) {
$.error(e);
}
});
});
}
/**
* 腾讯视频签到领取V力值
* @async
* @function txspCheckIn
* @returns
*/
async function txspCheckIn() {
return new Promise((resolve, reject) => {
let opt = {
url: `https://vip.video.qq.com/rpc/trpc.new_task_system.task_system.TaskSystem/CheckIn?rpc_data={}`,
headers: {
Referer: "https://film.video.qq.com/x/grade/?ptag=user.apho&ovscroll=0&hidetitlebar=1&aid=V0$$1:0$2:7$3:8.11.01.25068$4:0$8:4&isDarkMode=1&uiType=REGULAR",
Cookie: txspCookie,
},
};
$.get(opt, async (error, resp, data) => {
var obj = JSON.parse(data);
var code = obj.ret;
if (code === 0 && obj.check_in_score != undefined) {
$.info(`签到成功:获得${obj.check_in_score}V力值`);
$.taskInfo = `签到成功:获得${obj.check_in_score}V力值\n`;
} else if (code === -2002) {
$.info(`今天已签到, 明日再来吧`);
$.taskInfo = `今天已签到, 明日再来吧\n`;
} else {
$.warn(`签到失败,异常详细信息如下\n${data}`);
$.taskInfo = `签到失败, 异常详细信息请查看日志\n`;
}
resolve();
});
});
}
/**
* 获取腾讯体育任务列表
* @async
* @function readTxSportsTaskList
* @returns
*/
async function readTxSportsTaskList() {
return new Promise((resolve) => {
let opt = {
url: `https://vip.video.qq.com/rpc/trpc.new_task_system.task_system.TaskSystem/ReadTaskList?rpc_data={"business_id":3,"channel_id":4,"platform":5}`,
headers: {
Referer: "https://film.video.qq.com/x/sports-grade/?ovscroll=0&hidetitlebar=1&immersive=1",
Cookie: txspCookie,
},
};
$.get(opt, async (error, resp, data) => {
try {
if (safeGet(data)) {
var obj = JSON.parse(data);
var code = obj.ret;
let task_maintitle = "";
if (code === 0) {
let taskList = obj.task_list;
let txSportsCheckInTasks = taskList && taskList.find(task => task.task_maintitle === "每日签到");
isTxSportsCheckIn = txSportsCheckInTasks.task_status;
} else {
$.warn(`获取腾讯视频任务列表失败,异常详细信息如下\n${data}`);
}
resolve();
}
} catch (e) {
$.error(e);
}
});
});
}
/**
* 腾讯体育签到领取热爱值
* @async
* @function txSportsCheckIn
* @returns
*/
async function txSportsCheckIn() {
return new Promise((resolve, reject) => {
let opt = {
url: `https://vip.video.qq.com/rpc/trpc.new_task_system.task_system.TaskSystem/CheckIn?rpc_data={"task_id":8006}`,
headers: {
Referer:
"https://film.video.qq.com/x/sports-grade/?ovscroll=0&hidetitlebar=1&immersive=1",
Cookie: txspCookie,
},
};
$.get(opt, async (error, resp, data) => {
var obj = JSON.parse(data);
var code = obj.ret;
if (code === 0 && obj.check_in_score != undefined) {
$.info(`签到成功:获得${obj.check_in_score}热爱值`);
$.taskInfo += `签到成功:获得${obj.check_in_score}热爱值\n`;
} else if (code === -2002) {
$.info(`今天已签到, 明日再来吧`);
$.taskInfo += `今天已签到, 明日再来吧\n`;
} else {
$.warn(`签到失败,异常详细信息如下\n${data}`);
$.taskInfo += `签到失败, 异常详细信息请查看日志\n`;
}
resolve();
});
});
}
/**
* 领取每日球票
* @async
* @function getDayTicket
* @returns
*/
async function getDayTicket() {
return new Promise((resolve, reject) => {
let opt = {
url: "https://activity.video.qq.com/fcgi-bin/asyn_activity?otype=xjson&act_id=118561&module_id=158089&type=90&option=5",
headers: {
Origin: "https://film.video.qq.com",
Referer: "https://film.video.qq.com/x/sports-vip-channel/?from=tab",
Cookie: txspCookie,
},
};
$.get(opt, async (error, resp, data) => {
try {
var obj = JSON.parse(data);
var code = obj.ret;
if (code === 0) {
$.info(`领取每日球票成功`);
$.taskInfo += `领取每日球票成功\n`;
} else if (code === -2021) {
$.info(`每日球票已领取, 明日再来吧`);
$.taskInfo += `每日球票已领取, 明日再来吧\n`;
} else {
$.warn(`领取每日球票失败,异常详细信息如下\n${data}`);
$.taskInfo += `领取每日球票失败,异常详细信息请查看日志\n`;
}
} catch (e) {
$.error(e);
} finally {
resolve();
}
});
});
}
/**
* 领取每月球票
* @async
* @function getMonthTicket
* @returns
*/
async function getMonthTicket() {
return new Promise((resolve, reject) => {
let opt = {
url: "https://activity.video.qq.com/fcgi-bin/asyn_activity?otype=xjson&act_id=118561&module_id=165163&type=100160&option=100",
headers: {
Origin: "https://film.video.qq.com",
Referer: "https://film.video.qq.com/x/sports-vip-channel/?from=tab",
Cookie: txspCookie,
},
};
$.get(opt, async (error, resp, data) => {
try {
var obj = JSON.parse(data);
var code = obj.ret;
if (code === 0) {
$.info(`领取每月球票成功`);
$.taskInfo += `领取每月球票成功\n`;
} else if (code === -903) {
$.info(`每月球票已领取,下个月再来哦`);
$.taskInfo += `每月球票已领取,下个月再来哦\n`;
} else {
$.warn(`领取每月球票失败,异常详细信息如下\n${data}`);
$.taskInfo += `领取每月球票失败,异常详细信息请查看日志\n`;
}
} catch (e) {
$.error(e);
} finally {
resolve();
}
});
});
}
/**
* 抽抽乐 2024年2月29日10点下线
* @async
* @function lottery()
* @returns
*/
async function lottery() {
return new Promise((resolve, reject) => {
let opt = {
url: "https://activity.video.qq.com/fcgi-bin/asyn_activity?otype=xjson&act_id=118561&module_id=158090&type=100143&option=100",
headers: {
Origin: "https://film.video.qq.com",
Referer: "https://film.video.qq.com/x/sports-vip-channel/?from=tab",
Cookie: txspCookie,
},
};
$.get(opt, async (error, resp, data) => {
try {
var obj = JSON.parse(data);
var code = obj.ret;
if (code === 0) {
$.info(`抽奖成功: ${obj.lotter_ext}`);
} else if (code === -904) {
$.info(`今天已抽奖, 明日再来吧`);
} else {
$.warn(`抽奖失败,异常详细信息如下\n${data}`);
}
} catch (e) {
$.error(e);
} finally {
resolve();
}
});
});
}
function getCookie() {
if($request && $request.method !=`OPTIONS` && $request.url.match(/\/rpc\/trpc\.new_task_system\.task_system\.TaskSystem\/ReadTaskList/)){
let txsp = $request.headers["Cookie"] || $request.headers["cookie"];
if (txsp) {
if (typeof txspCookie === "undefined" || (txspCookie && txspCookie.length === 0)) {
$.setdata(txsp, "txspCookie");
$.log(`Cookie: ${txsp}`);
$.msg($.name, "🎉 Cookie写入成功", "不用请自行关闭重写!");
} else if (txsp !== txspCookie) {
$.setdata(txsp, "txspCookie");
$.log(`Cookie: ${txsp}`);
$.msg($.name, "🎉 Cookie更新成功", "不用请自行关闭重写!");
} else {
$.msg($.name, "⚠️ Cookie未变动 跳过更新", "不用请自行关闭重写!");
}
} else {
$.msg($.name, "⚠️ Cookie未找到", "不用请自行关闭重写!");
}
}
if($request && $request.method !=`OPTIONS` && $request.url.match(/\/trpc\.videosearch\.hot_rank\.HotRankServantHttp\/HotRankHttp/)){
let refreshCookie = $request.headers["Cookie"] || $request.headers["cookie"];
if (refreshCookie) {
if (typeof txspRefreshCookie === "undefined" || (txspRefreshCookie && txspRefreshCookie.length === 0)) {
$.setdata(refreshCookie, "txspRefreshCookie");
$.log(`Cookie: ${refreshCookie}`);
$.msg($.name, "🎉 refreshCookie写入成功", "不用请自行关闭重写!");
} else if (refreshCookie !== txspRefreshCookie) {
$.setdata(refreshCookie, "txspRefreshCookie");
$.log(`Cookie: ${refreshCookie}`);
$.msg($.name, "🎉 refreshCookie更新成功", "不用请自行关闭重写!");
} else {
$.msg($.name, "⚠️ refreshCookie未变动 跳过更新", "不用请自行关闭重写!");
}
} else {
$.msg($.name, "⚠️ refreshCookie未找到", "不用请自行关闭重写!");
}
}
if($request && $request.method !=`OPTIONS` && $request.url.match(/\/trpc\.video_account_login\.web_login_trpc\.WebLoginTrpc\/NewRefresh/)){
let refreshBody = $request.body;
if (refreshBody){
if (typeof txspRefreshBody === "undefined" || (txspRefreshBody && txspRefreshBody.length === 0)) {
$.setdata(refreshBody, "txspRefreshBody");
$.log(`refreshBody: ${refreshBody}`);
$.msg($.name, "🎉 refreshBody写入成功", "不用请自行关闭重写!");
} else if (refreshBody !== txspRefreshBody) {
$.setdata(refreshBody, "txspRefreshBody");
$.log(`refreshBody: ${refreshBody}`);
$.msg($.name, "🎉 refreshBody更新成功", "不用请自行关闭重写!");
} else {
$.msg($.name, "⚠️ refreshBody未变动 跳过更新", "不用请自行关闭重写!");
}
}
}
}
async function getNotice() {
return new Promise((resolve) => {
let opt = {
url: "https://github.wowyijiu.today/https://raw.githubusercontent.com/WowYiJiu/Personal/main/WowYiJiu.json",
timeout: 10000,
};
$.get(opt, async (error, resp, data) => {
try {
if (error) {
$.error("👾 获取免责声明失败");
resolve();
} else {
if (data) {
var obj = JSON.parse(data);
$.log(obj.notice);
resolve();
}
}
} catch (e) {
$.error(e);
resolve();
}
});
});
}
async function getVersion() {
const timeoutMs = 10000;
const opt = {
url: "https://github.wowyijiu.today/https://raw.githubusercontent.com/WowYiJiu/Personal/main/Script/tenvideo.js",
timeout: timeoutMs
};
const data = await new Promise((resolve) => {
$.get(opt, (error, resp, data) => {
if (error) {
resolve("undefined");
} else {
resolve(data);
}
});
});
const versionInfo = data.match(/@version\s+(v\d+\.\d+\.\d+)/);
if (versionInfo) {
latestVersion = versionInfo[1];
} else {
latestVersion = "undefined";
}
return latestVersion;
}
async function SendMsg() {
if (Notify > 0) {
if ($.isNode()) {
await notify.sendNotify($.name, `${$.version}\n\n${$.desc}`);
} else {
$.msg($.name, "", `${$.version}\n${$.taskInfo}`);
}
} else {
$.msg($.name, "", `${$.version}\n${$.taskInfo}`);
}
}
async function waitRandom(min, max) {
var time = getRandomInt(min, max);
await $.wait(time);
}
// 随机生成整数
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// 提取Cookie的指定字段
function extractValues(str, keys) {
let results = keys.map((key) =>
str.split("; ").find((s) => s.startsWith(key + "="))
);
return results.join(";");
}
// 判断时间戳是不是今天
function isToday(timestamp) {
let date = new Date(timestamp);
let today = new Date();
return (
date.getDate() === today.getDate() &&
date.getMonth() === today.getMonth() &&
date.getFullYear() === today.getFullYear()
);
}
function safeGet(data) {
try {
if (typeof JSON.parse(data) == "object") {
return true;
}
} catch (e) {
$.error(e);
$.error(`腾讯视频访问数据为空,请检查Cookie是否有效`);
return false;
}
}
// prettier-ignore
function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise(((e,i)=>{s.call(this,t,((t,s,o)=>{t?i(t):e(s)}))}))}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.logLevels={debug:0,info:1,warn:2,error:3},this.logLevelPrefixs={debug:" DEBUG",info:" INFO",warn:" WARN",error:" ERROR"},this.logLevel="info",this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.encoding="utf-8",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}getEnv(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":void 0}isNode(){return"Node.js"===this.getEnv()}isQuanX(){return"Quantumult X"===this.getEnv()}isSurge(){return"Surge"===this.getEnv()}isLoon(){return"Loon"===this.getEnv()}isShadowrocket(){return"Shadowrocket"===this.getEnv()}isStash(){return"Stash"===this.getEnv()}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null,...s){try{return JSON.stringify(t,...s)}catch{return e}}getjson(t,e){let s=e;if(this.getdata(t))try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise((e=>{this.get({url:t},((t,s,i)=>e(i)))}))}runScript(t,e){return new Promise((s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=e&&e.timeout?e.timeout:o;const[r,a]=i.split("@"),n={url:`http://${a}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":r,Accept:"*/*"},timeout:o};this.post(n,((t,e,i)=>s(i)))})).catch((t=>this.logErr(t)))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),o=JSON.stringify(this.data);s?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(e,o):this.fs.writeFileSync(t,o)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return s;return o}lodash_set(t,e,s){return Object(t)!==t||(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce(((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{}),t)[e[e.length-1]]=s),t}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),o=s?this.getval(s):"";if(o)try{const t=JSON.parse(o);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(e),r=this.getval(i),a=i?"null"===r?null:r||"{}":"{}";try{const e=JSON.parse(a);this.lodash_set(e,o,t),s=this.setval(JSON.stringify(e),i)}catch(e){const r={};this.lodash_set(r,o,t),s=this.setval(JSON.stringify(r),i)}}else s=this.setval(t,e);return s}getval(t){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.read(t);case"Quantumult X":return $prefs.valueForKey(t);case"Node.js":return this.data=this.loaddata(),this.data[t];default:return this.data&&this.data[t]||null}}setval(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.write(t,e);case"Quantumult X":return $prefs.setValueForKey(t,e);case"Node.js":return this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0;default:return this.data&&this.data[e]||null}}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.cookie&&void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar)))}get(t,e=(()=>{})){switch(t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"],delete t.headers["content-type"],delete t.headers["content-length"]),t.params&&(t.url+="?"+this.queryStr(t.params)),void 0===t.followRedirect||t.followRedirect||((this.isSurge()||this.isLoon())&&(t["auto-redirect"]=!1),this.isQuanX()&&(t.opts?t.opts.redirection=!1:t.opts={redirection:!1})),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,((t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,i)}));break;case"Quantumult X":this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then((t=>{const{statusCode:s,statusCode:i,headers:o,body:r,bodyBytes:a}=t;e(null,{status:s,statusCode:i,headers:o,body:r,bodyBytes:a},r,a)}),(t=>e(t&&t.error||"UndefinedError")));break;case"Node.js":let s=require("iconv-lite");this.initGotEnv(t),this.got(t).on("redirect",((t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}})).then((t=>{const{statusCode:i,statusCode:o,headers:r,rawBody:a}=t,n=s.decode(a,this.encoding);e(null,{status:i,statusCode:o,headers:r,rawBody:a,body:n},n)}),(t=>{const{message:i,response:o}=t;e(i,o,o&&s.decode(o.rawBody,this.encoding))}));break}}post(t,e=(()=>{})){const s=t.method?t.method.toLocaleLowerCase():"post";switch(t.body&&t.headers&&!t.headers["Content-Type"]&&!t.headers["content-type"]&&(t.headers["content-type"]="application/x-www-form-urlencoded"),t.headers&&(delete t.headers["Content-Length"],delete t.headers["content-length"]),void 0===t.followRedirect||t.followRedirect||((this.isSurge()||this.isLoon())&&(t["auto-redirect"]=!1),this.isQuanX()&&(t.opts?t.opts.redirection=!1:t.opts={redirection:!1})),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient[s](t,((t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,i)}));break;case"Quantumult X":t.method=s,this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then((t=>{const{statusCode:s,statusCode:i,headers:o,body:r,bodyBytes:a}=t;e(null,{status:s,statusCode:i,headers:o,body:r,bodyBytes:a},r,a)}),(t=>e(t&&t.error||"UndefinedError")));break;case"Node.js":let i=require("iconv-lite");this.initGotEnv(t);const{url:o,...r}=t;this.got[s](o,r).then((t=>{const{statusCode:s,statusCode:o,headers:r,rawBody:a}=t,n=i.decode(a,this.encoding);e(null,{status:s,statusCode:o,headers:r,rawBody:a,body:n},n)}),(t=>{const{message:s,response:o}=t;e(s,o,o&&i.decode(o.rawBody,this.encoding))}));break}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length)));return t}queryStr(t){let e="";for(const s in t){let i=t[s];null!=i&&""!==i&&("object"==typeof i&&(i=JSON.stringify(i)),e+=`${s}=${i}&`)}return e=e.substring(0,e.length-1),e}msg(e=t,s="",i="",o={}){const r=t=>{const{$open:e,$copy:s,$media:i,$mediaMime:o}=t;switch(typeof t){case void 0:return t;case"string":switch(this.getEnv()){case"Surge":case"Stash":default:return{url:t};case"Loon":case"Shadowrocket":return t;case"Quantumult X":return{"open-url":t};case"Node.js":return}case"object":switch(this.getEnv()){case"Surge":case"Stash":case"Shadowrocket":default:{const r={};let a=t.openUrl||t.url||t["open-url"]||e;a&&Object.assign(r,{action:"open-url",url:a});let n=t["update-pasteboard"]||t.updatePasteboard||s;if(n&&Object.assign(r,{action:"clipboard",text:n}),i){let t,e,s;if(i.startsWith("http"))t=i;else if(i.startsWith("data:")){const[t]=i.split(";"),[,o]=i.split(",");e=o,s=t.replace("data:","")}else{e=i,s=(t=>{const e={JVBERi0:"application/pdf",R0lGODdh:"image/gif",R0lGODlh:"image/gif",iVBORw0KGgo:"image/png","/9j/":"image/jpg"};for(var s in e)if(0===t.indexOf(s))return e[s];return null})(i)}Object.assign(r,{"media-url":t,"media-base64":e,"media-base64-mime":o??s})}return Object.assign(r,{"auto-dismiss":t["auto-dismiss"],sound:t.sound}),r}case"Loon":{const s={};let o=t.openUrl||t.url||t["open-url"]||e;o&&Object.assign(s,{openUrl:o});let r=t.mediaUrl||t["media-url"];return i?.startsWith("http")&&(r=i),r&&Object.assign(s,{mediaUrl:r}),console.log(JSON.stringify(s)),s}case"Quantumult X":{const o={};let r=t["open-url"]||t.url||t.openUrl||e;r&&Object.assign(o,{"open-url":r});let a=t["media-url"]||t.mediaUrl;i?.startsWith("http")&&(a=i),a&&Object.assign(o,{"media-url":a});let n=t["update-pasteboard"]||t.updatePasteboard||s;return n&&Object.assign(o,{"update-pasteboard":n}),console.log(JSON.stringify(o)),o}case"Node.js":return}default:return}};if(!this.isMute)switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:$notification.post(e,s,i,r(o));break;case"Quantumult X":$notify(e,s,i,r(o));break;case"Node.js":break}if(!this.isMuteLog){let t=["","==============📣系统通知📣=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}debug(...t){this.logLevels[this.logLevel]<=this.logLevels.debug&&(t.length>0&&(this.logs=[...this.logs,...t]),console.log(`[${this.time('HH:mm:ss')}${this.logLevelPrefixs.debug}] ${t.map((t=>t??String(t))).join(this.logSeparator)}`))}info(...t){this.logLevels[this.logLevel]<=this.logLevels.info&&(t.length>0&&(this.logs=[...this.logs,...t]),console.log(`[${this.time('HH:mm:ss')}${this.logLevelPrefixs.info}] ${t.map((t=>t??String(t))).join(this.logSeparator)}`))}warn(...t){this.logLevels[this.logLevel]<=this.logLevels.warn&&(t.length>0&&(this.logs=[...this.logs,...t]),console.log(`[${this.time('HH:mm:ss')}${this.logLevelPrefixs.warn}] ${t.map((t=>t??String(t))).join(this.logSeparator)}`))}error(...t){this.logLevels[this.logLevel]<=this.logLevels.error&&(t.length>0&&(this.logs=[...this.logs,...t]),console.log(`[${this.time('HH:mm:ss')}${this.logLevelPrefixs.error}] ${t.map((t=>t??String(t))).join(this.logSeparator)}`))}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.map((t=>t??String(t))).join(this.logSeparator))}logErr(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":case"Quantumult X":default:this.log("",`❗️${this.name}, 错误!`,e,t);break;case"Node.js":this.log("",`❗️${this.name}, 错误!`,e,void 0!==t.message?t.message:t,t.stack);break}}wait(t){return new Promise((e=>setTimeout(e,t)))}done(t={}){const e=((new Date).getTime()-this.startTime)/1e3;switch(this.log("",`🔔${this.name}, 结束! 🕛 ${e} 秒`),this.log(),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":case"Quantumult X":default:$done(t);break;case"Node.js":process.exit(1)}}}(t,e)}