-
Notifications
You must be signed in to change notification settings - Fork 0
/
阿里云盘脚本V5.3.1【优化版本】.user.js
1027 lines (902 loc) · 44.2 KB
/
阿里云盘脚本V5.3.1【优化版本】.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 阿里云盘脚本V5.3.1【优化版本】
// @namespace http://bbs.tampermonkey.net.cn/
// @version 66.80
// @description 【bbs.tampermonkey.net.cn】李恒道
// @author 【bbs.tampermonkey.net.cn】李恒道
// @match https://passport.aliyundrive.com/*
// @match https://www.aliyundrive.com/drive/*
// @match https://www.aliyundrive.com/drive
// @match https://aliyundrive.com/drive/*
// @match https://aliyundrive.com/drive
// @match http://passport.aliyundrive.com/*
// @match http://www.aliyundrive.com/drive/*
// @match http://www.aliyundrive.com/drive
// @match http://aliyundrive.com/drive/*
// @match http://aliyundrive.com/drive
// @icon https://www.google.com/s2/favicons?domain=aliyundrive.com
// @require https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.js
// @require https://cdn.bootcdn.net/ajax/libs/js-sha1/0.6.0/sha1.js
// @grant unsafeWindow
// @grant GM_setClipboard
// @grant GM_xmlhttpRequest
// @connect aliyundrive.com
// @connect alicloudccp.com
// @run-at document-start
// @supportURL https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=427
// @homepage https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=427
// @supportURL https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=427
// @homepage https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=427
// ==/UserScript==
let username=''
let password=''
//自动登陆配置项
let NewLink=true;
//使用新版链接
let FileList=[]
let Searchlist=[]
let CreateListner=false;
let GenerateFileInShow=false;
let parent_file_id='root'
let listurl=''
let CreateSaveBtn=false;
let Totallistnum=0;
let Sublistnum=0;
var ShowFileObj={
name:'文件获取失败',
content_hash:'hash获取失败',
size:'公众号:叛逆青年旅舍,来自油猴中文网:bbs.tampermonkey.net.cn',
content_type:'Fucccccck',
file_id:'天才少年李恒道',
content_type:'系统李恒道吹牛逼理论,QQ4548212'
}
let accesstoken=''
let filenum=0;
let next_markerlist=[]
let totalnum=0;
let Uploadlist=[]
let Success=0;
let Faile=0;
let GenerateDialogShow;//对话框1
let GenerateFileinDialogShow;//对话框2
let GenerateShow=false
let uploadsize=1000000
//他妈看不懂了,写的是啥
function GetFileSha1Encr(tempobj){
if(NewLink==true)
{
let name=tempobj.name.replace('|','=')
if(name==='')
{
name='nameisnull'
}
return 'aliyunpan://'+name+'|'+tempobj.content_hash.replace('|','=')+'|'+tempobj.size+'|'+tempobj.content_type.replace('|','=')
}
return window.btoa(unescape(encodeURIComponent(JSON.stringify({
name:tempobj.name,
content_hash:tempobj.content_hash,
size:tempobj.size,
content_type:tempobj.content_type,
}))))
}
function CurrentText() {
var d = new Date(),
str = '';
str += d.getFullYear() + '年';
str += d.getMonth() + 1 + '月';
str += d.getDate() + '日';
str += d.getHours() + '时';
str += d.getMinutes() + '分';
str += d.getSeconds() + '秒';
return str+'序列文件.txt';
}
async function CreateTextUpload(name,size,hash){
return new Promise((resolve, reject) => {
let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id
let uploadtext='{"drive_id":"'+useruid+'","part_info_list":[{"part_number":1}],"parent_file_id":"'+parent_file_id+'","name":"'+name+
'","type":"file","check_name_mode":"auto_rename","size":'+size+',"content_hash":"'+hash+'","content_hash_name":"sha1"}'
GM_xmlhttpRequest({
url:"https://api.aliyundrive.com/v2/file/create",
method :"POST",
data:uploadtext,
headers: {
"Content-type": "application/json;charset=utf-8",
"Authorization": accesstoken
},
onload:function(xhr){
resolve(xhr.responseText);
}
});
});
}
async function UploadTextBin(tageturl,targetdata){
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
url:tageturl,
method :"PUT",
data:targetdata,
headers: {
"Content-type": " ",
"Referer": "https://www.aliyundrive.com/",
// "Authorization": accesstoken
},
//binary:true,
onload:function(xhr){
resolve(xhr.responseText);
}
});
});
}
async function Complete(upload_id,file_id){
return new Promise((resolve, reject) => {
let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id
let uploadtext='{"drive_id":"'+useruid+'","upload_id":"'+upload_id+'","file_id":"'+file_id+'"}'
GM_xmlhttpRequest({
url:'https://api.aliyundrive.com/v2/file/complete',
method :"POST",
data:uploadtext,
headers: {
"Content-type": "application/json;charset=utf-8",
"Authorization": accesstoken
},
onload:function(xhr){
resolve(xhr.responseText);
}
});
});
}
async function UploadTextToAliYunpan(text){
var tempblob=new Blob([text])
if(tempblob.size>uploadsize)
{
alert('文件超出脚本限制大小,无法上传至云盘!请选择导出文件')
return;
}
let create=JSON.parse(await CreateTextUpload(CurrentText(),tempblob.size,sha1(text)))
if(create.rapid_upload==true){
alert('网盘内存在该文件!')
}
let createurl=create.part_info_list[0].upload_url
await UploadTextBin(createurl,text)
let finishret= await Complete(create.upload_id,create.file_id)
if(finishret.indexOf('file_id')==-1)
{
alert('保存至网盘失败!')
}
finishret=JSON.parse(finishret)
let sharurl=GetFileSha1Encr(finishret)
alert('保存至网盘成功!,已设置到剪辑版')
GM_setClipboard(sharurl)
//file_id JSON.parse
console.log('UploadTextToAliYunpan',finishret)
}
function GetDecrText(text){
if(text.indexOf('115://')!==-1)
{
let sizelist=text.replace('115://','').split('|')
if(sizelist.length<4)
{
return 'Error'
}
if(sizelist.length>4)
{
var n = parseInt(sizelist[1]);
if (!isNaN(n))
{
return {content_hash:sizelist[2],content_type:'null',name:sizelist[0],size:sizelist[1]}
}
let temp=text
let sizelength=text.replace('115://','').split('|').length-4
for(let num=0;num<sizelength;num++)
{
temp=temp.replace('|','=')
}
sizelist=temp.replace('115://','').split('|')
}
return {content_hash:sizelist[2],content_type:'null',name:sizelist[0],size:sizelist[1]}
}
let aliyunUrl = text
const aliyunPrefix = ['aliyunpan::', 'aliyunpan://', 'aliyunpan//']
let aliyunResult = {}
if (aliyunPrefix.some((key) => text.indexOf(key) !== -1))
{
if(text.indexOf('http://')!==-1) {
aliyunUrl = text.replace('http://','')
}
aliyunPrefix.forEach((key) => {
try
{
if(aliyunUrl.indexOf(key)!==-1)
{
let sizelist=decodeURIComponent(aliyunUrl).replace(new RegExp(key),'').split('|')
console.log(sizelist.length)
if(sizelist.length!==4)
{
throw 'Error'
}
aliyunResult = {content_hash:sizelist[1],content_type:sizelist[3],name:sizelist[0],size:sizelist[2]}
}
}
catch(err)
{
console.error(err)
aliyunResult = err;
}
})
return aliyunResult
} else {
try
{
return JSON.parse(decodeURIComponent(escape(window.atob(text))))
}
catch(err)
{
return 'Error'
}
}
}
function MulReadialogCreate(){
if(GenerateShow===true)
{
GenerateShow=false;
GenerateDialogShow.remove()
}
//导入文件
if(GenerateFileInShow==true)
{
return;
}
GenerateFileInShow=true
GenerateFileinDialogShow=document.createElement('div')
unsafeWindow.ReadFileList=ReadFileList
GenerateFileinDialogShow.innerHTML=`<div class="ant-modal-content" style=" width: 500px;z-index: 99;position: absolute;top: 50px;left: calc(50% - 250px);"><div class="ant-modal-header"><input id="uploadfile" onchange="ReadFileList(this)" type="file" style="display: none;"><div class="ant-modal-title" id="rcDialogTitle0"><div class="icon-wrapper--3dbbo" style="display: flex;align-items: center;justify-content: space-between;"><span>文件批量导入(请勿导入时关闭)</span> <span data-role="icon" data-render-as="svg" data-icon-type="PDSClose" class="close-icon--33bP0 icon--d-ejA " style=" cursor: pointer;"><svg viewBox="0 0 1024 1024"><use xlink:href="#PDSClose"></use></svg></span></div></div></div><div class="ant-modal-body"><div class=""><div class="cover-wrapper--2UqQb" style="background: var(--background_secondary_blur);flex-direction: column;height: 100px;display: flex;justify-content: center;align-items: center;" data-spm-anchor-id="0.0.0.i6.54a06c75eRjwhJ"><div>多文件批量导出 公众号:<span style=" color: blue;">叛逆青年旅舍</span></div><div>作者<span style=" color: blue;" data-spm-anchor-id="0.0.0.i7.54a06c75eRjwhJ">天才少年李恒道</span>QQ<span style=" color: blue;">4548212<!-- span--></span></div><div>油猴中文网<span style=" color: red;" data-spm-anchor-id="0.0.0.i7.54a06c75eRjwhJ">bbs.tampermonkey.net.cn</span><span style=" color: blue;"><!-- span--></span></div><div></div></div><div class="FileListOutShow " style=" height: calc(100% - 150px); overflow-y: scroll; padding: 5px 20px; max-height: 300px;" data-spm-anchor-id="0.0.0.i7.54a06c75uw7F5E"></div><div style="display: flex;flex-direction: row-reverse;margin-top: 10px;align-items: center;"><div class="button-wrapper--1UkG6" data-type="primary" data-spm-anchor-id="0.0.0.i3.35676c7515rlzj" style="margin-left: 5px;margin-right: 5px;height: 32px;">开始提取</div><div class="button-wrapper--1UkG6" data-type="primary" data-spm-anchor-id="0.0.0.i3.35676c7515rlzj" style="margin-left: 5px;margin-right: 5px;height: 32px;">导入文件</div> <div class="SelectNumShow">当前已选:<span>0</span>项</div></div> </div></div></div>`
GenerateFileinDialogShow.onclick=function(event){
//多选关闭删除
if(event.target.outerHTML.indexOf('#PDSClose')!=-1)
{
Uploadlist=[]
GenerateFileInShow=false;
GenerateFileinDialogShow.remove()
return;
}
if(event.target.outerHTML.indexOf('导入文件')!=-1)
{
document.getElementById("uploadfile").click();
return;
}
if(event.target.outerHTML.indexOf('开始提取')!=-1)
{
alert('正在开始上传,请勿重复点击!')
StartAllFile()
return;
}
}
document.querySelector('body').append(GenerateFileinDialogShow)
}
function MulFileDialogCreate(){
if(GenerateFileInShow==true)
{
Uploadlist=[]
GenerateFileInShow=false;
GenerateFileinDialogShow.remove()
}
if(GenerateShow==true)
{
return;
}
GenerateShow=true
GenerateDialogShow=document.createElement('div')
GenerateDialogShow.innerHTML=`<div class="ant-modal-content" style=" width: 500px;z-index: 99;position: absolute;top: 50px;left: calc(50% - 250px);"><div class="ant-modal-header"><div class="ant-modal-title" id="rcDialogTitle0"><div class="icon-wrapper--3dbbo" style="display: flex;align-items: center;justify-content: space-between;"><span>文件批量导出</span> <span data-role="icon" data-render-as="svg" data-icon-type="PDSClose" class="close-icon--33bP0 icon--d-ejA " style=" cursor: pointer;"><svg viewBox="0 0 1024 1024"><use xlink:href="#PDSClose"></use></svg></span></div></div></div><div class="ant-modal-body"><div class=""><div class="cover-wrapper--2UqQb" style="background: var(--background_secondary_blur);flex-direction: column;height: 100px;display: flex;justify-content: center;align-items: center;" data-spm-anchor-id="0.0.0.i6.54a06c75eRjwhJ"><div>多文件批量导出 公众号:<span style=" color: blue;">叛逆青年旅舍</span></div><div>作者<span style=" color: blue;" data-spm-anchor-id="0.0.0.i7.54a06c75eRjwhJ">天才少年李恒道</span>QQ<span style=" color: blue;">4548212<!-- span--></span></div><div>油猴中文网<span style=" color: red;" data-spm-anchor-id="0.0.0.i7.54a06c75eRjwhJ">bbs.tampermonkey.net.cn</span><span style=" color: blue;"><!-- span--></span></div><div></div></div><div style="background: var(--background_secondary_blur);display: flex;align-items: center;padding: 0px 50px;justify-content: space-evenly;padding-bottom: 10px;"><div>搜索文件</div><input type="text" name="SearchMulFile" data-spm-anchor-id="0.0.0.i1.35676c753HbmyV" value=""><div class="button-wrapper--1UkG6" data-type="primary" data-spm-anchor-id="0.0.0.i3.35676c7515rlzj" style="margin-left: 5px;margin-right: 5px;height: 32px;">搜索</div> </div><div class="FileListOutShow " style=" height: calc(100% - 150px); overflow-y: scroll; padding: 5px 20px; max-height: 300px;" data-spm-anchor-id="0.0.0.i7.54a06c75uw7F5E"> </div><div style="display: flex;flex-direction: row-reverse;margin-top: 10px;align-items: center;"><div class="button-wrapper--1UkG6" data-type="primary" data-spm-anchor-id="0.0.0.i3.35676c7515rlzj" style="margin-left: 5px;margin-right: 5px;height: 32px;">保存至网盘</div><div class="button-wrapper--1UkG6" data-type="primary" data-spm-anchor-id="0.0.0.i3.35676c7515rlzj" style="margin-left: 5px;margin-right: 5px;height: 32px;">导出</div><div class="button-wrapper--1UkG6" data-type="primary" data-spm-anchor-id="0.0.0.i3.35676c7515rlzj" style="margin-left: 5px;margin-right: 5px;height: 32px;">全部选择</div> <div class="SelectNumShow">当前共:<span>330</span>项</div></div> </div></div></div>`
GenerateDialogShow.onclick=function(event){
debugger;
console.log('去他妈的导出',event.target)
//多选关闭删除
if(event.target.outerHTML.indexOf('#PDSClose')!=-1)
{
GenerateShow=false;
GenerateDialogShow.remove()
return;
}
if(event.target.innerText=='全部选择')
{
document.querySelectorAll('.FileListOutShow >div').forEach(item=>{
SetSelectItem(item,true)
})
return;
}
if(event.target.innerText=='搜索')
{
SearchFileMulInsert(document.querySelector('[name="SearchMulFile"]').value);
return;
}
if(event.target.innerText=='保存至网盘')
{
let outtext='阿里云油猴插件By:油猴中文版\n作者:天才少年李恒道QQ:4548212\n公众号:叛逆青年旅舍\n油猴中文网:bbs.tampermonkey.net.cn\n'
document.querySelectorAll('.FileListOutShow >div').forEach(item=>{
if(item.checkbox==true){
outtext=outtext+item.name+'\n'+item.date+'\n'
}
})
if(outtext!=='阿里云油猴插件By:油猴中文版\n作者:天才少年李恒道QQ:4548212\n公众号:叛逆青年旅舍\n油猴中文网:bbs.tampermonkey.net.cn\n')
{
alert('开始进行上传,请勿重复点击!')
UploadTextToAliYunpan(outtext)
}
else{
alert('未选择任何文件')
}
return;
}
if(event.target.innerText=='导出')
{
let outtext='阿里云油猴插件By:油猴中文版\n作者:天才少年李恒道QQ:4548212\n公众号:叛逆青年旅舍\n油猴中文网:bbs.tampermonkey.net.cn\n'
document.querySelectorAll('.FileListOutShow >div').forEach(item=>{
if(item.checkbox==true){
outtext=outtext+item.name+'\n'+item.date+'\n'
}
})
if(outtext!=='阿里云油猴插件By:油猴中文版\n作者:天才少年李恒道QQ:4548212\n公众号:叛逆青年旅舍\n油猴中文网:bbs.tampermonkey.net.cn\n')
{
download('导出文件成功By:油猴中文网.txt',outtext)
}
else{
alert('未选择任何文件')
}
return;
}
}
document.querySelector('body').append(GenerateDialogShow)
SearchFileMulInsert('')
}
function LoadDownloadText(url){
debugger;
GM_xmlhttpRequest({
url:url,
method :"GET",
headers: {
//"Content-type": "application/json;charset=utf-8",
"Referer": "https://www.aliyundrive.com/",
// "Authorization": accesstoken
},
onload:function(xhr){
debugger;
MulReadialogCreate()
AddText(xhr.responseText)
alert('解析完成!')
console.log('解析文本内容!',xhr.responseText)
}
});
}
function DownloadTextRead(obj){
alert('开始读取文件内容,时长根据网速决定,请勿重复点击');
console.log('获取远程对象开始',obj)
let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id
let uploadtext='{"drive_id":"'+useruid+'","file_id":"'+obj.file_id+'"}'
GM_xmlhttpRequest({
url:"https://api.aliyundrive.com/v2/file/get_download_url",
method :"POST",
data:uploadtext,
headers: {
"Content-type": "application/json;charset=utf-8",
"Referer": "https://www.aliyundrive.com/",
"Authorization": accesstoken
},
onload:function(xhr){
var json = JSON.parse(xhr.responseText);
if(json.url===undefined)
{
alert('获取下载地址失败!')
return;
}
LoadDownloadText(json.url)
}
});
//MulReadialogCreate()
}
async function UploadOne(num){
return new Promise((resolve, reject) => {
let obj=Uploadlist[num]
let text=GetDecrText(obj.date)
let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id
let uploadtext='{"drive_id":"'+useruid+'","part_info_list":[{"part_number":1}],"parent_file_id":"'+parent_file_id+'","name":"'+text.name+'","type":"file","check_name_mode":"auto_rename","size":'+text.size+',"content_hash":"'+text.content_hash+'","content_hash_name":"sha1"}'
GM_xmlhttpRequest({
url:"https://api.aliyundrive.com/v2/file/create",
method :"POST",
data:uploadtext,
headers: {
"Content-type": "application/json;charset=utf-8",
"Authorization": accesstoken
},
onload:function(xhr){
var json = JSON.parse(xhr.responseText);
if(json.rapid_upload==true)
{
Success++;
SetSelectItem(obj,true,false)
resolve('success');
}
else{
Faile++;
SetSelectItem(obj,false,false)
resolve('faile');
}
}
});
});
}
async function StartAllFile(){
Uploadlist=document.querySelectorAll('.FileListOutShow >div')
Success=0;
Faile=0;
for(let index=0;index<Uploadlist.length;index++){
if(Uploadlist[index].checkbox===false){
await UploadOne(index)
}
}
alert('上传完毕,成功了:'+Success+'个文件,失败了:'+Faile+'文件')
unsafeWindow.location.reload();
}
function AddText(text){
let list=text.split('\n')
for(let index=0;index<list.length;index++)
{
let rowtext=list[index]
if(rowtext.indexOf('eyJu')!=-1||rowtext.indexOf('aliyunpan://')!=-1||rowtext.indexOf('aliyunpan::')!=-1||rowtext.indexOf('115://')!=-1)
{
let temp=GetDecrText(rowtext)
if(temp.content_hash==undefined)
{
alert('存在文件不正確!已跳過該文件!')
}
else{
let FileItem=document.createElement('div')
totalnum+=1
SetTotalnum()
FileItem.checkbox=false;
FileItem.date=rowtext
FileItem.name=temp.name
FileItem.innerHTML='<div style="display: flex;align-items: center;justify-content: space-between;"> <div style="width: 160px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">'+temp.name+'</div><div style="flex-grow: 1;text-align: center;">'+temp.size+'</div><div class="checkbox--NOwE_ checkbox-container--TNndw" role="checkbox" aria-checked="false" data-checked="false" data-partial="true" data-disabled="false" data-no-padding="false" style="margin-right: 0px;"><div class="checkbox--11DPr" data-spm-anchor-id="0.0.0.i10.54a06c75uw7F5E"></div></div><div></div></div>'
document.querySelector('.FileListOutShow').append(FileItem)
}
}
}
if(document.querySelectorAll('.FileListOutShow >div').length==0)
{
alert('找不到分享码!')
}
}
function ReadFileList(evt){
totalnum=0
SetTotalnum()
let files = evt.files
if (files.length > 0) {
let file = files[0];
let reader = new FileReader();
reader.readAsText(file);
reader.onloadend = () => {
let result = reader.result;
AddText(result)
};
}
}
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
function uploadadded(event){
}
function SetTotalnum(){
document.querySelector('.SelectNumShow span').innerText=totalnum
}
function SetSelectItem(item,check,change=true){
if(item.checkbox===check)
{
return;
}
if( item.checkbox===false)
{
item.checkbox=true
if(change==true)
{
totalnum+=1
SetTotalnum()
}
item.children[0].children[2].setAttribute('data-checked','true')
item.children[0].children[2].innerHTML='<div class="checkbox--11DPr" data-spm-anchor-id="0.0.0.i10.54a06c75uw7F5E"><svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M12.6247 5.29974L7.26637 11.9977L3.83435 8.56567L4.96572 7.4343L7.1337 9.60228L11.3753 4.30023L12.6247 5.29974Z"></path></svg></div>'
}
else{
item.checkbox=false
if(change==true)
{
totalnum-=1
SetTotalnum()
}
item.children[0].children[2].setAttribute('data-checked','false')
item.children[0].children[2].innerHTML='<div class="checkbox--11DPr" data-spm-anchor-id="0.0.0.i10.54a06c75uw7F5E"></div>'
}
}
function SearchFileMulInsert(text){
document.querySelector('.FileListOutShow').innerText=''
totalnum=0
for(let index=0;index<FileList.length;index++){
let templist=FileList[index]
for(let innerindex=0;innerindex<templist.list.length;innerindex++)
{
let tempobj=templist.list[innerindex]
if(tempobj.type!=='folder')
{
if(text===''||tempobj.name.indexOf(text)!=-1)
{
let FileItem=document.createElement('div')
FileItem.checkbox=false;
FileItem.date=GetFileSha1Encr(tempobj)
FileItem.name=tempobj.name
FileItem.innerHTML='<div style="display: flex;align-items: center;justify-content: space-between;"> <div style="width: 160px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">'+tempobj.name+'</div><div style="flex-grow: 1;text-align: center;">'+tempobj.size+'</div><div class="checkbox--NOwE_ checkbox-container--TNndw" role="checkbox" aria-checked="false" data-checked="false" data-partial="true" data-disabled="false" data-no-padding="false" style="margin-right: 0px;"><div class="checkbox--11DPr" data-spm-anchor-id="0.0.0.i10.54a06c75uw7F5E"></div></div><div></div></div>'
FileItem.onclick=function(event){
if(event.target.outerHTML.indexOf('checkbox')!==-1||event.target.outerHTML.indexOf('M12.6247 5.29974L7.26637')!==-1)
{
SetSelectItem(FileItem,!FileItem.checkbox)
}
}
document.querySelector('.FileListOutShow').append(FileItem)
}
}
}
}
SetTotalnum()
}
function ShowToast(text,time=3000){
let toast=document.createElement('div')
toast.innerHTML='<div><div class="drive-toast"><div><div class="drive-toast-notice"><div class="drive-toast-notice-content"><div class="drive-toast-custom-content drive-toast-info"><div></div><span><div class="content-wrapper--B7mAG" style="margin-left: 20px; " data-desc="false"><div class="title-wrapper--3bQQ2">'
+ text+
'<div class="desc-wrapper--218x0"></div></div></div></span></div></div></div></div></div></div>'
document.querySelector('body').append(toast)
setInterval(function(){toast.remove() }, time);
}
function RefreshToken(){
if(accesstoken!=='')
{
return;
}
GM_xmlhttpRequest({
url:"https://websv.aliyundrive.com/token/refresh",
method :"POST",
data:'{"refresh_token": "'+JSON.parse(localStorage.getItem('token')).refresh_token+'"}',
headers: {
"Content-type": "application/json;charset=utf-8",
},
onload:function(xhr){
var json = JSON.parse(xhr.responseText);
accesstoken=json.access_token
if(accesstoken!==undefined&&accesstoken!='')
{
}
else{
ShowToast('解析Acess_Token失败!')
}
}
});
}
function CreateShareClip(tempobj){
ShowFileObj.name=tempobj.name;
ShowFileObj.content_hash=tempobj.content_hash;
ShowFileObj.size=tempobj.size;
ShowFileObj.content_type=tempobj.content_type;
ShowFileObj.file_id=tempobj.file_id;
let ret=confirm('文件名:'+ShowFileObj.name+'\n校验值:'+ShowFileObj.content_hash+'\n文件大小:'+ShowFileObj.size+'\n'+
'点击确定自动添加分享码到剪辑版\n来自油猴中文网bbs.tampermonkey.net.cn\n公众号:叛逆青年旅舍');
if(ret==true)
{
try
{
GM_setClipboard(GetFileSha1Encr(tempobj))
alert('文件已设置到剪辑版!')
}
catch(err)
{
alert('文件名字可能存在特殊关键字,请改名重试')
}
}
}
function StartListner(){
setInterval(function(event) {
if(CreateSaveBtn===false)
{
let header=document.querySelector('[class|=header]')
if(header!==null&&header.childElementCount===2&&document.querySelector('[class|=header]').children[1].innerText.indexOf('提取分享码')===-1){
let GenerateShareBtn=document.createElement('div')
GenerateShareBtn.innerHTML='<div class="button-wrapper--1UkG6" data-type="primary" data-spm-anchor-id="0.0.0.i3.35676c7515rlzj" style="margin-left: 5px;"margin-right:5px;">提取分享码</div>'
GenerateShareBtn.onclick=function(){
var text=prompt("请输入分享码","");
console.log(text)
if(text==null)
{
return;}
try{
text=GetDecrText(text)
}catch(err){
console.error(err)
alert('解析提取码失败!')
return;
}
if(text.content_hash==undefined)
{
alert('提取码不正确!')
}
else{
if(accesstoken=='')
{
alert('访问Token异常!')
return;
}
let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id
let uploadtext='{"drive_id":"'+useruid+'","part_info_list":[{"part_number":1}],"parent_file_id":"'+parent_file_id+'","name":"'+text.name+'","type":"file","check_name_mode":"auto_rename","size":'+text.size+',"content_hash":"'+text.content_hash+'","content_hash_name":"sha1"}'
GM_xmlhttpRequest({
url:"https://api.aliyundrive.com/v2/file/create",
method :"POST",
data:uploadtext,
headers: {
"Content-type": "application/json;charset=utf-8",
"Authorization": accesstoken
},
onload:function(xhr){
var json = JSON.parse(xhr.responseText);
if(json.rapid_upload==true)
{
alert("提取文件成功!")
unsafeWindow.location.reload();
}
else{
alert("提取文件失败!")
}
}
});
}
}
let GenerateFileOut=document.createElement('div')
GenerateFileOut.innerHTML='<div class="button-wrapper--1UkG6" data-type="primary" style="margin-left: 5px;"margin-right:5px;">多文件分享</div>'
GenerateFileOut.onclick=function(){
MulFileDialogCreate()
}
let GenerateFileIn=document.createElement('div')
GenerateFileIn.innerHTML='<div class="button-wrapper--1UkG6" data-type="primary" style="margin-left: 5px;"margin-right:5px;">多文件提取</div>'
GenerateFileIn.onclick=function(){
MulReadialogCreate()
}
document.querySelector('[class|=header]').children[1].append(GenerateShareBtn)
document.querySelector('[class|=header]').children[1].append(GenerateFileOut)
document.querySelector('[class|=header]').children[1].append(GenerateFileIn)
}
}
//info-wrapper--
let formlist=document.querySelectorAll('.ant-modal-body')
for(let forminedx=0;forminedx<formlist.length;forminedx++){
let form=formlist[forminedx]
if(form.offsetWidth==0)
{
continue;
}
if(form!=null&&form.innerHTML.indexOf('详细信息')!=-1)
{
if(form.innerHTML.indexOf('创建时间')!=-1)
{
let img=form.children[0].children[0].children[0].children[0].alt
if(img!==null&&img==="folder")
{
if(document.querySelector('.ant-modal-body').innerText.indexOf('生成分享')!==-1)
{
document.querySelector('.ant-modal-body [data-type="primary"]').remove()
document.querySelector('.ant-modal-body [data-type="primary"]').remove()
}
return;
}
/*if(img!==null&&img.alt==="text")
{
let innertext=document.querySelector('.ant-modal-body').innerText
if(innertext.indexOf('生成分享')!==-1&&innertext.indexOf('远程提取')===-1)
{
document.querySelector('.dingwei').style.display='flex'
document.querySelector('.dingwei').innerHTML='<div class="button-wrapper--1UkG6 FuckNetTextChild" data-type="primary">生成分享</div><div class="button-wrapper--1UkG6 FuckNetTextChild" data-type="primary" style=" margin-left: 5px;">远程提取</div>'
return;
}
}*/
if(form.innerHTML.indexOf('生成分享')==-1)
{
let GenerateFileDate=document.createElement('div')
GenerateFileDate.style.display='flex'
GenerateFileDate.innerHTML='<div class="button-wrapper--1UkG6 FuckNetTextChild" data-type="primary">生成分享</div><div class="button-wrapper--1UkG6 FuckNetTextChild" data-type="primary" style=" margin-left: 5px;">远程提取</div>'
/*if(img.alt==="text")
{
GenerateFileDate.style.display='flex'
GenerateFileDate.innerHTML='<div class="button-wrapper--1UkG6 FuckNetTextChild" data-type="primary">生成分享</div><div class="button-wrapper--1UkG6 FuckNetTextChild" data-type="primary" style=" margin-left: 5px;">远程提取</div>'
}else{
GenerateFileDate.innerHTML='<div class="button-wrapper--1UkG6 FuckNetTextChild" data-type="primary">生成分享</div>'
}*/
GenerateFileDate.onclick=function(event){
debugger;
if(event.target.innerText=='生成分享')
{
let name=document.querySelector('.ant-modal-content [class|=title-wrapper]').innerText
for(let index=0;index<FileList.length;index++){
let templist=FileList[index]
for(let innerindex=0;innerindex<templist.list.length;innerindex++)
{
let tempobj=templist.list[innerindex]
if(tempobj.type!=='folder')
{
if(tempobj.name===name)
{
CreateShareClip(tempobj)
return;
}
}
}
}
return;
}
if(event.target.innerText=='远程提取')
{
let name=document.querySelector('.ant-modal-content [class|=title-wrapper]').innerText
for(let index=0;index<FileList.length;index++){
let templist=FileList[index]
for(let innerindex=0;innerindex<templist.list.length;innerindex++)
{
let tempobj=templist.list[innerindex]
if(tempobj.type!=='folder')
{
if(tempobj.name===name)
{
if(tempobj.file_extension==="txt")
{
console.log('查看文件',tempobj)
if(tempobj.size>uploadsize){
alert('该文本文档的大小过大!无法使用该功能')
}
else{
let temlist=document.querySelectorAll('[role="document"] [data-icon-type="PDSClose"]')
for(let index=0;index<temlist.length;index++){
temlist[index].click()
}
DownloadTextRead(tempobj)
}
}else{
alert('该文件不是文本文件!')
}
return;
}
}
}
}
return;
}
}
let WrapperList=document.querySelectorAll('[class|=group-wrapper]')
WrapperList[WrapperList.length-1].append(GenerateFileDate)
}
}
}
}
}, 1500);
}
if(unsafeWindow.location.href.indexOf('aliyundrive.com/drive')!=-1)
{
function addXMLRequestCallback(callback){
var oldSend, i;
if( XMLHttpRequest.callbacks ) {
XMLHttpRequest.callbacks.push( callback );
} else {
XMLHttpRequest.callbacks = [callback];
oldSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(){
for( i = 0; i < XMLHttpRequest.callbacks.length; i++ ) {
XMLHttpRequest.callbacks[i]( this );
}
if(arguments[0].indexOf!=undefined)
{
if(arguments[0].indexOf('marker')==-1)
{
this.CreatFirstList=true
}else if(FileList.length!=0&&arguments[0].indexOf(FileList[FileList.length-1].name)!==-1){
this.NextList=true
}
if(arguments[0].indexOf('parent_file_id')!==-1)
{
parent_file_id=JSON.parse(arguments[0]).parent_file_id
}
}
//FileList=[{name:item.next_marker,list:item.items}]
oldSend.apply(this, arguments);
}
}
}
addXMLRequestCallback( function( xhr ) {
//CreateBanList
xhr.addEventListener("load", function(){
if ( xhr.readyState == 4 && xhr.status == 200 ) {
if(xhr.responseURL==="https://websv.aliyundrive.com/token/refresh"){
accesstoken=JSON.parse(xhr.response).access_token
}
if(xhr.responseURL==="https://api.aliyundrive.com/v2/file/list")
{
let quit=false;
document.querySelectorAll('.ant-modal-header').forEach((item)=>{
if(item.innerText.indexOf('移动')!==-1)
{
if(item.offsetWidth!==0)
{
quit=true
}
}
})
if(quit)
{
return;
}
let item=JSON.parse(xhr.response)
if(listurl===unsafeWindow.location.href)
{
if(xhr.CreatFirstList==true)
{
FileList=[{name:item.next_marker,list:item.items}]
filenum=item.items.length
}
else{
let Search=false;
FileList.forEach((item)=>{
if(item.name===item.next_marker)
{
item.list=item.items
Search=true
}
})
if(Search===false&&xhr.NextList==true)
{
FileList.push({name:item.next_marker,list:item.items})
filenum+=item.items.length
}
}
}
else{
listurl=unsafeWindow.location.href
FileList=[{name:item.next_marker,list:item.items}]
filenum=item.items.length
}
if(CreateListner===false)
{
StartListner()
CreateListner=true
}
RefreshToken()
ShowToast('已获取文件列表 数量为'+filenum+'(数字如不准请联系作者) By:天才少年李恒道')
}
}
});
});
}
if(unsafeWindow.location.href.indexOf('passport.aliyundrive.com/mini_login.htm')!=-1)
{
let container=document.querySelector('#container');
container.addEventListener("DOMNodeInserted", function(event) {
if(username=='')
{
return}
if(password=='')
{
return}