forked from lyericwang/TaskConfig
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathall_in_one.js
1204 lines (1152 loc) · 47.4 KB
/
all_in_one.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
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
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const global = {
log: 1, //日志模式:0不显示 1全部显示 2精简显示,推荐值:1
parallel: false, //是否顺序签到(true则同时签到,可能会出现内存占用过高导致执行失败的情况;false则签到速度会慢一些,但是很稳)
sign: { //用于设置哪些需要进行签到,哪些不处理
baidu_tieba: true,
iqiyi: true,
_52pojie: true,
netease_music: true,
v2ex: true,
china_telecom: true,
rrtv: true,
eleme: false
},
data: {
china_telecom: "" //此处输入要签到的手机号码,半角双引号中间
}
}
//#region smartjs,用于兼容Surge和QuantumultX
/*
本作品用于QuantumultX和Surge之间js执行方法的转换
您只需书写其中任一软件的js,然后在您的js最【前面】追加上此段js即可
无需担心影响执行问题,具体原理是将QX和Surge的方法转换为互相可调用的方法
尚未测试是否支持import的方式进行使用,因此暂未export
如有问题或您有更好的改进方案,请前往 https://github.com/sazs34/TaskConfig/issues 提交内容,或直接进行pull request
您也可直接在tg中联系@wechatu
*/
// #region 固定头部
let isQuantumultX = typeof $task != 'undefined'; //判断当前运行环境是否是qx
let isSurge = typeof $httpClient != 'undefined'; //判断当前运行环境是否是surge
let isRequest = typeof $request != "undefined"; //判断是否是请求
// http请求
var $task = isQuantumultX ? $task : {};
var $httpClient = isSurge ? $httpClient : {};
// cookie读写
var $prefs = isQuantumultX ? $prefs : {};
var $persistentStore = isSurge ? $persistentStore : {};
// 消息通知
var $notify = isQuantumultX ? $notify : {};
var $notification = isSurge ? $notification : {};
var done = (value = {}) => isQuantumultX ? (isRequest ? $done(value) : null) : ((isRequest ? $done(value) : $done()));
// #endregion 固定头部
// #region 网络请求专用转换
if (isQuantumultX) {
var errorInfo = {
error: ''
};
$httpClient = {
get: (url, cb) => {
var urlObj;
if (typeof (url) == 'string') {
urlObj = {
url: url
}
} else {
urlObj = url;
}
$task.fetch(urlObj).then(response => {
cb(undefined, response, response.body)
}, reason => {
errorInfo.error = reason.error;
cb(errorInfo, response, '')
})
},
post: (url, cb) => {
var urlObj;
if (typeof (url) == 'string') {
urlObj = {
url: url
}
} else {
urlObj = url;
}
url.method = 'POST';
$task.fetch(urlObj).then(response => {
cb(undefined, response, response.body)
}, reason => {
errorInfo.error = reason.error;
cb(errorInfo, response, '')
})
}
}
}
if (isSurge) {
$task = {
fetch: url => {
//为了兼容qx中fetch的写法,所以永不reject
return new Promise((resolve, reject) => {
if (url.method == 'POST') {
$httpClient.post(url, (error, response, data) => {
if (response) {
response.body = data;
resolve(response, {
error: error
});
} else {
resolve(null, {
error: error
})
}
})
} else {
$httpClient.get(url, (error, response, data) => {
if (response) {
response.body = data;
resolve(response, {
error: error
});
} else {
resolve(null, {
error: error
})
}
})
}
})
}
}
}
// #endregion 网络请求专用转换
// #region cookie操作
if (isQuantumultX) {
$persistentStore = {
read: key => {
return $prefs.valueForKey(key);
},
write: (val, key) => {
return $prefs.setValueForKey(val, key);
}
}
}
if (isSurge) {
$prefs = {
valueForKey: key => {
return $persistentStore.read(key);
},
setValueForKey: (val, key) => {
return $persistentStore.write(val, key);
}
}
}
// #endregion
// #region 消息通知
//#endregion
//#endregion
let master = () => {
if (typeof $request != "undefined") {
getCookie();
} else {
execute();
}
}
let getCookie = () => {
//#region 基础配置
const config = {
baidu_tieba_h5: {
cookie: 'CookieTB',
name: '百度贴吧Cookie-H5',
Host: 'tieba.baidu.com'
},
baidu_tieba_app: {
cookie: 'CookieTB',
name: '百度贴吧Cookie-App',
Host: 'c.tieba.baidu.com'
},
iqiyi_app: {
cookie: 'CookieQY',
name: '爱奇艺Cookie-App',
Host: 'passport.iqiyi.com'
},
_52pojie: {
cookie: 'CookieWA',
name: '吾爱破解Cookie',
Host: 'www.52pojie.cn'
},
netease_music: {
cookie: 'CookieWY',
name: '网易云音乐Cookie',
Host: 'music.163.com'
},
v2ex: {
cookie: 'CookieV2ex',
name: 'V2EX-Cookie',
Host: 'www.v2ex.com'
},
jd: {
cookie: 'CookieJD',
name: '京东Cookie',
Host: 'api.m.jd.com'
},
china_telecom: {
cookie: 'cookie.10000',
name: '电信营业厅',
Host: 'wapside.189.cn'
},
eleme: {
cookie: "CookieELM",
name: '饿了么Cookie',
Host: 'ele.me'
},
rrtv: {
cookie: 'chavy_cookie_rrtv',
name: '人人视频Cookie',
Host: 'rr.tv'
}
}
//#endregion
//#region 查重方法,用于检测Cookie值是否发生变化以便于更新Cookie
let updateCookie = (config, newVal) => {
if (!newVal || !config) return;
var historyCookie = $prefs.valueForKey(config.cookie);
if (historyCookie) {
if (historyCookie != newVal) {
if ($prefs.setValueForKey(newVal, config.cookie)) {
$notify(`更新 ${config.name} 成功🎉`, "", "无需禁用脚本,仅Cookie改变时才会重新获取");
} else {
$notify(`更新 ${config.name} 失败!!!`, "", "");
}
} else {
//cookie未发生变化,不执行更新
}
} else {
if ($prefs.setValueForKey(newVal, config.cookie)) {
$notify(`首次写入 ${config.name} 成功🎉`, "", "无需禁用脚本,仅Cookie改变时才会重新获取");
} else {
$notify(`首次写入 ${config.name} 失败!!!`, "", "");
}
}
}
//#endregion
//#region 正式开始写入cookie
let request = $request;
var isValidRequest = request && request.headers && request.headers.Cookie
if (isValidRequest) {
let headers = request.headers;
// console.log(`【Cookie触发】${headers.Host}-${headers.Cookie}`)
//#region 百度贴吧-H5
if (headers.Host == config.baidu_tieba_h5.Host) {
var regex = /(^|)BDUSS=([^;]*)(;|$)/;
var matchInfo = headers.Cookie.match(regex);
if (matchInfo) {
var headerCookie = headers.Cookie.match(regex)[0];
updateCookie(config.baidu_tieba_h5, headerCookie);
}
}
//#endregion
//#region 百度贴吧-APP
if (headers.Host == config.baidu_tieba_app.Host) {
var regex = /(^|)BDUSS=([^;]*)(;|$)/;
var matchInfo = headers.Cookie.match(regex);
if (matchInfo) {
var headerCookie = headers.Cookie.match(regex)[0];
updateCookie(config.baidu_tieba_app, headerCookie);
}
}
//#endregion
//#region 爱奇艺-APP
if (headers.Host == config.iqiyi_app.Host) {
var regex = /authcookie=([A-Za-z0-9]+)/;
if (regex.test(request.url)) {
var headerCookie = regex.exec(request.url)[1];
updateCookie(config.iqiyi_app, headerCookie);
}
}
//#endregion
//#region 吾爱破解
if (headers.Host == config._52pojie.Host) {
var headerCookie = headers.Cookie;
updateCookie(config._52pojie, headerCookie);
}
//#endregion
//#region 网易云音乐
if (headers.Host == config.netease_music.Host) {
var headerCookie = headers.Cookie;
//这个cookie很调皮,会将WM_TID放置到最前面一次,导致cookie会检测到变化,实际值始终是一样的
if (headerCookie.indexOf("WM_TID=") > 0)
updateCookie(config.netease_music, headerCookie);
}
//#endregion
//#region V2EX
if (headers.Host == config.v2ex.Host) {
var headerCookie = headers.Cookie;
updateCookie(config.v2ex, headerCookie);
}
//#endregion
//#region 京东
if (headers.Host == config.jd.Host) {
var headerCookie = headers.Cookie;
updateCookie(config.jd, headerCookie);
}
//#endregion
//#region 中国电信
if (headers.Host.indexOf(config.china_telecom.Host) >= 0) {
var headerCookie = headers.Cookie;
updateCookie(config.china_telecom, headerCookie);
}
//#endregion
//#region 饿了么
if (headers.Host.indexOf(config.eleme.Host) >= 0) {
var headerCookie = headers.Cookie;
var cookieVal = helper.getCookieByName(headerCookie, "USERID");
updateCookie(config.eleme, cookieVal);
}
//#endregion
//#region 人人视频
if (headers.Host.indexOf(config.rrtv.Host) >= 0) {
var headerToken = headers.token;
updateCookie(config.rrtv, headerToken);
}
//#endregion
}
$done();
//#endregion
}
let execute = () => {
//#region 签到配置,请勿修改
const config = {
baidu_tieba: {
cookie: 'CookieTB',
name: '百度贴吧',
provider: {
list: {
url: "https://tieba.baidu.com/mo/q/newmoindex",
headers: {
"Content-Type": "application/octet-stream",
Referer: "https://tieba.baidu.com/index/tbwise/forum",
Cookie: '',
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16A366"
}
},
sign: {
url: "https://tieba.baidu.com/sign/add",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Cookie: '',
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_1_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/14B100 UCBrowser/10.7.5.650 Mobile"
},
body: ""
}
},
data: {
total: 0,
progress: 0,
result: [],
notify: ''
}
},
iqiyi: {
cookie: 'CookieQY',
name: '爱奇艺',
provider: {
url: 'https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask?autoSign=yes&P00001='
},
data: {
notify: ''
}
},
_52pojie: {
cookie: 'CookieWA',
name: '吾爱破解',
provider: {
url: `https://www.52pojie.cn/home.php?mod=task&do=apply&id=2&mobile=no`,
headers: {
Cookie: ''
}
},
data: {
notify: ''
}
},
netease_music: {
cookie: 'CookieWY',
name: '网易云音乐',
provider: {
app: {
url: `http://music.163.com/api/point/dailyTask?type=0`,
headers: {
Cookie: ''
}
},
pc: {
url: `http://music.163.com/api/point/dailyTask?type=1`,
headers: {
Cookie: ''
}
}
},
data: {
app: '',
pc: '',
notify: ''
}
},
v2ex: {
cookie: 'CookieV2ex',
name: 'V2EX',
provider: {
check: {
url: `https://www.v2ex.com/mission/daily`,
method: 'GET',
headers: {
Cookie: ''
}
},
sign: {
url: `https://www.v2ex.com/mission/daily/redeem?once=`,
method: 'GET',
headers: {
Cookie: ''
}
}
},
data: {
notify: ''
}
},
china_telecom: {
cookie: 'cookie.10000',
name: '中国电信',
provider: {
url: 'https://wapside.189.cn:9001/api/home/sign',
method: 'POST',
headers: {
"Content-Type": `application/json;charset=utf-8`,
"User-Agent": `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;CtClient;7.6.0;iOS;13.3;iPhone XR`,
"Host": `wapside.189.cn:9001`,
"Origin": `https://wapside.189.cn:9001`,
"Referer": `https://wapside.189.cn:9001/resources/dist/signInActivity.html?cmpid=jt-khd-my-zygn&ticket=0ab000281b4a8139f264620ae1d8b1ce067a6587921f90a6260dca4389a4e01a&version=7.6.0`,
Cookie: ''
},
body: JSON.stringify({
phone: global.data.china_telecom
})
},
data: {
notify: ''
}
},
eleme: {
cookie: 'CookieELM',
name: '饿了么',
provider: {
sign: {
url: `https://h5.ele.me/restapi/member/v2/users/`,
method: 'POST',
},
check: {
url: `https://h5.ele.me/restapi/member/v1/users/`,
method: 'GET',
},
prize: {
url: `https://h5.ele.me/restapi/member/v2/users/`,
method: 'POST',
body: ''
}
},
data: {
notify: ''
}
},
rrtv: {
cookie: 'chavy_cookie_rrtv',
name: '人人视频',
provider: {
daily: {
url: 'https://api.rr.tv/rrtv-activity/sign/sign',
method: 'POST',
headers: {
token: "",
clientType: 'ios_rrsp_jzsp',
'Accept-Encoding': 'gzip, deflate, br',
Connection: 'keep-alive',
clientVersion: '4.3.5',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Origin: 'https://mobile.rr.tv',
Referer: 'https://mobile.rr.tv/',
Accept: 'application/json, text/plain, */*',
Host: 'api.rr.tv',
'Accept-Language': 'zh-cn',
'Content-Length': '12',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
}
},
welfare: {
url: 'https://api.rr.tv/dailyWelfare/getWelfare',
method: 'POST',
headers: {
token: "",
clientType: 'web',
'Accept-Encoding': 'gzip, deflate, br',
Connection: 'keep-alive',
clientVersion: '0.0.1',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Origin: 'https://mobile.rr.tv',
Referer: 'https://mobile.rr.tv/mission/',
Accept: 'application/json, text/plain, */*',
Host: 'api.rr.tv',
'Accept-Language': 'zh-cn',
'Content-Length': '45',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
}
},
info: {
url: 'https://api.rr.tv/user/profile',
method: 'POST',
headers: {
token: "",
clientType: 'ios_rrsp_jzsp',
'Accept-Encoding': 'gzip, deflate, br',
Connection: 'keep-alive',
clientVersion: '4.3.5',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Origin: 'https://mobile.rr.tv',
Referer: 'https://mobile.rr.tv/mission/',
Accept: 'application/json, text/plain, */*',
Host: 'api.rr.tv',
'Accept-Language': 'zh-cn',
'Content-Length': '0',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
}
}
},
data: {
notify: '',
result: {
daily: null,
welfare: null
}
}
}
}
//#endregion
//#region 签到开始
//#region 百度贴吧
let sign_baidu_tieba = () => {
try {
if (!global.sign.baidu_tieba) {
record(`[${config.baidu_tieba.name}]未开启签到`);
return;
}
let cookieVal = $prefs.valueForKey(config.baidu_tieba.cookie);
let process = config.baidu_tieba.data;
let checkIsAllProcessed = () => {
if (process.total > process.result.length) return;
let totalNotify = `[${config.baidu_tieba.name}]签到结果`;
for (const res of process.result) {
if (res.errorCode == -1) {
totalNotify += `
[${res.bar}] 已经签到,当前等级${res.level},经验${res.exp}`;
} else {
totalNotify += `
[${res.bar}] ${res.errorCode==0?'签到成功':'签到失败'},${res.errorCode==0?res.errorMsg:('原因:'+res.errorMsg)}`;
}
}
record(totalNotify);
process.notify = `[${config.baidu_tieba.name}] 总签${process.result.length}个,成功${process.result.filter(it=>{return it.errorCode==-1||it.errorCode==0}).length}个,失败${process.result.filter(it=>{return it.errorCode>=1}).length}个`
finalNotify("baidu_tieba");
}
let signBars = (bars, tbs, index) => {
if (index >= bars.length) {
checkIsAllProcessed();
} else {
let bar = bars[index];
if (bar.is_sign == 1) {
process.result.push({
bar: `${bar.forum_name}`,
level: bar.user_level,
exp: bar.user_exp,
errorCode: -1,
errorMsg: "已签到"
});
signBars(bars, tbs, ++index);
} else {
config.baidu_tieba.provider.sign.body = `tbs=${tbs}&kw=${bar.forum_name}&ie=utf-8`;
config.baidu_tieba.provider.sign.headers.Cookie = cookieVal;
$task.fetch(config.baidu_tieba.provider.sign).then(response => {
try {
var addResult = JSON.parse(response.body);
if (addResult.no == 0) {
process.result.push({
bar: bar.forum_name,
errorCode: 0,
errorMsg: `获得${addResult.data.uinfo.cont_sign_num}积分,第${addResult.data.uinfo.user_sign_rank}个签到`
});
} else {
process.result.push({
bar: bar.forum_name,
errorCode: addResult.no,
errorMsg: addResult.error
});
}
} catch (e) {
process.result.push({
bar: bar.forum_name,
errorCode: 998,
errorMsg: '不应存在的错误'
})
}
signBars(bars, tbs, ++index);
}, reason => {
process.result.push({
bar: bar.forum_name,
errorCode: 999,
errorMsg: '接口错误'
});
signBars(bars, tbs, ++index);
});
}
}
}
let getList = () => {
if (!cookieVal) {
process.notify = `[${config.baidu_tieba.name}] 未获取到Cookie⚠️`;
record(process.notify);
finalNotify("baidu_tieba");
} else {
config.baidu_tieba.provider.list.headers.Cookie = cookieVal;
$task.fetch(config.baidu_tieba.provider.list).then(response => {
var body = JSON.parse(response.body);
var isSuccessResponse = body && body.no == 0 && body.error == "success" && body.data.tbs;
if (isSuccessResponse) {
process.total = body.data.like_forum.length;
if (body.data.like_forum && body.data.like_forum.length > 0) {
signBars(body.data.like_forum, body.data.tbs, 0);
} else {
process.notify = `[${config.baidu_tieba.name}] 签到失败-请确认您有关注的贴吧⚠️`
record(process.notify);
finalNotify("baidu_tieba");
}
} else {
process.notify = `[${config.baidu_tieba.name}] 签到失败-${(body && body.error) ? body.error : "接口数据获取失败"}⚠️`;
record(process.notify);
finalNotify("baidu_tieba");
}
}, reason => {
process.notify = `[${config.baidu_tieba.name}] 签到失败-未获取到签到列表⚠️`;
record(`${process.notify}-${reason.error}`);
finalNotify("baidu_tieba");
});
}
}
getList();
} catch (e) {
progress.notify = `[${config.baidu_tieba.name}] 脚本错误,详见日志`
finalNotify("baidu_tieba");
console.log(`AIO-BaiduTieba-${JSON.stringify(e)}`)
}
}
//#endregion
//#region 爱奇艺会员签到
let sign_iqiyi = () => {
if (!global.sign.iqiyi) {
record(`[${config.iqiyi.name}]未开启签到`);
return;
}
let cookieVal = $prefs.valueForKey(config.iqiyi.cookie);
if (!cookieVal) {
config.iqiyi.data.notify = `[${config.iqiyi.name}]未获取到Cookie⚠️`;
record(config.iqiyi.data.notify);
finalNotify("iqiyi");
return;
}
config.iqiyi.provider.url += cookieVal;
$task.fetch(config.iqiyi.provider).then(response => {
try {
var obj = JSON.parse(response.body);
if (obj && obj.msg == "成功") {
if (obj.data.signInfo.code == "A00000") {
config.iqiyi.data.notify = `[${config.iqiyi.name}]${obj.data.signInfo.msg}!${obj.data.signInfo.data.acquireGiftList[0]}, 连续签到${obj.data.signInfo.data.continueSignDaysSum}天 🎉`;
record(config.iqiyi.data.notify)
} else {
// console.log("failure response: \n" + response.body);
config.iqiyi.data.notify = `[${config.iqiyi.name}]${obj.data.signInfo.msg}⚠️`;
record(`${config.iqiyi.data.notify}${obj.data.signInfo.msg}`);
}
} else {
config.iqiyi.data.notify = `[${config.iqiyi.name}]签到失败⚠️`;
record(`${config.iqiyi.data.notify}${obj.msg}`);
}
} catch (e) {
config.iqiyi.data.notify = `[${config.iqiyi.name}]签到失败,数据解析失败⚠️`;
record(`${config.iqiyi.data.notify}-${JSON.stringify(e)}`);
}
finalNotify("iqiyi");
}, reason => {
config.iqiyi.data.notify = `[${config.iqiyi.name}]签到失败!网络请求异常⚠️`;
finalNotify("iqiyi");
record(`${config.iqiyi.data.notify} : ${reason.error}`);
});
}
//#endregion
//#region 网易云音乐
let sign_netease_music = () => {
if (!global.sign.netease_music) {
record(`[${config.netease_music.name}] 未开启签到`);
return;
}
let cookieVal = $prefs.valueForKey(config.netease_music.cookie);
if (!cookieVal) {
config.netease_music.data.notify = `[${config.netease_music.name}] 未获取到Cookie`;
record(config.netease_music.data.notify);
finalNotify('netease_music');
return;
}
let sign = (type) => {
// record(`网易云-sign-${type}`)
config.netease_music.provider[type].headers.Cookie = cookieVal;
$task.fetch(config.netease_music.provider[type]).then(response => {
let result = JSON.parse(response.body);
combain(result, type);
}, reason => {
var signInfo = {};
signInfo.code = 999;
signInfo.msg = reason.error;
combain(signInfo, type);
});
}
let combain = (result, type) => {
// record(`网易云-combain-${type}-${JSON.stringify(result)}`)
try {
if (result.code == 200) {
//success
config.netease_music.data[type] = '签到成功🎉';
} else if (result.code == -2) {
//signed
config.netease_music.data[type] = '重复签到🎉';
} else if (result.code == 301) {
//signed
config.netease_music.data[type] = 'Cookie失效⚠️';
} else {
//failed
config.netease_music.data[type] = '未知错误⚠️';
}
} catch (e) {
config.netease_music.data[type] = '未知错误见日志⚠️';
record(`网易云报错-${JSON.stringify(e)}`);
}
checkIsAllProcessed();
}
let checkIsAllProcessed = () => {
record(`[${config.netease_music.name}]-check-${config.netease_music.data.pc}-${config.netease_music.data.app}`)
if (config.netease_music.data.pc && config.netease_music.data.app) {
config.netease_music.data.notify = `[${config.netease_music.name}] APP-${config.netease_music.data.app} PC-${config.netease_music.data.pc}`;
finalNotify('netease_music');
}
}
sign('app');
sign('pc');
}
//#endregion
//#region 吾爱破解
let sign__52pojie = () => {
if (!global.sign._52pojie) {
record(`[${config._52pojie.name}]未开启签到`);
return;
}
let cookieVal = $prefs.valueForKey(config._52pojie.cookie);
if (!cookieVal) {
config._52pojie.data.notify = `[${config._52pojie.name}] 未获取到Cookie⚠️`;
record(config._52pojie.data.notify);
finalNotify("_52pojie");
return;
}
config._52pojie.provider.headers.Cookie = cookieVal;
$task.fetch(config._52pojie.provider).then(response => {
try {
if (response.body.match(/\u606d\u559c\u60a8/)) {
//success
config._52pojie.data.notify = `[${config._52pojie.name}] 签到成功🎉`;
} else if (response.body.match(/\u4e0b\u671f\u518d\u6765/)) {
//repeat
config._52pojie.data.notify = `[${config._52pojie.name}] 重复签到🎉`;
} else if (response.body.match(/\u9700\u8981\u5148\u767b\u5f55/)) {
//cookie
config._52pojie.data.notify = `[${config._52pojie.name}] 未获取到Cookie⚠️`;
} else {
//script need update
config._52pojie.data.notify = `[${config._52pojie.name}] 脚本需更新⚠️`;
}
record(config._52pojie.data.notify);
} catch (e) {
config._52pojie.data.notify = `[${config._52pojie.name}] 脚本数据解析异常⚠️`;
record(`${config._52pojie.data.notify}-${JSON.stringify(e)}`)
}
finalNotify("_52pojie");
}, reason => {
config._52pojie.data.notify = `[${config._52pojie.name}] 签到失败!网络请求异常⚠️`;
finalNotify("_52pojie");
record(`${config._52pojie.data.notify} : ${reason.error}`);
});
}
//#endregion
//#region V2EX
let sign_v2ex = () => {
if (!global.sign.v2ex) {
record(`[${config.v2ex.name}] 未开启签到`);
return;
}
let cookieVal = $prefs.valueForKey(config.v2ex.cookie);
if (!cookieVal) {
config.v2ex.data.notify = `[${config.v2ex.name}] 未获取到Cookie⚠️`;
record(config.v2ex.data.notify);
finalNotify("v2ex");
return;
}
let checkSign = () => {
config.v2ex.provider.check.headers.Cookie = cookieVal;
$task.fetch(config.v2ex.provider.check).then(response => {
try {
let data = response.body;
if (data.indexOf('每日登录奖励已领取') >= 0) {
config.v2ex.data.notify = `[${config.v2ex.name}] 重复签到🎉`
record(config.v2ex.data.notify);
finalNotify("v2ex");
} else {
let regex = /<input[^>]*\/mission\/daily\/redeem\?once=(\d+)[^>]*>/g;
let code = regex.exec(data);
if (code) {
signMission(code[1])
}
}
} catch (e) {
config.v2ex.data.notify = `[${config.v2ex.name}] 签到失败!数据处理异常⚠️`;
record(`${config.v2ex.data.notify}-${JSON.stringify(e)}`);
finalNotify("v2ex");
}
}, reason => {
config.v2ex.data.notify = `[${config.v2ex.name}] 签到失败!网络请求异常⚠️`;
record(`${config.v2ex.data.notify}-${reason.error}`);
finalNotify("v2ex");
})
}
let signMission = code => {
config.v2ex.provider.sign.headers.Cookie = cookieVal;
config.v2ex.provider.sign.url = `https://www.v2ex.com/mission/daily/redeem?once=${code}`;
$task.fetch(config.v2ex.provider.sign).then(response => {
try {
let data = response.body;
if (data.indexOf('每日登录奖励已领取') >= 0) {
let days = 0;
let daysRegex = /已连续登录 (\d{1,10}) 天/;
if (daysRegex.test(data)) {
days = daysRegex.exec(data)[1]
}
config.v2ex.data.notify = `[${config.v2ex.name}] 签到成功🎉${days>0?`已连续签到${days}天`:''}`
record(config.v2ex.data.notify);
finalNotify("v2ex");
} else {
config.v2ex.data.notify = `[${config.v2ex.name}] 签到失败⚠️`
record(`${config.v2ex.data.notify}-签到响应数据中没有检测到'每日登录奖励已领取'字段,判定为签到失败,可自行访问${config.v2ex.provider.sign.url}进行签到`)
finalNotify("v2ex");
}
} catch (e) {
config.v2ex.data.notify = `[${config.v2ex.name}] 签到失败⚠️详见日志报错`
record(`${config.v2ex.data.notify}-${JSON.stringify(e)}`);
finalNotify("v2ex");
}
}, reason => {
config.v2ex.data.notify = `[${config.v2ex.name}] 签到失败!网络请求异常⚠️⚠️`;
record(`${config.v2ex.data.notify}-${reason.error}`);
finalNotify("v2ex");
})
}
checkSign();
}
//#endregion
//#region 中国电信营业厅
let sign_china_telecom = () => {
if (!global.sign.china_telecom) {
record(`[${config.china_telecom.name}]未开启签到`);
return;
}
if (!global.data.china_telecom) {
config.china_telecom.data.notify = `[${config.china_telecom.name}] 未配置对应的签到手机号`;
record(config.china_telecom.data.notify);
finalNotify("china_telecom");
return;
}
let cookieVal = $prefs.valueForKey(config.china_telecom.cookie);
if (!cookieVal) {
config.china_telecom.data.notify = `[${config.china_telecom.name}] 未获取到Cookie⚠️`;
record(`${config.china_telecom.data.notify}`);
finalNotify("china_telecom");
return;
}
config.china_telecom.provider.headers.Cookie = cookieVal;
$task.fetch(config.china_telecom.provider).then(response => {
try {
var body = JSON.parse(response.body);
if (body.resoultCode == "0") {
if (body.data.code == 1) {
config.china_telecom.data.notify = `[${config.china_telecom.name}] 签到成功,获得金币${body.data.coin}/金豆${body.data.flow}`;
} else if (body.data.code == 0) {
config.china_telecom.data.notify = `[${config.china_telecom.name}] 签到成功,${body.data.msg}`;
} else {
config.china_telecom.data.notify = `[${config.china_telecom.name}] ${body.data.msg}`;
}
} else {
config.china_telecom.data.notify = `[${config.china_telecom.name}] 签到失败, ${body.data.msg}-${body.resoultCode}`;
}
record(config.china_telecom.data.notify)
} catch (e) {
config.china_telecom.data.notify = `[${config.china_telecom.name}] 签到失败-e`;
record(`${config.china_telecom.data.notify}-error:${JSON.stringify(e)}`);
}
finalNotify("china_telecom");
}, reason => {
config.china_telecom.data.notify = `[${config.china_telecom.name}] 签到失败,${reason.error}`
record(config.china_telecom.data.notify)
finalNotify("china_telecom");
})
}
//#endregion
//#region 饿了么
let sign_eleme = () => {
if (!global.sign.eleme) {
record(`[${config.eleme.name}] 未开启签到`);
return;
}
let cookieVal = $prefs.valueForKey(config.eleme.cookie);
if (!cookieVal) {
config.eleme.data.notify = `[${config.eleme.name}] 未获取到Cookie⚠️`;
record(config.eleme.data.notify);
finalNotify("eleme");
return;
}
let eleUserId = cookieVal;
let sign = () => {
config.eleme.provider.sign.url += `${eleUserId}/sign_in`;
$task.fetch(config.eleme.provider.sign).then(response => {
try {
if (response.statusCode == 200) {
config.eleme.data.notify = `[${config.eleme.name}] 签到成功🎉`;
record(config.eleme.data.notify);
finalNotify("eleme");
// prize();
} else {
check();
}
} catch (e) {
config.eleme.data.notify = `[${config.eleme.name}] 签到失败!数据解析异常⚠️`;
record(`${config.eleme.data.notify} : ${JSON.stringify(e)}`);
finalNotify("eleme");
}
}, reason => {
config.eleme.data.notify = `[${config.eleme.name}] 签到失败!网络请求异常⚠️`;
record(`${config.eleme.data.notify} : ${reason.error}`);
finalNotify("eleme");
})
}
let check = () => {
config.eleme.provider.check.url += `${eleUserId}/sign_in/info`;
$task.fetch(config.eleme.provider.check).then(resp => {
try {
let result = JSON.parse(resp.body);
if (result && result.has_signed_in_today) {
config.eleme.data.notify = `[${config.eleme.name}] 今日已签到🎉`;
} else {
config.eleme.data.notify = `[${config.eleme.name}] 签到失败`;