forked from QiQUQ/baiduwp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1689 lines (1642 loc) · 56.7 KB
/
index.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 BDUSS = '' //**INPUT YOUR BDUSS HERE**
const STOKEN = '' //**INPUT YOUR STOKEN HERE**
const SVIPBDUSS = '' //**INPUT YOUR SVIP BDUSS HERE**
const SVIPSTOKEN = '' //**INPUT YOUR SVIP STOKEN HERE** (optional, rapid need)
const INDEX_URL = '' // Input your index url here
const AUTH_USER = '' //**INPUT BASIC AUTH USERNAME (optional)**
const AUTH_PASS = '' //**INPUT BASIC AUTH SUPER SECRET PASSWORD (optional)**
const pwdBody = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Ling Macker"/>
<meta name="description" content="PanDownload网页版,百度网盘分享链接在线解析工具"/>
<meta name="keywords" content="PanDownload,百度网盘,分享链接,下载,不限速"/>
<link rel="icon" href="https://pandownload.com/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/limonte-sweetalert2/8.11.8/sweetalert2.all.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/js/bootstrap.min.js"></script>
<style>
body {
background-image: url("https://pandownload.com/img/baiduwp/bg.png");
}
.logo-img {
width: 1.1em;
position: relative;
top: -3px;
}
</style>
<meta name="referrer" content="never">
<title>请输入提取码</title>
<style>
.alert {
background-color: #FFFFFF;
position: relative;
top: 5em;
}
.alert-heading {
height: 0.8em;
}
</style>
<script>
$(function(){
Swal.fire({
title: '请输入提取码',
input: 'text',
inputAttributes: {
autocapitalize: 'off'
},
allowOutsideClick: false,
showCancelButton: false,
confirmButtonText: '提取文件',
preConfirm: (pwd) => {
const url = document.URL
let surl
if(url.includes('/s/1')){
surl = url.match(/\\/s\\/(1.+)/)[1]
}
else if(url.includes('/share/init?surl=')){
surl ='1'+ url.match(/init\\?surl=([0-9a-zA-Z_]+)/)[1]
}
$(document).ready(function(){
$('<form action="/" method="POST"><input type="hidden" name="surl" value="' + surl + '"><input type="hidden" name="pwd" value="' + pwd + '"></form>').appendTo('body').submit();
})
}
})
})
</script>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container">
<a class="navbar-brand" href="${INDEX_URL}">
<img src="https://pandownload.com/img/baiduwp/logo.png" class="img-fluid rounded logo-img mr-2" alt="LOGO">PanDownload
</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#collpase-bar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collpase-bar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="${INDEX_URL}">主页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/TkzcM/baiduwp" target="_blank">GitHub</a>
</li>
</ul>
</div>
</div>
</nav>
</body>
</html>`
const rapidhtml = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Ling Macker"/>
<meta name="description" content="PanDownload网页版,百度网盘分享链接在线解析工具"/>
<meta name="keywords" content="PanDownload,百度网盘,分享链接,下载,不限速"/>
<link rel="icon" href="https://pandownload.com/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/limonte-sweetalert2/8.11.8/sweetalert2.all.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/js/bootstrap.min.js"></script>
<style>
body {
background-image: url("https://pandownload.com/img/baiduwp/bg.png");
}
.logo-img {
width: 1.1em;
position: relative;
top: -3px;
}
</style>
<title>PanDownload网页版</title>
<style>
.form-inline input {
width: 500px;
}
.input-card {
position: relative;
top: 7.0em;
}
.card-header {
height: 3.2em;
font-size: 20px;
line-height: 2.0em;
}
form input,
form button {
height: 3em;
}
</style>
<link href="https://cdn.staticfile.org/font-awesome/5.8.1/css/all.min.css" rel="stylesheet">
<script>
function formatBytes(a,b=2){if(0===a)return"0 Bytes";const c=0>b?0:b,d=Math.floor(Math.log(a)/Math.log(1024));return parseFloat((a/Math.pow(1024,d)).toFixed(c))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][d]}
function atou(str) {
return decodeURIComponent(escape(window.atob(str)));
}
function Trim(str){
return str.replace(/(^\\s*)|(\\s*$)/g, "");
}
function dl(md5, slicemd5, flength, name) {
var form = $('<form method="post" action="/rapiddl" target="_blank"></form>');
form.append('<input type="hidden" name="md5" value="'+md5+'">');
form.append('<input type="hidden" name="slicemd5" value="'+slicemd5+'">');
form.append('<input type="hidden" name="flength" value="'+flength+'">');
form.append('<input type="hidden" name="name" value="'+name+'">');
$(document.body).append(form);
form.submit();
}
function getFileType(filename){
var point = filename.lastIndexOf(".");
var t = filename.substr(point+1);
if (t == ""){
return "";
}
t = t.toLowerCase();
return t;
}
function getIconClass(filename){
var filetype = {
file_video: ["wmv", "rmvb", "mpeg4", "mpeg2", "flv", "avi", "3gp", "mpga", "qt", "rm", "wmz", "wmd", "wvx", "wmx", "wm", "mpg", "mp4", "mkv", "mpeg", "mov", "asf", "m4v", "m3u8", "swf"],
file_audio: ["wma", "wav", "mp3", "aac", "ra", "ram", "mp2", "ogg", "aif", "mpega", "amr", "mid", "midi", "m4a", "flac"],
file_image: ["jpg", "jpeg", "gif", "bmp", "png", "jpe", "cur", "svgz", "ico"],
file_archive: ["rar", "zip", "7z", "iso"],
windows: ["exe"],
apple: ["ipa"],
android: ["apk"],
file_alt: ["txt", "rtf"],
file_excel: ["xls", "xlsx"],
file_word: ["doc", "docx"],
file_powerpoint: ["ppt", "pptx"],
file_pdf: ["pdf"],
};
var point = filename.lastIndexOf(".");
var t = filename.substr(point+1);
if (t == ""){
return "";
}
t = t.toLowerCase();
for(var icon in filetype) {
for(var type in filetype[icon]) {
if (t == filetype[icon][type])
{
return "fa-"+icon.replace('_', '-');
}
}
}
return "";
}
function replaceIcon(){
$(".fa-file").each(function(){
var icon = getIconClass($(this).next().text());
var filetype = getFileType($(this).next().text())
var type = icon.substring(8);
if (icon != "")
{
if (icon == "fa-windows" || icon == "fa-android" || icon == "fa-apple")
{
$(this).removeClass("far").addClass("fab");
}
$(this).removeClass("fa-file").addClass(icon);
}
});
}
function getLink(link) {
const bdpan = link.match(/bdpan:\\/\\/(.+)/);;
const pcs = link.match('BaiduPCS-Go');
const mengji = link.match(/.{32}#.{32}/);
const bdlink = link.match('bdlink(.+)');
if (bdpan){
const deb64 = atou(bdpan[1]);
const md5 = deb64.match(/\\|(.{32})\\|/)[1];
const slicemd5 = deb64.match(/\\|([^\\|]{32})$/)[1];
const file_length = deb64.match(/\\|([0-9]+)\\|/)[1];
const file_name = deb64.match(/^(.+\\.[a-zA-Z]{1,9})\\|/)[1];
return {'md5':md5,'slicemd5':slicemd5,'flength':file_length,'name':file_name};
}
else if (pcs){
const input = link;
const length = input.match(/length\\=([0-9]+)/)[1];
const md5 = input.match(/\\-md5\\=(.{32})/)[1];
const slicemd5 = input.match(/\\-slicemd5\\=(.{32})/)[1];
const file_name = input.match(/\\"(.+)\\"/)[1];
return {'md5':md5,'slicemd5':slicemd5,'flength':length,'name':file_name};
}
else if(mengji){
const input = link;
const md5 = input.match(/^(.{32})#/)[1];
const slicemd5 = input.match(/#(.{32})#/)[1];
const file_length = input.match(/#([0-9]+)#/)[1];
const file_name = Trim(input.match(/#[0-9]+#(.+)$/)[1]);
return {'md5':md5,'slicemd5':slicemd5,'flength':file_length,'name':file_name};
}
else if(bdlink){
let files = []
const bdlink1 = link.match('bdlink\\=([a-zA-Z0-9\\=\\/\\+]+\\={0,2})[\\#\\?\\&]?');
const bdlink2 = link.match('bdlink\\=([a-zA-Z0-9\\=\\/\\+]+\\={0,2})$');
let de_b64
if(bdlink1){
de_b64 = atou(bdlink1[1]);
if(de_b64.split('\\n').length > 1){
for (i=0;i<de_b64.split('\\n').length;i++)
files.push(getLink(de_b64.split('\\n')[i]))
return files
}
else if(de_b64.split('\\n').length == 1)
return getLink(de_b64);
}
else if(bdlink2){
de_b64 = atou(bdlink2[1]);
if(de_b64.split('\\n').length > 1){
for (i=0;i<de_b64.split('\\n').length;i++){
files.push(getLink(de_b64.split('\\n')[i]))
}
return files
}
else if(de_b64.split('\\n').length == 1)
return getLink(de_b64);
}
}
else{
return false;
}
}
function genFile() {
let file = []
const links = document.getElementById('links').value.split('\\n').filter(function(el){
return el != "" && el != null
});
for(i=0;i<links.length;i++){
const fileinfo = getLink(links[i])
if(fileinfo != false){
file.push(fileinfo);
}
else{
Swal.fire('未检测到有效链接');
return false;
}
}
let filelist = \`<ol class="breadcrumb my-4">
文件列表 <a href="">返回</a> </ol>
<div>
<ul class="list-group ">\`
function addFile(file){
const md5 = file['md5']
const slicemd5 = file['slicemd5']
const flength = file['flength']
const name = file['name']
return \`<li class="list-group-item border-muted rounded text-muted py-2">
<i class="far fa-file mr-2"></i>
<a href="javascript:void(0)" onclick="dl('\${md5}','\${slicemd5}','\${flength}','\${name}')">\${name}</a>
<span class="float-right">\${formatBytes(flength)}</span></li>\`
}
for(const f in file){
if(file[f].length > 1){
for(const fs in file[f]){
filelist += addFile(file[f][fs])
}
}
else if(file[f] ){
filelist += addFile(file[f])
}
}
const orig = document.getElementsByClassName("container")[1]
orig.innerHTML = ""
orig.innerHTML += filelist + "</ul></div></div></body></html>";
replaceIcon();
}
</script>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container">
<a class="navbar-brand" href="${INDEX_URL}">
<img src="https://pandownload.com/img/baiduwp/logo.png" class="img-fluid rounded logo-img mr-2" alt="LOGO">PanDownload
</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#collpase-bar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collpase-bar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="${INDEX_URL}">主页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/TkzcM/baiduwp" target="_blank">GitHub</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="col-lg-6 col-md-9 mx-auto mb-5 input-card">
<div class="card">
<div class="card-header bg-dark text-light">秒传链接在线解析</div>
<div class="card-body">
<form name="form1" method="post" action="./rapiddl">
<div class="form-group my-2">
<textarea type="text" class="form-control" id="links" name="surl" placeholder="秒传链接(支持批量解析,每行一条链接)">
</textarea>
</div>
<button type="button" onclick="genFile()" class="mt-4 mb-3 form-control btn btn-success btn-block">打开</button>
</form>
</div>
</div>
</div>
</div>
</body>
</html>`
const error = `
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Ling Macker"/>
<meta name="description" content="PanDownload网页版,百度网盘分享链接在线解析工具"/>
<meta name="keywords" content="PanDownload,百度网盘,分享链接,下载,不限速"/>
<link rel="icon" href="https://pandownload.com/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/js/bootstrap.min.js"></script>
<style>
body {
background-image: url("https://pandownload.com/img/baiduwp/bg.png");
}
.logo-img {
width: 1.1em;
position: relative;
top: -3px;
}
</style>
<meta name="referrer" content="never">
<title>提示</title>
<style>
.alert {
position: relative;
top: 5em;
}
.alert-heading {
height: 0.8em;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container">
<a class="navbar-brand" href="${INDEX_URL}">
<img src="https://pandownload.com/img/baiduwp/logo.png" class="img-fluid rounded logo-img mr-2" alt="LOGO">PanDownload
</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#collpase-bar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collpase-bar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="${INDEX_URL}">主页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/TkzcM/baiduwp" target="_blank">GitHub</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-7 col-sm-8 col-11">`
const previewHeader = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Ling Macker"/>
<meta name="description" content="PanDownload网页版,百度网盘分享链接在线解析工具"/>
<meta name="keywords" content="PanDownload,百度网盘,分享链接,下载,不限速"/>
<link rel="icon" href="https://pandownload.com/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/js/bootstrap.min.js"></script>
<script src="https://cdn.staticfile.org/dplayer/1.26.0/DPlayer.min.js"></script>
<style>
body {
background-image: url("https://pandownload.com/img/baiduwp/bg.png");
}
.logo-img {
width: 1.1em;
position: relative;
top: -3px;
}
#video{
max-width: 100%;
}
</style>
<meta name="referrer" content="never">
<title>视频预览</title>
<style>
.alert {
position: relative;
top: 3em;
}
.dplayer-logo {
pointer-events: none;
position: absolute;
left:auto;
right: 10px;
top: 10px;
max-width: 30px;
max-height: 30px;
}
.alert-heading {
height: 0.8em;
}
</style>
<script>`
const previewFooter = `</script>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container">
<a class="navbar-brand" href="${INDEX_URL}">
<img src="https://pandownload.com/img/baiduwp/logo.png" class="img-fluid rounded logo-img mr-2" alt="LOGO">PanDownload
</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#collpase-bar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collpase-bar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="${INDEX_URL}">主页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/TkzcM/baiduwp" target="_blank">GitHub</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid" id="video">
<div class="row justify-content-center">
<div class="col-md-7 col-sm-8 col-11">
<div class="alert alert-primary" role="alert">
<h5 class="alert-heading">视频预览 with ❤ DPlayer</h5>
<hr>
<p class="card-text"><a href="./help">如无法播放请按照教程修改UA</a><br><div id="dplayer"></div></p>
</div>
</div>
</div>
</div>
</body>
</html>`
const filebody = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Ling Macker"/>
<meta name="description" content="PanDownload网页版,百度网盘分享链接在线解析工具"/>
<meta name="keywords" content="PanDownload,百度网盘,分享链接,下载,不限速"/>
<link rel="icon" href="https://pandownload.com/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/js/bootstrap.min.js"></script>
<script src="https://cdn.staticfile.org/limonte-sweetalert2/8.11.8/sweetalert2.all.min.js"></script>
<style>
body {
background-image: url("https://pandownload.com/img/baiduwp/bg.png");
}
.logo-img {
width: 1.1em;
position: relative;
top: -3px;
}
</style>
<meta name="referrer" content="never">
<link href="https://cdn.staticfile.org/font-awesome/5.8.1/css/all.min.css" rel="stylesheet">
<title>文件列表</title>
<script>
function dl(fs_id, timestamp, sign, randsk, share_id, uk, fname) {
var form = $('<form method="post" action="/download" target="_blank"></form>');
form.append('<input type="hidden" name="fs_id" value="'+fs_id+'">');
form.append('<input type="hidden" name="time" value="'+timestamp+'">');
form.append('<input type="hidden" name="sign" value="'+sign+'">');
form.append('<input type="hidden" name="randsk" value="'+randsk+'">');
form.append('<input type="hidden" name="share_id" value="'+share_id+'">');
form.append('<input type="hidden" name="uk" value="'+uk+'">');
form.append('<input type="hidden" name="filename" value="'+fname+'">');
$(document.body).append(form);
form.submit();
}
function video(fs_id, timestamp, sign, randsk, share_id, uk, filetype){
Swal.fire({
title: '请选择',
icon: 'info',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#3085d6',
confirmButtonText: '下载',
cancelButtonText: '预览'
}).then((result) => {
if (result.value) {
dl(fs_id, timestamp, sign, randsk, share_id, uk);
}
else if(result.dismiss === Swal.DismissReason.cancel){
let form = $('<form method="post" action="/preview" target="_blank"></form>');
form.append('<input type="hidden" name="fs_id" value="'+fs_id+'">');
form.append('<input type="hidden" name="time" value="'+timestamp+'">');
form.append('<input type="hidden" name="sign" value="'+sign+'">');
form.append('<input type="hidden" name="randsk" value="'+randsk+'">');
form.append('<input type="hidden" name="share_id" value="'+share_id+'">');
form.append('<input type="hidden" name="uk" value="'+uk+'">');
form.append('<input type="hidden" name="filetype" value="'+filetype+'">');
$(document.body).append(form);
form.submit();
}
})
}
function getFileType(filename){
var point = filename.lastIndexOf(".");
var t = filename.substr(point+1);
if (t == ""){
return "";
}
t = t.toLowerCase();
return t;
}
function getIconClass(filename){
var filetype = {
file_video: ["wmv", "rmvb", "mpeg4", "mpeg2", "flv", "avi", "3gp", "mpga", "qt", "rm", "wmz", "wmd", "wvx", "wmx", "wm", "mpg", "mp4", "mkv", "mpeg", "mov", "asf", "m4v", "m3u8", "swf"],
file_audio: ["wma", "wav", "mp3", "aac", "ra", "ram", "mp2", "ogg", "aif", "mpega", "amr", "mid", "midi", "m4a", "flac"],
file_image: ["jpg", "jpeg", "gif", "bmp", "png", "jpe", "cur", "svgz", "ico"],
file_archive: ["rar", "zip", "7z", "iso"],
windows: ["exe"],
apple: ["ipa"],
android: ["apk"],
file_alt: ["txt", "rtf"],
file_excel: ["xls", "xlsx"],
file_word: ["doc", "docx"],
file_powerpoint: ["ppt", "pptx"],
file_pdf: ["pdf"],
};
var point = filename.lastIndexOf(".");
var t = filename.substr(point+1);
if (t == ""){
return "";
}
t = t.toLowerCase();
for(var icon in filetype) {
for(var type in filetype[icon]) {
if (t == filetype[icon][type])
{
return "fa-"+icon.replace('_', '-');
}
}
}
return "";
}
function goToDir(surl, pwd, randsk, shareid, uk, dir) {
var $form = $('<form>').attr('method', 'POST');
var appendFormItem = function(key, value) {
$form.append($('<input>').attr('type', 'hidden').attr('name', key).attr('value', value));
};
appendFormItem('surl', surl);
appendFormItem('pwd', pwd);
appendFormItem('randsk', randsk);
appendFormItem('shareid', shareid);
appendFormItem('uk', uk);
appendFormItem('dir', dir);
$form.appendTo($('body')).submit();
}
$(document).ready(function(){
$(".fa-file").each(function(){
var icon = getIconClass($(this).next().text());
var filetype = getFileType($(this).next().text())
var type = icon.substring(8);
if(type == 'video'||type == 'audio'){
const link = $(this).next().attr("onclick")
const postlink = link.substring(3,link.length-1)
$(this).next().attr("onclick","video("+postlink+",'"+filetype+"')")
}
if (icon != "")
{
if (icon == "fa-windows" || icon == "fa-android" || icon == "fa-apple")
{
$(this).removeClass("far").addClass("fab");
}
$(this).removeClass("fa-file").addClass(icon);
}
});
});
</script>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container">
<a class="navbar-brand" href="${INDEX_URL}">
<img src="https://pandownload.com/img/baiduwp/logo.png" class="img-fluid rounded logo-img mr-2" alt="LOGO">PanDownload
</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#collpase-bar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collpase-bar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="${INDEX_URL}">主页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/TkzcM/baiduwp" target="_blank">GitHub</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<ol class="breadcrumb my-4">
文件列表 </ol>
<div>
<ul class="list-group ">`
const error_div = `</div>
</div>
</div>
</body>
</html>`
const parseLink = async request => {
const url = await request.url
let innerRequest
if(url.includes('/s/1')){
const surl = url.match(/\/s\/(1[0-9a-zA-Z_-]+)/)[1]
const isPwd = await fetch('https://pan.baidu.com/s/'+surl,{
method:'HEAD',
redirect:'manual'
})
if(isPwd.status == 302){
return new Response(pwdBody,{ headers: { 'Content-Type': 'text/html;charset=UTF-8' } })
}
else if(isPwd.status == 200){
innerRequest = new Request('https://example.com/',{method:'POST',body:'surl='+surl,headers:{'Content-Type':'application/x-www-form-urlencoded'}})
return await generate(innerRequest)
}
else{
return new Response(error + `
<div class="alert alert-danger" role="alert">
<h5 class="alert-heading">提示</h5>
<hr>
<p class="card-text">CheckPwd Failed</p>
</div>` + error_div,{ headers: { 'Content-Type': 'text/html;charset=UTF-8' } })
}
}
else if(url.includes('/init?surl=')){
const surl = url.match(/init\?surl=([0-9a-zA-Z_-]+)/)[1]
const surl1 = '1'+ surl
const isPwd = await fetch('https://pan.baidu.com/s/'+surl1,{
method:'HEAD',
redirect:'manual'
})
if(isPwd.status == 302){
return new Response(pwdBody,{ headers: { 'Content-Type': 'text/html;charset=UTF-8' } })
}
else if(isPwd.status == 200){
innerRequest = new Request('https://example.com/',{method:'POST',body:'surl='+surl1,headers:{'Content-Type':'application/x-www-form-urlencoded'}})
return await generate(innerRequest)
}
else{
return new Response(error + `
<div class="alert alert-danger" role="alert">
<h5 class="alert-heading">提示</h5>
<hr>
<p class="card-text">CheckPwd Failed</p>
</div>` + error_div,{ headers: { 'Content-Type': 'text/html;charset=UTF-8' } })
}
}
}
const generate = async request => {
const text = await request.formData()
const surl = text.get('surl')
const pwd = text.get('pwd')
const dir = text.get('dir')
const uk = text.get('uk') || ''
const shareid = text.get('shareid') || ''
let randsk = text.get('randsk')
const headers = { 'Content-Type': 'text/html;charset=UTF-8' }
const surl_1 = surl.substring(1)
async function verifyPwd(surl,pwd){
if(pwd){
let formData1 = new FormData()
formData1.append('pwd',pwd)
const res = await fetch(`https://pan.baidu.com/share/verify?channel=chunlei&clienttype=0&web=1&app_id=250528&${surl_1 ? `surl=${surl_1}` : `uk=${uk}&shareid=${shareid}`}`,
{
body: formData1,
method: 'POST',
headers:{
'user-agent':'netdisk',
'Referer':'https://pan.baidu.com/disk/home'
}
}
)
const json1 = await res.json()
if(json1.errno == 0){
return json1.randsk
}
else {
return 1
}
}
else{
const res = await fetch(surl ? 'https://pan.baidu.com/s/1' + surl : `https://pan.baidu.com/share/link?uk=${uk}&shareid=${shareid}`,{
redirect:"manual"
})
if(res.status == 302){
return 1
}else{
const cookie = res.headers.get('set-cookie')
if(cookie.includes('BDCLND=')){
return cookie.match(/BDCLND\=(.+?)\;/)[1]
}
else{
return false
}
}
}
}
async function getSign(surl,randsk){
if(randsk == 1){
return 1
}
const res1 = await fetch(surl ? 'https://pan.baidu.com/s/1' + surl : `https://pan.baidu.com/share/link?uk=${uk}&shareid=${shareid}`,
{
method:'GET',
headers:{
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
'Cookie':'BDUSS=' + BDUSS + '; '
+ 'STOKEN=' + STOKEN + '; BDCLND=' + randsk
}
})
const body = await res1.text()
var re = /yunData.setData\(({.+)\);/
if(body.match(re)){
const json2 = JSON.parse(body.match(re)[1])
return json2
}
else {
return 1
}
}
async function getFileList(shareid,uk,randsk,dir){
const res2 = await fetch('https://pan.baidu.com/share/list?app_id=250528&channel='
+ 'chunlei&clienttype=0&desc=0&num=100&order=name&page=1&root=' + (+!dir) + '&shareid=' + shareid + '&showempty=0&uk='
+ uk + (dir ? '&dir=' + encodeURIComponent(dir) : '') + '&web=1',{
method:'GET',
headers:{
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
'Cookie':'BDUSS=' + BDUSS + ';'
+ 'STOKEN=' + STOKEN + '; BDCLND=' + randsk
}
})
const body = await res2.text()
return JSON.parse(body)
}
async function checkPwd(pwd){
if(pwd != ""){
return await verifyPwd(surl_1,pwd)
}
else{
return await verifyPwd(surl_1)
}
}
if (!randsk) {
randsk = await checkPwd(pwd)
}
const json2 = await getSign(surl_1,randsk)
let filecontent = ``
if(json2 != 1){
const sign = json2.sign
const timestamp = json2.timestamp
const shareid = json2.shareid
const uk = json2.uk
const filejson = await getFileList(shareid,uk,randsk,dir)
if (filejson.errno) {
return new Response(error + `
<div class="alert alert-danger" role="alert">
<h5 class="alert-heading">提示</h5>
<hr>
<p class="card-text">${filejson.show_msg || '提取码错误或文件失效'}</p>
</div>` + error_div, { headers })
}
if (dir) {
const dirParts = dir.split('/')
filecontent += `<li class="list-group-item border-muted rounded text-muted py-2" style="margin-bottom: 10px">
<i class="far fa-folder-open mr-2"></i>
${dirParts.map((e, i) => `<a href="javascript:void(0)" onclick="goToDir('${surl}', '${pwd}', '${randsk}', '${shareid}', '${uk}', '${dirParts.slice(0, i + 1).join('/')}')">${e}/</a>`).join('')}
<span class="float-right"></span>
</li>`
}
for(var i=0;i<filejson.list.length;i++){
const file = filejson.list[i]
if(file.isdir == 0){
filecontent += `<li class="list-group-item border-muted rounded text-muted py-2">
<i class="far fa-file mr-2"></i>
<a href="javascript:void(0)" onclick="dl('`+ file.fs_id + `',`+ timestamp +`,'`+ sign +`','` + randsk + `','`+shareid+`','`+ uk +`','`+ file.server_filename +`')">`+file.server_filename+`</a>
<span class="float-right">`+ formatBytes(file.size) +`</span>
</li>`
}
else {
filecontent += `<li class="list-group-item border-muted rounded text-muted py-2">
<i class="far fa-folder mr-2"></i>
<a href="javascript:void(0)" onclick="goToDir('${surl}', '${pwd}', '${randsk}', '${shareid}', '${uk}', '${file.path}')">`+file.server_filename+`</a>
<span class="float-right"></span>
</li>`
}
}
let filefoot = `</ul>
</div>
</div>
</body>
</html>`
return new Response(filebody+filecontent+filefoot, { headers })
}
else{
return new Response(error + `
<div class="alert alert-danger" role="alert">
<h5 class="alert-heading">提示</h5>
<hr>
<p class="card-text">提取码错误或文件失效</p>
</div>` + error_div, { headers })
}
}
const landing = `
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Ling Macker"/>
<meta name="description" content="PanDownload网页版,百度网盘分享链接在线解析工具"/>
<meta name="keywords" content="PanDownload,百度网盘,分享链接,下载,不限速"/>
<link rel="icon" href="https://pandownload.com/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.2/js/bootstrap.min.js"></script>
<style>
body {
background-image: url("https://pandownload.com/img/baiduwp/bg.png");
}
.logo-img {
width: 1.1em;
position: relative;
top: -3px;
}
</style>
<title>PanDownload网页版</title>
<style>
.form-inline input {
width: 500px;
}
.input-card {
position: relative;
top: 7.0em;
}
.card-header {
height: 3.2em;
font-size: 20px;
line-height: 2.0em;
}
form input,
form button {
height: 3em;
}
</style>
<script>
function validateForm() {
var link = document.forms["form1"]["surl"].value;
if (link == null || link == "") {
document.forms["form1"]["surl"].focus();
return false;
}
var uk = link.match(/uk=(\\d+)/);
var shareid = link.match(/shareid=(\\d+)/);
if (uk != null && shareid != null) {
document.forms["form1"]["surl"].value = "";
$("form").append('<input type="hidden" name="uk" value="' + uk[1] + '">');
$("form").append('<input type="hidden" name="shareid" value="' + shareid[1] + '">');
return true;
}
var surl = link.match(/surl=([A-Za-z0-9-_]+)/);
if (surl == null) {
surl = link.match(/1[A-Za-z0-9-_]+/);
if (surl == null) {
document.forms["form1"]["surl"].focus();
return false;
}
else {
surl = surl[0];
}
}
else {
surl = "1" + surl[1];
}
document.forms["form1"]["surl"].value = surl;
return true;
}
</script>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container">
<a class="navbar-brand" href="${INDEX_URL}">
<img src="https://pandownload.com/img/baiduwp/logo.png" class="img-fluid rounded logo-img mr-2" alt="LOGO">PanDownload
</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#collpase-bar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collpase-bar">
<ul class="navbar-nav">
<li class="nav-item">