forked from menhargai/BaiduNetdiskHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
baiduyun.user.js
1280 lines (1175 loc) · 60.4 KB
/
baiduyun.user.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
// ==UserScript==
// @name 百度网盘直链下载助手
// @namespace https://github.com/syhyz1990/baiduyun
// @version 2.9.1
// @icon https://www.baiduyun.wiki/48x48.png
// @description 【百度网盘直链下载助手】是一款免客户端获取百度网盘文件真实下载地址的油猴脚本,支持Windows,Mac,Linux,Android等多平台,可使用IDM,XDown等多线程加速工具加速下载,告别下载限速问题。
// @author syhyz1990
// @license AGPL
// @supportURL https://github.com/syhyz1990/baiduyun
// @updateURL https://www.baiduyun.wiki/baiduyun.user.js
// @match *://pan.baidu.com/disk/home*
// @match *://yun.baidu.com/disk/home*
// @match *://pan.baidu.com/s/*
// @match *://yun.baidu.com/s/*
// @match *://pan.baidu.com/share/*
// @match *://yun.baidu.com/share/*
// @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @require https://cdn.bootcss.com/sweetalert/2.1.2/sweetalert.min.js
// @connect baidu.com
// @connect meek.com.cn
// @run-at document-idle
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_setClipboard
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// ==/UserScript==
"use strict";
var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
return typeof e;
} : function (e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
};
!function () {
function e(e, t, i) {
e = e || "", t = t || "", i = i || "", console.group("[百度网盘直链下载助手]"), console.log(e, t, i), console.groupEnd();
}
function t(e, t) {
var i = localStorage.getItem("baiduyunPlugin_BDUSS") ? localStorage.getItem("baiduyunPlugin_BDUSS") : '{"baiduyunPlugin_BDUSS":""}',
n = JSON.parse(i).BDUSS;
return n ? 'aria2c "' + e + '" --out "' + t + '" --header "User-Agent: ' + m + '" --header "Cookie: BDUSS=' + n + '"' : (swal({
title: "提示",
text: "请先安装【百度网盘万能助手】",
buttons: {confirm: {text: "安装", value: "confirm"}}
}).then(function (e) {
"confirm" === e && (location.href = "https://www.baiduyun.wiki/zh-cn/assistant.html");
}), "请先安装百度网盘万能助手,安装后请重启浏览器!!!");
}
function i(e) {
return e ? e.replace(/&/g, "&") : "";
}
function n() {
function t() {
Z = N(), ee = B(), te = K(), ie = d(), ce = V(), "all" == ce && (pe = D()), "category" == ce && (ue = P()), "search" == ce && (fe = F()), a(), i(), n();
}
function i() {
"all" == ce ? ae = z() : "category" == ce ? ae = R() : "search" == ce && (ae = L());
}
function n() {
oe = [];
}
function a() {
de = s();
}
function s() {
return $("." + h.list).is(":hidden") ? "grid" : "list";
}
function l() {
p(), g(), w(), y(), k(), c();
}
function c() {
$(document).on("click", '[title="分享"]', function () {
var e = setInterval(function () {
0 === $("#share-method-public").length ? $(".share-method-line").parent().append('<div class="share-method-line"><input type="radio" id="share-method-public" name="share-method" value="public" checked><span class="icon radio-icon icon-radio-non"></span><label for="share-method-public"><b>公开分享</b><span>任何人访问链接即可查看,下载!</span></div>') : (clearInterval(e), $(document).off("click", '[title="分享"]'));
}, 100);
});
}
function p() {
window.addEventListener("hashchange", function (e) {
a(), "all" == V() ? ce == V() ? pe != D() && (pe = D(), i(), n()) : (ce = V(), pe = D(), i(), n()) : "category" == V() ? ce == V() ? ue != P() && (ce = V(), ue = P(), i(), n()) : (ce = V(), ue = P(), i(), n()) : "search" == V() && (ce == V() ? fe != F() && (ce = V(), fe = F(), i(), n()) : (ce = V(), fe = F(), i(), n()));
});
}
function g() {
$("a[data-type=list]").click(function () {
de = "list";
}), $("a[data-type=grid]").click(function () {
de = "grid";
});
}
function w() {
var t = $("span." + h.checkbox);
"grid" == de && (t = $("." + h["chekbox-grid"])), t.each(function (t, i) {
$(i).on("click", function (t) {
var i = $(this).parent(), n = void 0, a = void 0;
if ("list" == de ? (n = $("div.file-name div.text a", i).attr("title"), a = i.hasClass(h["item-active"])) : "grid" == de && (n = $("div.file-name a", $(this)).attr("title"), a = !$(this).hasClass(h["item-active"])), a) {
e("取消选中文件:" + n);
for (var o = 0; o < oe.length; o++) oe[o].filename == n && oe.splice(o, 1);
} else e("选中文件:" + n), $.each(ae, function (e, t) {
if (t.server_filename == n) {
var i = {filename: t.server_filename, path: t.path, fs_id: t.fs_id, isdir: t.isdir};
oe.push(i);
}
});
});
});
}
function b() {
$("span." + h.checkbox).each(function (e, t) {
$(t).unbind("click");
});
}
function y() {
$("div." + h["col-item"] + "." + h.check).each(function (t, i) {
$(i).bind("click", function (t) {
$(this).parent().hasClass(h.checked) ? (e("取消全选"), oe = []) : (e("全部选中"), oe = [], $.each(ae, function (e, t) {
var i = {filename: t.server_filename, path: t.path, fs_id: t.fs_id, isdir: t.isdir};
oe.push(i);
}));
});
});
}
function x() {
$("div." + h["col-item"] + "." + h.check).each(function (e, t) {
$(t).unbind("click");
});
}
function k() {
$("div." + h["list-view"] + " dd").each(function (t, i) {
$(i).bind("click", function (t) {
var i = t.target.nodeName.toLowerCase();
if ("span" != i && "a" != i && "em" != i) if (e("shiftKey:" + t.shiftKey), t.shiftKey) {
oe = [];
var n = $("div." + h["list-view"] + " dd." + h["item-active"]);
$.each(n, function (t, i) {
var n = $("div.file-name div.text a", $(i)).attr("title");
e("选中文件:" + n), $.each(ae, function (e, t) {
if (t.server_filename == n) {
var i = {filename: t.server_filename, path: t.path, fs_id: t.fs_id, isdir: t.isdir};
oe.push(i);
}
});
});
} else {
oe = [];
var a = $("div.file-name div.text a", $(this)).attr("title");
e("选中文件:" + a), $.each(ae, function (e, t) {
if (t.server_filename == a) {
var i = {filename: t.server_filename, path: t.path, fs_id: t.fs_id, isdir: t.isdir};
oe.push(i);
}
});
}
});
});
}
function _() {
$("div." + h["list-view"] + " dd").each(function (e, t) {
$(t).unbind("click");
});
}
function S() {
var e = window.MutationObserver, t = {childList: !0};
re = new e(function (e) {
b(), x(), _(), w(), y(), k();
});
var i = document.querySelector("." + h["list-view"]), n = document.querySelector("." + h["grid-view"]);
re.observe(i, t), re.observe(n, t);
}
function A() {
$("div." + h["bar-search"]).css("width", "18%");
var e = $('<span class="g-dropdown-button"></span>'),
t = $('<a class="g-button g-button-blue" href="javascript:;"><span class="g-button-right"><em class="icon icon-speed" title="百度网盘下载助手"></em><span class="text" style="width: 60px;">下载助手</span></span></a>'),
i = $('<span class="menu" style="width:114px"></span>'),
n = $('<span class="g-button-menu" style="display:block"></span>'),
a = $('<span class="g-dropdown-button g-dropdown-button-second" menulevel="2"></span>'),
o = $('<a class="g-button" href="javascript:;"><span class="g-button-right"><span class="text" style="width:auto">直链下载</span></span></a>'),
s = $('<span class="menu" style="width:120px;left:79px"></span>'),
l = $('<a id="batchhttplink-direct" class="g-button-menu" href="javascript:;">显示链接</a>');
s.append(l), n.append(a.append(o).append(s)), n.hover(function () {
a.toggleClass("button-open");
}), l.click(G);
var d = $('<span class="g-button-menu" style="display:block"></span>'),
r = $('<span class="g-dropdown-button g-dropdown-button-second" menulevel="2"></span>'),
c = $('<a class="g-button" href="javascript:;"><span class="g-button-right"><span class="text" style="width:auto">aria直链下载</span></span></a>'),
p = $('<span class="menu" style="width:120px;left:79px"></span>'),
u = $('<a id="batchhttplink-aria" class="g-button-menu" href="javascript:;">显示链接</a>');
p.append(u), d.append(r.append(c).append(p)), d.hover(function () {
r.toggleClass("button-open");
}), u.click(G);
var f = $('<span class="g-button-menu" style="display:block"></span>'),
v = $('<span class="g-dropdown-button g-dropdown-button-second" menulevel="2"></span>'),
g = $('<a class="g-button" href="javascript:;"><span class="g-button-right"><span class="text" style="width:auto">API下载</span></span></a>'),
m = $('<span class="menu" style="width:120px;left:77px"></span>'),
w = $('<a id="download-api" class="g-button-menu" href="javascript:;">直接下载</a>'),
b = $('<a id="batchhttplink-api" class="g-button-menu" href="javascript:;">显示链接</a>'),
y = $('<a id="appid-setting" class="g-button-menu" href="javascript:;">脚本配置</a>');
m.append(w).append(b).append(y), f.append(v.append(g).append(m)), f.hover(function () {
v.toggleClass("button-open");
}), w.click(E), b.click(G), y.click(M);
var x = $('<span class="g-button-menu" style="display:block"></span>'),
k = $('<span class="g-dropdown-button g-dropdown-button-second" menulevel="2"></span>'),
_ = $('<a class="g-button" href="javascript:;"><span class="g-button-right"><span class="text" style="width:auto">aria外链下载</span></span></a>'),
S = $('<span class="menu" style="width:120px;left:79px"></span>'),
A = $('<a id="batchlink-outerlink" class="g-button-menu" href="javascript:;">显示链接</a>');
S.append(A), x.append(k.append(_).append(S)), x.hover(function () {
k.toggleClass("button-open");
}), A.click(G);
var I = $('<span class="g-button-menu" style="display:block;cursor: pointer">分享后下载</span>');
I.click(J), T(), i.append(f).append(d).append(n).append(I), e.append(t).append(i), e.hover(function () {
e.toggleClass("button-open");
}), $("." + h["list-tools"]).append(e), $("." + h["list-tools"]).css("height", "40px");
}
function M() {
var e = prompt("请输入神秘代码 , 不懂请勿输入 , 否则后果自负", v);
/^\d{1,6}$/.test(e) && (GM_setValue("secretCode", e), swal("神秘代码执行成功 , 点击确定将自动刷新"), history.go(0));
}
function T() {
return 1 === W.ISSVIP;
}
function E(t) {
e("选中文件列表:", oe);
var i = t.target.id, n = void 0;
if ("download-direct" == i) {
var a = void 0;
if (0 === oe.length) return void swal(f.unselected);
1 == oe.length && (a = 1 === oe[0].isdir ? "batch" : "dlink"), oe.length > 1 && (a = "batch"), ne = U(oe);
var o = H(a);
if (0 !== o.errno) return -1 == o.errno ? void swal("文件不存在或已被百度和谐,无法下载!") : 112 == o.errno ? void swal("页面过期,请刷新重试!") : void swal("发生错误!");
if ("dlink" == a) n = o.dlink[0].dlink; else {
if ("batch" != a) return void swal("发生错误!");
n = o.dlink, 1 === oe.length && (n = n + "&zipname=" + encodeURIComponent(oe[0].filename) + ".zip");
}
} else {
if (0 === oe.length) return void swal(f.unselected);
if (oe.length > 1) return void swal(f.morethan);
if (1 == oe[0].isdir) return void swal(f.dir);
"download-api" == i && (n = q(oe[0].path));
}
Y(n);
}
function G(t) {
if (e("选中文件列表:", oe), 0 === oe.length) return void swal(f.unselected);
var i = t.target.id, n = void 0, a = void 0;
if (n = -1 == i.indexOf("https") ? -1 == i.indexOf("http") ? location.protocol + ":" : "http:" : "https:", se = [], le = [], -1 != i.indexOf("direct")) {
se = I(n);
if (0 === se.length) return void swal("没有链接可以显示,不要选中文件夹!");
he.open({
title: "直链下载",
type: "batch",
list: se,
tip: '支持使用IDM批量下载,需升级 <a href="https://www.baiduyun.wiki/zh-cn/assistant.html">[百度网盘万能助手]</a> 至v2.0.3',
showcopy: !0
});
}
if (-1 != i.indexOf("aria")) {
if (se = I(n), a = '请先安装 <a href="https://www.baiduyun.wiki/zh-cn/assistant.html">百度网盘万能助手</a> 请将链接复制到支持Aria的下载器中, 推荐使用 <a href="http://pan.baiduyun.wiki/down">XDown</a>(仅支持300M以下的文件夹)', 0 === se.length) return void swal("没有链接可以显示,不要选中文件夹!");
he.open({title: "Aria链接", type: "batchAria", list: se, tip: a, showcopy: !0});
} else if (-1 != i.indexOf("api")) {
if (se = C(n), a = '请先安装 <a href="https://www.baiduyun.wiki/zh-cn/assistant.html">百度网盘万能助手</a> 请将链接复制到“IDM->任务->从剪切板中添加批量下载”', 0 === se.length) return void swal("没有链接可以显示,API链接不要全部选中文件夹!");
he.open({title: "API下载链接", type: "batch", list: se, tip: a, showcopy: !0});
} else -1 != i.indexOf("outerlink") && j(function (e) {
if (se = O(e), 0 === se.length) return void swal("没有链接可以显示,API链接不要全部选中文件夹!");
he.open({
title: "下载链接(仅显示文件链接)",
type: "batchAria",
list: se,
alllist: e,
tip: '请先安装 <a href="https://www.baiduyun.wiki/zh-cn/assistant.html">百度网盘万能助手</a> 请将链接复制到支持Aria的下载器中, 推荐使用 <a href="http://pan.baiduyun.wiki/down">XDown</a>',
showcopy: !0,
showall: !0
});
});
}
function I(e) {
var t = [];
return $.each(oe, function (i, n) {
var a = void 0, o = void 0, s = void 0;
a = 0 == n.isdir ? "dlink" : "batch", ne = U([n]), s = H(a), 0 == s.errno ? ("dlink" == a ? o = s.dlink[0].dlink : "batch" == a && (o = s.dlink), o = o.replace(/^([A-Za-z]+):/, e)) : o = "error", t.push({
filename: n.filename,
downloadlink: o
});
}), t;
}
function C(e) {
var t = [];
return $.each(oe, function (i, n) {
if (1 != n.isdir) {
var a = void 0;
a = q(n.path), a = a.replace(/^([A-Za-z]+):/, e), t.push({filename: n.filename, downloadlink: a});
}
}), t;
}
function j(e) {
$.each(oe, function (t, i) {
1 != i.isdir && X(i.path, function (t) {
var n = [];
0 == t.errno ? n.push({filename: i.filename, links: t.urls}) : n.push({
filename: i.filename,
links: [{rank: 1, url: "error"}]
}), e(n);
});
});
}
function O(e) {
var t = [];
return $.each(e, function (e, i) {
t.push({filename: i.filename, downloadlink: i.links[0].url});
}), t;
}
function N() {
var e = void 0;
try {
e = new Function("return " + W.sign2)();
} catch (e) {
throw new Error(e.message);
}
return o(e(W.sign5, W.sign1));
}
function D() {
var e = location.hash, t = new RegExp("path=([^&]*)(&|$)", "i"), i = e.match(t);
return decodeURIComponent(i[1]);
}
function P() {
var e = location.hash, t = new RegExp("type=([^&]*)(&|$)", "i"), i = e.match(t);
return decodeURIComponent(i[1]);
}
function F() {
var e = location.hash, t = new RegExp("key=([^&]*)(&|$)", "i"), i = e.match(t);
return decodeURIComponent(i[1]);
}
function V() {
var e = location.hash;
return e.substring(e.indexOf("#") + 2, e.indexOf("?"));
}
function z() {
var e = [], t = ve + "list", i = D();
ie = d();
var n = {
dir: i,
bdstoken: te,
logid: ie,
order: "size",
num: 1e3,
desc: 0,
clienttype: 0,
showempty: 0,
web: 1,
channel: "chunlei",
appid: v
};
return $.ajax({
url: t, async: !1, method: "GET", data: n, success: function (t) {
e = 0 === t.errno ? t.list : [];
}
}), e;
}
function R() {
var e = [], t = ve + "categorylist", i = P();
ie = d();
var n = {
category: i,
bdstoken: te,
logid: ie,
order: "size",
desc: 0,
clienttype: 0,
showempty: 0,
web: 1,
channel: "chunlei",
appid: v
};
return $.ajax({
url: t, async: !1, method: "GET", data: n, success: function (t) {
e = 0 === t.errno ? t.info : [];
}
}), e;
}
function L() {
var e = [], t = ve + "search";
ie = d(), fe = F();
var i = {
recursion: 1,
order: "time",
desc: 1,
showempty: 0,
web: 1,
page: 1,
num: 100,
key: fe,
channel: "chunlei",
app_id: 250528,
bdstoken: te,
logid: ie,
clienttype: 0
};
return $.ajax({
url: t, async: !1, method: "GET", data: i, success: function (t) {
e = 0 === t.errno ? t.list : [];
}
}), e;
}
function U(e) {
if (0 === e.length) return null;
var t = [];
return $.each(e, function (e, i) {
t.push(i.fs_id);
}), "[" + t + "]";
}
function B() {
return W.timestamp;
}
function K() {
return W.MYBDSTOKEN;
}
function J() {
var e = [];
if (0 === oe.length) return void swal(f.unselected);
$.each(oe, function (t, i) {
e.push(i.path);
});
var t = "https://pan.baidu.com/share/pset?channel=chunlei&clienttype=0&web=1&channel=chunlei&web=1&app_id=250528&bdstoken=" + te + "&logid=" + ie + "&clienttype=0",
i = {schannel: 0, channel_list: JSON.stringify([]), period: 7, path_list: JSON.stringify(e)};
$.ajax({
url: t, async: !1, method: "POST", data: i, success: function (e) {
0 === e.errno && swal({
title: "分享链接",
text: e.link,
buttons: {confirm: {text: "打开", value: "confirm"}}
}).then(function (t) {
"confirm" === t && GM_openInTab(e.link, {active: !0});
});
}
});
}
function H(e) {
var t = void 0;
ie = d();
var i = {bdstoken: te, logid: ie}, n = {sign: Z, timestamp: ee, fidlist: ne, type: e},
a = "https://pan.baidu.com/api/download?bdstoken=" + i.bdstoken + "&web=5&app_id=250528&logid=" + i.logid + "=&channel=chunlei&clienttype=5";
return $.ajax({
url: a, async: !1, method: "POST", data: n, success: function (e) {
t = e;
}
}), t;
}
function q(e) {
return ge + "file?method=download&path=" + encodeURIComponent(e) + "&app_id=" + v;
}
function X(e, t) {
var i = void 0, n = me + "file?method=locatedownload&app_id=" + v + "&ver=4.0&path=" + encodeURIComponent(e);
GM_xmlhttpRequest({
method: "POST", url: n, headers: {"User-Agent": m}, onload: function (e) {
200 === e.status ? (i = JSON.parse(e.responseText), void 0 == i.error_code ? void 0 == i.urls ? i.errno = 2 : ($.each(i.urls, function (e, t) {
i.urls[e].url = t.url.replace("\\", "");
}), i.errno = 0) : 31066 == i.error_code ? i.errno = 1 : i.errno = -1) : (i = {}, i.errno = -1), t(i);
}
});
}
function Y(t) {
e("下载链接:" + t), $("#helperdownloadiframe").attr("src", t);
}
function Q() {
var e = $('<div class="helper-hide" style="padding:0;margin:0;display:block"></div>'),
t = $('<iframe src="javascript:;" id="helperdownloadiframe" style="display:none"></iframe>');
e.append(t), $("body").append(e);
}
var W = void 0, Z = void 0, ee = void 0, te = void 0, ie = void 0, ne = void 0, ae = [], oe = [], se = [], le = [],
de = "list", re = void 0, ce = void 0, pe = void 0, ue = void 0, he = void 0, fe = void 0,
ve = location.protocol + "//" + location.host + "/api/",
ge = location.protocol + "//pcs.baidu.com/rest/2.0/pcs/",
me = location.protocol + "//d.pcs.baidu.com/rest/2.0/pcs/";
this.init = function () {
if (W = unsafeWindow.yunData, e("初始化信息:", W), void 0 === W) return void e("页面未正常加载,或者百度已经更新!");
t(), l(), S(), A(), Q(), he = new r({addCopy: !0}), e("下载助手加载成功!当前版本:", u);
};
}
function a() {
function t() {
if (pe = n(), X = q.SIGN, Y = q.TIMESTAMP, Q = q.MYBDSTOKEN, W = "chunlei", Z = 0, ee = 1, te = v, ie = d(), ne = 0, ae = "share", se = q.SHARE_ID, oe = q.SHARE_UK, "secret" == pe && (de = s()), a()) {
var e = {};
2 == q.CATEGORY ? (e.filename = q.FILENAME, e.path = q.PATH, e.fs_id = q.FS_ID, e.isdir = 0) : void 0 != q.FILEINFO && (e.filename = q.FILEINFO[0].server_filename, e.path = q.FILEINFO[0].path, e.fs_id = q.FILEINFO[0].fs_id, e.isdir = q.FILEINFO[0].isdir), be.push(e);
} else re = q.SHARE_ID, he = p(), fe = m(), we = F();
}
function i() {
var e = location.hash && /^#([a-zA-Z0-9]{4})$/.test(location.hash) && RegExp.$1,
t = $('.pickpw input[tabindex="1"]'), i = $(".pickpw a.g-button"), n = $(".pickpw .input-area"),
a = $('<div style="margin:-8px 0 10px ;color: #ff5858">正在获取提取码</div>'),
o = (location.href.match(/\/init\?(?:surl|shareid)=((?:\w|-)+)/) || location.href.match(/\/s\/1((?:\w|-)+)/))[1];
t && i && (n.prepend(a), e && (a.text("发现提取码,已自动为您填写"), setTimeout(function () {
t.val(e), i.click();
}, 1e3)), $.ajax({
method: "GET", url: "https://api.baiduyun.wiki/reset/" + o, success: function (e) {
e.link ? GM_xmlhttpRequest({
method: "GET", url: e.link, onload: function (e) {
var n = JSON.parse(e.responseText);
n.access_code ? (a.text("发现提取码,已自动为您填写"), t.val(n.access_code), setTimeout(function () {
i.click();
}, 200)) : a.text("未发现提取码,请手动填写");
}
}) : a.text("未发现提取码,请手动填写");
}, error: function (e) {
a.text("连接服务器失败,请手动填写");
}
}));
}
function n() {
return 1 === q.SHARE_PUBLIC ? "public" : "secret";
}
function a() {
return void 0 === q.getContext;
}
function o() {
return 1 == q.MYSELF;
}
function s() {
return '{"sekey":"' + decodeURIComponent(l("BDCLND")) + '"}';
}
function p() {
var e = location.hash, t = new RegExp("path=([^&]*)(&|$)", "i"), i = e.match(t);
return decodeURIComponent(i[1]);
}
function m() {
var e = "list";
return $(".list-switched-on").length > 0 ? e = "list" : $(".grid-switched-on").length > 0 && (e = "grid"), e;
}
function w() {
a() ? ($("div.slide-show-right").css("width", "500px"), $("div.frame-main").css("width", "96%"), $("div.share-file-viewer").css("width", "740px").css("margin-left", "auto").css("margin-right", "auto")) : $("div.slide-show-right").css("width", "500px");
var e = $('<span class="g-dropdown-button"></span>'),
t = $('<a class="g-button g-button-blue" style="width: 114px;" data-button-id="b200" data-button-index="200" href="javascript:;"></a>'),
i = $('<span class="g-button-right"><em class="icon icon-speed" title="百度网盘下载助手"></em><span class="text" style="width: 60px;">下载助手</span></span>'),
n = $('<span class="menu" style="width:auto;z-index:41"></span>'),
o = $('<a data-menu-id="b-menu207" class="g-button-menu" href="javascript:;">一键保存</a>'),
s = $('<a data-menu-id="b-menu207" class="g-button-menu" href="javascript:;" style="opacity: 0.8;">自定义保存路径</a>'),
l = $('<a data-menu-id="b-menu207" class="g-button-menu" href="javascript:;">直接下载</a>'),
d = $('<a data-menu-id="b-menu208" class="g-button-menu" href="javascript:;">显示直链</a>'),
r = $('<a data-menu-id="b-menu208" class="g-button-menu" href="javascript:;">显示aria链接</a>'),
c = $('<a data-menu-id="b-menu209" class="g-button-menu" style="color: #F24C43;font-weight: 700;" href="javascript:;">免登录下载</a>'),
p = $('<iframe src="https://ghbtns.com/github-btn.html?user=syhyz1990&repo=baiduyun&type=star&count=true" frameborder="0" scrolling="0" style="height: 20px;max-width: 120px;padding: 0 5px;box-sizing: border-box;margin-top: 5px;"></iframe>');
n.append(c).append(d).append(r).append(o).append(p), t.append(i), e.append(t).append(n), e.hover(function () {
e.toggleClass("button-open");
}), o.click(x), s.click(k), l.click(V), d.click(B), r.click(_), c.click(y), $("div.module-share-top-bar div.bar div.x-button-box").append(e);
}
function b() {
var e = {shareid: re, from: q.SHARE_UK, bdstoken: q.MYBDSTOKEN, logid: d()},
t = {path: g, isdir: 1, size: "", block_list: [], method: "post", dataType: "json"},
i = "https://pan.baidu.com/api/create?a=commit&channel=chunlei&app_id=250528&web=1&app_id=250528&bdstoken=" + e.bdstoken + "&logid=" + e.logid + "&clienttype=0";
$.ajax({
url: i, async: !1, method: "POST", data: t, success: function (e) {
0 === e.errno ? (swal("目录创建成功!"), x()) : swal("目录创建失败,请前往我的网盘页面手动创建!");
}
});
}
function y() {
var e = encodeURIComponent(location.href), t = "https://www.baiduwiki.com/?link=" + e;
GM_openInTab(t, {active: !0});
}
function x() {
if (null === Q) return swal(f.unlogin), !1;
if (0 === be.length) return void swal(f.unselected);
if (o()) return void swal({
title: "提示",
text: "自己分享的文件请到网盘中下载!",
buttons: {confirm: {text: "打开网盘", value: "confirm"}}
}).then(function (e) {
"confirm" === e && (location.href = "https://pan.baidu.com/disk/home#/all?path=%2F&vmode=list");
});
var e = [];
$.each(be, function (t, i) {
e.push(i.fs_id);
});
var t = {shareid: q.SHARE_ID, from: q.SHARE_UK, bdstoken: q.MYBDSTOKEN, logid: d()},
i = {path: GM_getValue("savePath"), fsidlist: JSON.stringify(e)},
n = "https://pan.baidu.com/share/transfer?shareid=" + t.shareid + "&from=" + t.from + "&ondup=newcopy&async=1&channel=chunlei&web=1&app_id=250528&bdstoken=" + t.bdstoken + "&logid=" + t.logid + "&clienttype=0";
$.ajax({
url: n, async: !1, method: "POST", data: i, success: function (e) {
0 === e.errno ? swal({
title: "提示",
text: "文件已保存至我的网盘,请再网盘中使用下载助手下载!",
buttons: {confirm: {text: "打开网盘", value: "confirm"}}
}).then(function (e) {
"confirm" === e && (location.href = "https://pan.baidu.com/disk/home#/all?vmode=list&path=" + encodeURIComponent(g));
}) : 2 === e.errno ? swal({
title: "提示",
text: "保存目录不存在,是否先创建该目录?",
buttons: {confirm: {text: "创建目录", value: "confirm"}}
}).then(function (e) {
"confirm" === e && b();
}) : swal("保存失败,请手动保存");
}
});
}
function k() {
var e = prompt("请输入保存路径,例如/PanHelper", g);
null !== e && (/^\//.test(e) ? (GM_setValue("savePath", e), swal({
title: "提示",
text: "路径设置成功!点击确定后立即生效",
buttons: {confirm: {text: "确定", value: "confirm"}}
}).then(function (e) {
"confirm" === e && history.go(0);
})) : swal("请输入正确的路径,例如/PanHelper"));
}
function _() {
return null === Q ? (swal(f.unlogin), !1) : (e("选中文件列表:", be), 0 === be.length ? (swal(f.unselected), !1) : 1 == be[0].isdir ? (swal(f.toobig), !1) : (ue = "ariclink", void K(function (e) {
if (void 0 !== e) if (-20 == e.errno) {
if (!(ce = z()) || 0 !== ce.errno) return swal("获取验证码失败!"), !1;
me.open(ce);
} else {
if (112 == e.errno) return swal("页面过期,请刷新重试"), !1;
if (0 === e.errno) {
ge.open({
title: "下载链接(仅显示文件链接)",
type: "shareAriaLink",
list: e.list,
tip: '请先安装 <a href="https://www.baiduyun.wiki/zh-cn/assistant.html">百度网盘万能助手</a> 请将链接复制到支持Aria的下载器中, 推荐使用 <a href="http://pan.baiduyun.wiki/down">XDown</a>',
showcopy: !0
});
} else swal(f.fail);
}
})));
}
function S() {
var e = $('<div class="helper-hide" style="padding:0;margin:0;display:block"></div>'),
t = $('<iframe src="javascript:;" id="helperdownloadiframe" style="display:none"></iframe>');
e.append(t), $("body").append(e);
}
function A() {
M(), G(), I(), j(), N();
}
function M() {
window.addEventListener("hashchange", function (e) {
fe = m(), he == p() || (he = p(), T(), E());
});
}
function T() {
we = F();
}
function E() {
be = [];
}
function G() {
m();
}
function I() {
fe = m();
var t = $("span." + h.checkbox);
"grid" == fe && (t = $("." + h["chekbox-grid"])), t.each(function (t, i) {
$(i).on("click", function (t) {
var i = $(this).parent(), n = void 0, a = void 0;
if ("list" == fe ? (n = $(".file-name div.text a", i).attr("title"), a = $(this).parents("dd").hasClass("JS-item-active")) : "grid" == fe && (n = $("div.file-name a", i).attr("title"), a = !$(this).hasClass("JS-item-active")), a) {
e("取消选中文件:" + n);
for (var o = 0; o < be.length; o++) be[o].filename == n && be.splice(o, 1);
} else e("选中文件: " + n), $.each(we, function (e, t) {
if (t.server_filename == n) {
var i = {filename: t.server_filename, path: t.path, fs_id: t.fs_id, isdir: t.isdir};
be.push(i);
}
});
});
});
}
function C() {
$("span." + h.checkbox).each(function (e, t) {
$(t).unbind("click");
});
}
function j() {
$("div." + h["col-item"] + "." + h.check).each(function (t, i) {
$(i).bind("click", function (t) {
$(this).parent().hasClass(h.checked) ? (e("取消全选"), be = []) : (e("全部选中"), be = [], $.each(we, function (e, t) {
var i = {filename: t.server_filename, path: t.path, fs_id: t.fs_id, isdir: t.isdir};
be.push(i);
}));
});
});
}
function O() {
$("div." + h["col-item"] + "." + h.check).each(function (e, t) {
$(t).unbind("click");
});
}
function N() {
$("div." + h["list-view"] + " dd").each(function (t, i) {
$(i).bind("click", function (t) {
var i = t.target.nodeName.toLowerCase();
if ("span" != i && "a" != i && "em" != i) {
be = [];
var n = $("div.file-name div.text a", $(this)).attr("title");
e("选中文件:" + n), $.each(we, function (e, t) {
if (t.server_filename == n) {
var i = {filename: t.server_filename, path: t.path, fs_id: t.fs_id, isdir: t.isdir};
be.push(i);
}
});
}
});
});
}
function D() {
$("div." + h["list-view"] + " dd").each(function (e, t) {
$(t).unbind("click");
});
}
function P() {
var e = window.MutationObserver, t = {childList: !0};
ve = new e(function (e) {
C(), O(), D(), I(), j(), N();
});
var i = document.querySelector("." + h["list-view"]), n = document.querySelector("." + h["grid-view"]);
ve.observe(i, t), ve.observe(n, t);
}
function F() {
var e = [];
if ("/" == p()) e = q.FILEINFO; else {
ie = d();
var t = {
uk: oe,
shareid: re,
order: "other",
desc: 1,
showempty: 0,
web: ee,
dir: p(),
t: Math.random(),
bdstoken: Q,
channel: W,
clienttype: Z,
app_id: te,
logid: ie
};
$.ajax({
url: $e, method: "GET", async: !1, data: t, success: function (t) {
0 === t.errno && (e = t.list);
}
});
}
return e;
}
function V() {
return null === Q ? (swal(f.unlogin), !1) : (e("选中文件列表:", be), 0 === be.length ? (swal(f.unselected), !1) : be.length > 1 ? (swal(f.morethan), !1) : 1 == be[0].isdir ? (swal(f.dir), !1) : (ue = "download", void K(function (e) {
if (void 0 !== e) if (-20 == e.errno) {
if (ce = z(), 0 !== ce.errno) return void swal("获取验证码失败!");
me.open(ce);
} else if (112 == e.errno) swal("页面过期,请刷新重试"); else if (0 === e.errno) {
var t = e.list[0].dlink;
H(t);
} else swal(f.fail);
})));
}
function z() {
var e = ye + "getvcode", t = void 0;
ie = d();
var i = {prod: "pan", t: Math.random(), bdstoken: Q, channel: W, clienttype: Z, web: ee, app_id: te, logid: ie};
return $.ajax({
url: e, method: "GET", async: !1, data: i, success: function (e) {
t = e;
}
}), t;
}
function R() {
ce = z(), $("#dialog-img").attr("src", ce.img);
}
function L() {
var e = $("#dialog-input").val();
return 0 === e.length ? void $("#dialog-err").text("请输入验证码") : e.length < 4 ? void $("#dialog-err").text("验证码输入错误,请重新输入") : void J(e, function (e) {
if (-20 == e.errno) {
if (me.close(), $("#dialog-err").text("验证码输入错误,请重新输入"), R(), !ce || 0 !== ce.errno) return void swal("获取验证码失败!");
me.open();
} else if (0 === e.errno) {
if (me.close(), "download" == ue) {
if (e.list.length > 1 || 1 == e.list[0].isdir) return swal(f.morethan), !1;
var t = e.list[0].dlink;
H(t);
} else if ("link" == ue) {
ge.open({
title: "下载链接(仅显示文件链接)",
type: "shareLink",
list: e.list,
tip: '支持使用IDM批量下载,需升级 <a href="https://www.baiduyun.wiki/zh-cn/assistant.html">[百度网盘万能助手]</a> 至v2.0.3',
showcopy: !0
});
} else if ("ariclink" == ue) {
ge.open({
title: "下载链接(仅显示文件链接)",
type: "shareAriaLink",
list: e.list,
tip: '请先安装 <a href="https://www.baiduyun.wiki/zh-cn/assistant.html">百度网盘万能助手</a> 请将链接复制到支持Aria的下载器中, 推荐使用 <a href="http://pan.baiduyun.wiki/down">XDown</a>',
showcopy: !0
});
}
} else swal("发生错误!");
});
}
function U() {
var e = [];
return $.each(be, function (t, i) {
e.push(i.fs_id);
}), "[" + e + "]";
}
function B() {
return null === Q ? (swal(f.unlogin), !1) : (e("选中文件列表:", be), 0 === be.length ? (swal(f.unselected), !1) : 1 == be[0].isdir ? (swal(f.dir), !1) : (ue = "link", void K(function (e) {
if (void 0 !== e) if (-20 == e.errno) {
if (!(ce = z()) || 0 !== ce.errno) return swal("获取验证码失败!"), !1;
me.open(ce);
} else {
if (112 == e.errno) return swal("页面过期,请刷新重试"), !1;
if (0 === e.errno) {
ge.open({
title: "下载链接(仅显示文件链接)",
type: "shareLink",
list: e.list,
tip: '支持使用IDM批量下载,需升级 <a href="https://www.baiduyun.wiki/zh-cn/assistant.html">[百度网盘万能助手]</a> 至v2.0.3',
showcopy: !0
});
} else swal(f.fail);
}
})));
}
function K(e) {
if (null === Q) return swal(f.unlogin), "";
var t = void 0;
if (a) {
le = U(), ie = d();
var i = new FormData;
i.append("encrypt", ne), i.append("product", ae), i.append("uk", oe), i.append("primaryid", se), i.append("fid_list", le), "secret" == pe && i.append("extra", de), $.ajax({
url: "https://api.baiduyun.wiki/download?sign=" + X + "×tamp=" + Y + "&logid=" + ie + "&init=" + GM_getValue("init"),
cache: !1,
method: "GET",
async: !1,
complete: function (e) {
t = e.responseText;
}
}), GM_xmlhttpRequest({
method: "POST", data: i, url: atob(atob(t)), onload: function (t) {
e(JSON.parse(t.response));
}
});
}
}
function J(e, t) {
var i = void 0;
if (a) {
le = U(), ie = d();
var n = new FormData;
n.append("encrypt", ne), n.append("product", ae), n.append("uk", oe), n.append("primaryid", se), n.append("fid_list", le), n.append("vcode_input", e), n.append("vcode_str", ce.vcode), "secret" == pe && n.append("extra", de), $.ajax({
url: "https://api.baiduyun.wiki/download?sign=" + X + "×tamp=" + Y + "&logid=" + ie,
cache: !1,
method: "GET",
async: !1,
complete: function (e) {
i = e.responseText;
}
}), GM_xmlhttpRequest({
method: "POST", data: n, url: atob(atob(i)), onload: function (e) {
t(JSON.parse(e.response));
}
});
}
}
function H(t) {
e("下载链接:" + t), $("#helperdownloadiframe").attr("src", t);
}
var q = void 0, X = void 0, Y = void 0, Q = void 0, W = void 0, Z = void 0, ee = void 0, te = void 0, ie = void 0,
ne = void 0, ae = void 0, oe = void 0, se = void 0, le = void 0, de = void 0, re = void 0, ce = void 0,
pe = void 0, ue = void 0, he = void 0, fe = void 0, ve = void 0, ge = void 0, me = void 0, we = [], be = [],
ye = location.protocol + "//" + location.host + "/api/",
$e = location.protocol + "//" + location.host + "/share/list";
this.init = function () {
if (GM_getValue("SETTING_P") && i(), q = unsafeWindow.yunData, e("初始化信息:", q), void 0 === q) return void e("页面未正常加载,或者百度已经更新!");
t(), w(), ge = new r({addCopy: !1}), me = new c(R, L), S(), a() || (A(), P()), e("下载助手加载成功!当前版本:", u);
};
}
function o(e) {
var t = void 0, i = void 0, n = void 0, a = void 0, o = void 0, s = void 0,
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (n = e.length, i = 0, t = ""; n > i;) {
if (a = 255 & e.charCodeAt(i++), i == n) {
t += l.charAt(a >> 2), t += l.charAt((3 & a) << 4), t += "==";
break;
}
if (o = e.charCodeAt(i++), i == n) {
t += l.charAt(a >> 2), t += l.charAt((3 & a) << 4 | (240 & o) >> 4), t += l.charAt((15 & o) << 2), t += "=";
break;
}
s = e.charCodeAt(i++), t += l.charAt(a >> 2), t += l.charAt((3 & a) << 4 | (240 & o) >> 4), t += l.charAt((15 & o) << 2 | (192 & s) >> 6), t += l.charAt(63 & s);
}
return t;
}
function s() {
var e = /[\/].+[\/]/g;
return location.pathname.match(e)[0].replace(/\//g, "");
}
function l(e) {
var t = void 0, i = void 0, n = document, a = decodeURI;
return n.cookie.length > 0 && -1 != (t = n.cookie.indexOf(e + "=")) ? (t = t + e.length + 1, i = n.cookie.indexOf(";", t), -1 == i && (i = n.cookie.length), a(n.cookie.substring(t, i))) : "";
}
function d() {
function e(e) {
if (e.length < 2) {
var t = e.charCodeAt(0);
return 128 > t ? e : 2048 > t ? d(192 | t >>> 6) + d(128 | 63 & t) : d(224 | t >>> 12 & 15) + d(128 | t >>> 6 & 63) + d(128 | 63 & t);
}
var i = 65536 + 1024 * (e.charCodeAt(0) - 55296) + (e.charCodeAt(1) - 56320);
return d(240 | i >>> 18 & 7) + d(128 | i >>> 12 & 63) + d(128 | i >>> 6 & 63) + d(128 | 63 & i);
}
function t(t) {
return (t + "" + Math.random()).replace(s, e);
}