-
Notifications
You must be signed in to change notification settings - Fork 15
/
worker-multiple-drives.js
1291 lines (1198 loc) · 59.6 KB
/
worker-multiple-drives.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
/* ░██████╗░██████╗░██╗░░░░░░░░██╗░██████╗░░░░█████╗░██████╗░░██████╗░
██╔════╝░██╔══██╗██║░░░░░░░░██║██╔════╝░░░██╔══██╗██╔══██╗██╔════╝░
██║░░██╗░██║░░██║██║░░░░░░░░██║╚█████╗░░░░██║░░██║██████╔╝██║░░██╗░
██║░░╚██╗██║░░██║██║░░░██╗░░██║░╚═══██╗░░░██║░░██║██╔══██╗██║░░╚██╗
╚██████╔╝██████╔╝██║██╗╚█████╔╝██████╔╝██╗╚█████╔╝██║░░██║╚██████╔╝
░╚═════╝░╚═════╝░╚═╝╚═╝░╚════╝░╚═════╝░╚═╝░╚════╝░╚═╝░░╚═╝░╚═════╝░
v 2.2.3
A Script Redesigned by Parveen Bhadoo from GOIndex at https://gitlab.com/GoogleDriveIndex/Google-Drive-Index */
// WARNING WARNING WARNING
// This Script doesn't fully support Folder ID (search won't work), use root or Shared Drive ID only
// add multiple serviceaccounts as {}, {}, {}, random account will be selected by each time app is opened.
const serviceaccounts = [
{}
];
const randomserviceaccount = serviceaccounts[Math.floor(Math.random()*serviceaccounts.length)]; // DO NOT TOUCH THIS
const domains_for_dl = ['']; // add multiple cloudflare addresses to balance the load on download/stream servers, eg. ['https://testing.fetchgoogleapi.workers.dev', 'https://testing2.fetchgoogleapi2.workers.dev']
const domain_for_dl = domains_for_dl[Math.floor(Math.random()*domains_for_dl.length)]; // DO NOT TOUCH THIS
const video_domains_for_dl = ['']; // add multiple cloudflare addresses to balance the load on download/stream servers, eg. ['https://testing.fetchgoogleapi.workers.dev', 'https://testing2.fetchgoogleapi2.workers.dev']
const video_domain_for_dl = video_domains_for_dl[Math.floor(Math.random()*video_domains_for_dl.length)]; // DO NOT TOUCH THIS
const blocked_region = ['']; // add regional codes seperated by comma, eg. ['IN', 'US', 'PK']
const blocked_asn = ['']; // add ASN numbers from http://www.bgplookingglass.com/list-of-autonomous-system-numbers, eg. [16509, 12345]
const authConfig = {
"siteName": "Bhadoo GDIndex", // Website name
"client_id": "", // Client id from Google Cloud Console
"client_secret": "", // Client Secret from Google Cloud Console
"refresh_token": "", // Authorize token
"service_account": false, // true if you're using Service Account instead of user account
"service_account_json": randomserviceaccount, // don't touch this one
"files_list_page_size": 50,
"search_result_list_page_size": 50,
"enable_cors_file_down": false,
"enable_password_file_verify": true, // support for .password file
"direct_link_protection": false, // protects direct links with Display UI
"lock_folders": false, // keeps folders and search locked if auth in on, and allows individual file view
"roots":[
{
"id": "root",
"name": "Drive One",
"protect_file_link": false,
// "auth": {"username":"password"} /* Remove double slash before "auth" to activate id password protection */
},
{
"id": "",
"name": "Drive Two",
"protect_file_link": false,
// "auth": {"username":"password", "username1":"password1"} /* Remove double slash before "auth" to activate id password protection */
},
]};
/*
███████╗██████╗░██╗████████╗ ████████╗██╗░░██╗███████╗░██████╗███████╗
██╔════╝██╔══██╗██║╚══██╔══╝ ╚══██╔══╝██║░░██║██╔════╝██╔════╝██╔════╝
█████╗░░██║░░██║██║░░░██║░░░ ░░░██║░░░███████║█████╗░░╚█████╗░█████╗░░
██╔══╝░░██║░░██║██║░░░██║░░░ ░░░██║░░░██╔══██║██╔══╝░░░╚═══██╗██╔══╝░░
███████╗██████╔╝██║░░░██║░░░ ░░░██║░░░██║░░██║███████╗██████╔╝███████╗
╚══════╝╚═════╝░╚═╝░░░╚═╝░░░ ░░░╚═╝░░░╚═╝░░╚═╝╚══════╝╚═════╝░╚══════╝
██╗░░░██╗░█████╗░██╗░░░░░██╗░░░██╗███████╗░██████╗
██║░░░██║██╔══██╗██║░░░░░██║░░░██║██╔════╝██╔════╝
╚██╗░██╔╝███████║██║░░░░░██║░░░██║█████╗░░╚█████╗░
░╚████╔╝░██╔══██║██║░░░░░██║░░░██║██╔══╝░░░╚═══██╗
░░╚██╔╝░░██║░░██║███████╗╚██████╔╝███████╗██████╔╝
░░░╚═╝░░░╚═╝░░╚═╝╚══════╝░╚═════╝░╚══════╝╚═════╝░*/
const uiConfig = {
"theme": "slate", // switch between themes, default set to slate, select from https://github.com/rokibhasansagar/BhadooGDIndex#themes
"version": "2.2.3", // don't touch this one. get latest code using generator at https://bhadoogen.phantomzone.workers.dev
// If you're using Image then set to true, If you want text then set it to false
"logo_image": true, // true if you're using image link in next option.
"logo_height": "", // only if logo_image is true
"logo_width": "100px", // only if logo_image is true
"favicon": "https://cdn.jsdelivr.net/gh/rokibhasansagar/BhadooGDIndex@2.2.3/images/favicon.ico",
// if logo is true then link otherwise just text for name
"logo_link_name": "https://cdn.jsdelivr.net/gh/rokibhasansagar/BhadooGDIndex@2.2.3/images/bhadoo-cloud-logo-white.svg",
"fixed_header": true, // If you want the footer to be flexible or fixed.
"header_padding": "80", // Value 80 for fixed header, Value 20 for flexible header. Required to be changed accordingly in some themes.
"nav_link_1": "Home", // change navigation link name
"nav_link_3": "Current Path", // change navigation link name
"nav_link_4": "Contact", // change navigation link name
"fixed_footer": false, // If you want the footer to be flexible or fixed.
"hide_footer": true, // hides the footer from site entirely.
"header_style_class": "navbar-dark bg-primary", // navbar-dark bg-primary || navbar-dark bg-dark || navbar-light bg-light
"footer_style_class": "bg-primary", // bg-primary || bg-dark || bg-light
"css_a_tag_color": "white", // Color Name or Hex Code eg. #ffffff
"css_p_tag_color": "white", // Color Name or Hex Code eg. #ffffff
"folder_text_color": "white", // Color Name or Hex Code eg. #ffffff
"loading_spinner_class": "text-light", // https://getbootstrap.com/docs/5.0/components/spinners/#colors
"search_button_class": "btn btn-danger", // https://getbootstrap.com/docs/5.0/components/buttons/#examples
"path_nav_alert_class": "alert alert-primary", // https://getbootstrap.com/docs/4.0/components/alerts/#examples
"file_view_alert_class": "alert alert-danger", // https://getbootstrap.com/docs/4.0/components/alerts/#examples
"file_count_alert_class": "alert alert-secondary", // https://getbootstrap.com/docs/4.0/components/alerts/#examples
"contact_link": "https://telegram.dog/Telegram", // Link to Contact Button on Menu
"copyright_year": "2050", // year of copyright, can be anything like 2015 - 2020 or just 2020
"company_name": "Bhadoo Cloud", // Name next to copyright
"company_link": "https://telegram.dog/Telegram", // link of copyright name
"credit": true, // Set this to true to give us credit
"display_size": true, // Set this to false to hide display file size
"display_time": false, // Set this to false to hide display modified time for folder and files
"display_download": true, // Set this to false to hide download icon for folder and files on main index
"disable_player": false, // Set this to true to hide audio and video players
"custom_srt_lang": "", // Subtitle Language Code for Custom .vtt language.
"disable_video_download": false, // Remove Download, Copy Button on Videos
"second_domain_for_dl": false, // If you want to display other URL for Downloading to protect your main domain.
"downloaddomain": domain_for_dl, // Ignore this and set domains at top of this page after service accounts.
"videodomain": video_domain_for_dl, // Ignore this and set domains at top of this page after service accounts.
"poster": "https://cdn.jsdelivr.net/gh/rokibhasansagar/BhadooGDIndex@2.2.3/images/poster.jpg", // Video poster URL or see Readme to how to load from Drive
"audioposter": "https://cdn.jsdelivr.net/gh/rokibhasansagar/BhadooGDIndex@2.2.3/images/music.jpg", // Video poster URL or see Readme to how to load from Drive
"jsdelivr_cdn_src": "https://cdn.jsdelivr.net/gh/rokibhasansagar/BhadooGDIndex", // If Project is Forked, then enter your GitHub repo
"render_head_md": true, // Render Head.md
"render_readme_md": true, // Render Readme.md
"display_drive_link": false, // This will add a Link Button to Google Drive of that particular file.
"plyr_io_version": "3.7.3", // Change plyr.io version in future when needed.
"plyr_io_video_resolution": "16:9", // For reference, visit: https://github.com/sampotts/plyr#options
"unauthorized_owner_link": "https://telegram.dog/Telegram", // Unauthorized Error Page Link to Owner
"unauthorized_owner_email": "abuse@telegram.org", // Unauthorized Error Page Owner Email
};
/*
██████╗░░█████╗░ ███╗░░██╗░█████╗░████████╗ ███████╗██████╗░██╗████████╗
██╔══██╗██╔══██╗ ████╗░██║██╔══██╗╚══██╔══╝ ██╔════╝██╔══██╗██║╚══██╔══╝
██║░░██║██║░░██║ ██╔██╗██║██║░░██║░░░██║░░░ █████╗░░██║░░██║██║░░░██║░░░
██║░░██║██║░░██║ ██║╚████║██║░░██║░░░██║░░░ ██╔══╝░░██║░░██║██║░░░██║░░░
██████╔╝╚█████╔╝ ██║░╚███║╚█████╔╝░░░██║░░░ ███████╗██████╔╝██║░░░██║░░░
╚═════╝░░╚════╝░ ╚═╝░░╚══╝░╚════╝░░░░╚═╝░░░ ╚══════╝╚═════╝░╚═╝░░░╚═╝░░░
██████╗░███████╗██╗░░░░░░█████╗░░██╗░░░░░░░██╗
██╔══██╗██╔════╝██║░░░░░██╔══██╗░██║░░██╗░░██║
██████╦╝█████╗░░██║░░░░░██║░░██║░╚██╗████╗██╔╝
██╔══██╗██╔══╝░░██║░░░░░██║░░██║░░████╔═████║░
██████╦╝███████╗███████╗╚█████╔╝░░╚██╔╝░╚██╔╝░
╚═════╝░╚══════╝╚══════╝░╚════╝░░░░╚═╝░░░╚═╝░░*/
// DON'T TOUCH BELOW THIS UNLESS YOU KNOW WHAT YOU'RE DOING
var gds = [];
function html(current_drive_order = 0, model = {}) {
return `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
<title>${authConfig.siteName}</title>
<meta name="robots" content="noindex" />
<link rel="icon" href="${uiConfig.favicon}">
<script>
window.drive_names = JSON.parse('${JSON.stringify(authConfig.roots.map(it => it.name))}');
window.drive_ids = ${JSON.stringify(authConfig.roots.map(it => it.id))};
window.MODEL = JSON.parse('${JSON.stringify(model)}');
window.current_drive_order = ${current_drive_order};
window.UI = JSON.parse('${JSON.stringify(uiConfig)}');
</script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.plyr.io/${uiConfig.plyr_io_version}/plyr.css" />
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.0.0/dist/${uiConfig.theme}/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<style>a{color:${uiConfig.css_a_tag_color};}p{color:${uiConfig.css_p_tag_color};}</style>
<script src="${uiConfig.jsdelivr_cdn_src}@${uiConfig.version}/js/app-multiple-drives.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@2.12.313/build/pdf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked@4.0.0/marked.min.js"></script>
</head>
<body>
</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
<script src="https://cdn.plyr.io/${uiConfig.plyr_io_version}/plyr.polyfilled.js"></script>
</html>`;
};
const homepage = `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
<title>${authConfig.siteName}</title>
<meta name="robots" content="noindex">
<link rel="icon" href="${uiConfig.favicon}">
<script>
window.drive_names = JSON.parse('${JSON.stringify(authConfig.roots.map(it => it.name))}');
window.UI = JSON.parse('${JSON.stringify(uiConfig)}');
</script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.plyr.io/${uiConfig.plyr_io_version}/plyr.css" />
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.0.0/dist/${uiConfig.theme}/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<style>a{color:${uiConfig.css_a_tag_color};}p{color:${uiConfig.css_p_tag_color};}</style>
</head>
<body>
<header>
<div id="nav">
<nav class="navbar navbar-expand-lg${uiConfig.fixed_header ?' fixed-top': ''} ${uiConfig.header_style_class}">
<div class="container-fluid">
<a class="navbar-brand" href="/">${uiConfig.logo_image ? '<img border="0" alt="'+uiConfig.company_name+'" src="'+uiConfig.logo_link_name+'" height="'+uiConfig.height+'" width="'+uiConfig.logo_width+'">' : uiConfig.logo_link_name}</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="/">${uiConfig.nav_link_1}</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Current Path</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown"><a class="dropdown-item" href="/">> ${uiConfig.nav_link_1}</a></div>
</li>
<li class="nav-item">
<a class="nav-link" href="${uiConfig.contact_link}" target="_blank">${uiConfig.nav_link_4}</a>
</li>
</ul>
<form class="d-flex" method="get" action="/0:search">
<input class="form-control me-2" name="q" type="search" placeholder="Search" aria-label="Search" value="" required="">
<button class="btn btn btn-danger" onclick="if($('#search_bar_form>input').val()) $('#search_bar_form').submit();" type="submit">Search</button>
</form>
</div>
</div>
</nav>
</div>
</header>
<div>
<div id="content" style="padding-top: ${uiConfig.header_padding}px;">
<div class="container">
<div class="alert alert-primary d-flex align-items-center" role="alert" style="margin-bottom: 0; padding-bottom: 0rem;">
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb" id="folderne">
<li class="breadcrumb-item"><a href="/">Home</a></li>
</ol>
</nav>
</div>
<div id="list" class="list-group text-break">
</div>
<div class="${uiConfig.file_count_alert_class} text-center" role="alert" id="count">Total <span id="n_drives" class="number text-center"></span> drives</div>
</div>
</div>
<div class="modal fade" id="SearchModel" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="SearchModelLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="SearchModelLabel"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true"></span>
</button>
</div>
<div class="modal-body" id="modal-body-space">
</div>
<div class="modal-footer" id="modal-body-space-buttons">
</div>
</div>
</div>
</div>
<br>
<footer class="footer mt-auto py-3 text-muted ${uiConfig.footer_style_class}" style="${uiConfig.fixed_footer ?'position: fixed; ': ''}left: 0; bottom: 0; width: 100%; color: white; z-index: 9999;${uiConfig.hide_footer ? ' display:none;': ' display:block;'}"> <div class="container" style="width: auto; padding: 0 10px;"> <p class="float-end"> <a href="#">Back to top</a> </p> ${uiConfig.credit ? '<p>Redesigned with <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-heart-fill" fill="red" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z" /> </svg> by <a href="https://www.npmjs.com/package/@googledrive/index" target="_blank">TheFirstSpeedster</a>, based on Open Source Softwares.</p>' : ''} <p>© ${uiConfig.copyright_year} - <a href=" ${uiConfig.company_link}" target="_blank"> ${uiConfig.company_name}</a>, All Rights Reserved.</p> </div> </footer>
</div>
</body>
<script src="${uiConfig.jsdelivr_cdn_src}@${uiConfig.version}/assets/homepage.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
</html>`
const unauthorized = `<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Sign in - ${authConfig.siteName}</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="${uiConfig.favicon}">
<script type="text/javascript" src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<style id="compiled-css" type="text/css">.login,.image{min-height:100vh}.bg-image{background-image:url('https://cdn.jsdelivr.net/gh/logingateway/images@1.0/background.jpg');background-size:cover;background-position:center center}#error-message{display:none}</style>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@700&family=Palette+Mosaic&display=swap" rel="stylesheet">
<style>
.logo{font-family:'Orbitron', sans-serif;color:#007bff}
</style>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
$(document).ready(function()
{
$('form').submit(function()
{
var username = $('#email').val();
var password = $('#password').val();
$.ajax(
{
'password' : password,
'username' : username,
'url' : '',
'type' : 'GET',
'success' : function(){ window.location = ''; },
'error' : function(){document.getElementById('error').innerHTML = 'Invalid Login Details, Retry or Contact Admin.';},
}
);
return false;
});
});
</script>
</head>
<body>
<div class="container-fluid">
<div class="row no-gutter">
<div class="col-md-6 d-none d-md-flex bg-image"></div>
<div class="col-md-6 bg-light">
<div class="login d-flex align-items-center py-5">
<div class="container">
<div class="row">
<div class="col-lg-10 col-xl-7 mx-auto">
<h3 class="logo">${authConfig.siteName}</h3>
<p class="text-muted mb-4">Requires Common Sense...</p>
<div id="error-message" class="alert alert-danger"></div>
<form onsubmit="return false;" method="post">
<p id="error" style="color:red;"></p>
<div class="form-group mb-3">
<input id="email" type="text" placeholder="Username" autofocus="" class="form-control rounded-pill border-0 shadow-sm px-4" required>
</div>
<div class="form-group mb-3">
<input id="password" type="password" placeholder="Password" class="form-control rounded-pill border-0 shadow-sm px-4 text-primary" required>
</div>
<button id="btn-login" type="submit" class="btn btn-primary btn-block text-uppercase mb-2 rounded-pill shadow-sm">Login</button>
<hr class="solid">
<center>
<p id="hidereset">
<marquee>No Signup Process Available, contact your administrator for id and password at ${uiConfig.unauthorized_owner_email} or visit ${uiConfig.unauthorized_owner_link}.</marquee>
</p>
</center>
</form>
</div>
</div>
</div>
</div>
<center>
<p>
© <script>document.write(new Date().getFullYear())</script> ${uiConfig.company_name}
</p>
</center>
</div>
</div>
</div>
</body>
</html>`
const not_found = `<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p id="status"></p>
<script>
document.getElementById("status").innerHTML =
"The requested URL <code>" + window.location.pathname + "</code> was not found on this server. <ins>That’s all we know.</ins>";
</script>`
const asn_blocked = `<html>
<head>
<title>Access Denied</title>
<link href='https://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'>
<style>
body{margin:0;padding:0;width:100%;height:100%;color:#b0bec5;display:table;font-weight:100;font-family:Lato}.container{text-align:center;display:table-cell;vertical-align:middle}.content{text-align:center;display:inline-block}.message{font-size:80px;margin-bottom:40px}a{text-decoration:none;color:#3498db}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="message">Access Denied</div>
</div>
</div>
</body>
</html>`
const directlink = `
<html>
<head>
<title>Direct Link - Access Denied</title>
<link href='https://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'>
<style>
body{margin:0;padding:0;width:100%;height:100%;color:#b0bec5;display:table;font-weight:100;font-family:Lato}.container{text-align:center;display:table-cell;vertical-align:middle}.content{text-align:center;display:inline-block}.message{font-size:80px;margin-bottom:40px}a{text-decoration:none;color:#3498db}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="message">Access Denied</div>
<center><a href=""><button id="goto">Click Here to Proceed!</button></a></center>
</div>
</div>
</body>
</html>
`
const SearchFunction = {
formatSearchKeyword: function(keyword) {
let nothing = "";
let space = " ";
if (!keyword) return nothing;
return keyword.replace(/(!=)|['"=<>/\\:]/g, nothing)
.replace(/[,,|(){}]/g, space)
.trim()
}
};
const DriveFixedTerms = new(class {
default_file_fields = 'parents,id,name,mimeType,modifiedTime,createdTime,fileExtension,size';
gd_root_type = {
user_drive: 0,
share_drive: 1
};
folder_mime_type = 'application/vnd.google-apps.folder';
})();
const JSONWebToken = {
header: {
alg: 'RS256',
typ: 'JWT'
},
importKey: async function(pemKey) {
var pemDER = this.textUtils.base64ToArrayBuffer(pemKey.split('\n').map(s => s.trim()).filter(l => l.length && !l.startsWith('---')).join(''));
return crypto.subtle.importKey('pkcs8', pemDER, {
name: 'RSASSA-PKCS1-v1_5',
hash: 'SHA-256'
}, false, ['sign']);
},
createSignature: async function(text, key) {
const textBuffer = this.textUtils.stringToArrayBuffer(text);
return crypto.subtle.sign('RSASSA-PKCS1-v1_5', key, textBuffer)
},
generateGCPToken: async function(serviceAccount) {
const iat = parseInt(Date.now() / 1000);
var payload = {
"iss": serviceAccount.client_email,
"scope": "https://www.googleapis.com/auth/drive",
"aud": "https://oauth2.googleapis.com/token",
"exp": iat + 3600,
"iat": iat
};
const encPayload = btoa(JSON.stringify(payload));
const encHeader = btoa(JSON.stringify(this.header));
var key = await this.importKey(serviceAccount.private_key);
var signed = await this.createSignature(encHeader + "." + encPayload, key);
return encHeader + "." + encPayload + "." + this.textUtils.arrayBufferToBase64(signed).replace(/\//g, '_').replace(/\+/g, '-');
},
textUtils: {
base64ToArrayBuffer: function(base64) {
var binary_string = atob(base64);
var len = binary_string.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes.buffer;
},
stringToArrayBuffer: function(str) {
var len = str.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = str.charCodeAt(i);
}
return bytes.buffer;
},
arrayBufferToBase64: function(buffer) {
let binary = '';
let bytes = new Uint8Array(buffer);
let len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary);
}
}
};
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request, event).catch(
(err) => new Response("GDI Error Handler Version : 1.0\nReport this Error to Email : admin@hashhackers.com\nInclude : Full details, including screenshot and links\n\n\n" + err.stack, { status: 500 })
)
);
});
async function handleRequest(request, event) {
const region = request.headers.get('cf-ipcountry').toUpperCase();
try {var asn_servers = request.cf.asn;}catch {var asn_servers = 0;}
const referer = request.headers.get("Referer");
if (gds.length === 0) {
for (let i = 0; i < authConfig.roots.length; i++) {
const gd = new googleDrive(authConfig, i);
await gd.init();
gds.push(gd)
}
let tasks = [];
gds.forEach(gd => {
tasks.push(gd.initRootType());
});
for (let task of tasks) {
await task;
}
}
let gd;
let url = new URL(request.url);
let path = url.pathname;
let hostname = url.hostname;
function redirectToIndexPage() {
return new Response('', {
status: 307,
headers: {
'Location': url
}
});
}
if (blocked_region.includes(region)) {
return new Response(asn_blocked, {
status: 403,
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
} else if (blocked_asn.includes(asn_servers)) {
return new Response(asn_blocked, {
headers: {
'content-type': 'text/html;charset=UTF-8'
},
status: 401
});
} else if (path == '/') {
return new Response(homepage, {
status: 200,
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
}
if (authConfig['direct_link_protection']) {
if (referer == null){
return new Response(directlink, {
headers: {
'content-type': 'text/html;charset=UTF-8'
},
status: 401
});
console.log("Refer Null");
} else if (referer.includes(hostname)) {
console.log("Refer Detected");
} else {
return new Response(directlink, {
headers: {
'content-type': 'text/html;charset=UTF-8'
},
status: 401
});
console.log("Wrong Refer URL");
}
}
const command_reg = /^\/(?<num>\d+):(?<command>[a-zA-Z0-9]+)(\/.*)?$/g;
const match = command_reg.exec(path);
if (match) {
const num = match.groups.num;
const order = Number(num);
if (order >= 0 && order < gds.length) {
gd = gds[order];
} else {
return redirectToIndexPage()
}
for (const r = gd.basicAuthResponse(request); r;) return r;
const command = match.groups.command;
if (command === 'search') {
if (request.method === 'POST') {
return handleSearch(request, gd);
} else {
const params = url.searchParams;
return new Response(html(gd.order, {
q: params.get("q").replace(/'/g, "").replace(/"/g, "") || '',
is_search_page: true,
root_type: gd.root_type
}), {
status: 200,
headers: {
'Content-Type': 'text/html; charset=utf-8'
}
});
}
} else if (command === 'id2path' && request.method === 'POST') {
return handleId2Path(request, gd)
}
}
const common_reg = /^\/\d+:\/.*$/g;
try {
if (!path.match(common_reg)) {
return redirectToIndexPage();
}
let split = path.split("/");
let order = Number(split[1].slice(0, -1));
if (order >= 0 && order < gds.length) {
gd = gds[order];
} else {
return redirectToIndexPage()
}
} catch (e) {
return redirectToIndexPage()
}
const basic_auth_res = gd.basicAuthResponse(request);
path = path.replace(gd.url_path_prefix, '') || '/';
if (request.method == 'POST') {
return basic_auth_res || apiRequest(request, gd);
}
let action = url.searchParams.get('a');
if (path.substr(-1) == '/' || action != null) {
return basic_auth_res || new Response(html(gd.order, {
root_type: gd.root_type
}), {
status: 200,
headers: {
'Content-Type': 'text/html; charset=utf-8'
}
});
} else {
try {
if (path.split('/').pop().toLowerCase() == ".password") {
return basic_auth_res || new Response("", {
status: 404
});
}
let file = await gd.file(path);
let range = request.headers.get('Range');
const inline_down = 'true' === url.searchParams.get('inline');
if (gd.root.protect_file_link && basic_auth_res) return basic_auth_res;
return gd.down(file?.id, range, inline_down);
}
catch {
return new Response(not_found, {
status: 404,
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
}
}
}
function gdiencode(str) {
var gdijsorg_0x40df = ['1KzJBAK', '1697708zMrtEu', '295396TasIvj', '21011Eyuayv', '1217593CxovUD', 'fromCharCode', '143062xekFCR', 'replace', '74bcHwvq', '73939wlqHSM', '2CBdqkc', '1712527AcNPoP'];
var gdijsorg_0x5556bb = gdijsorg_0x56b1;
(function(_0x3f3911, _0x38bce9) {
var _0x32440e = gdijsorg_0x56b1;
while (!![]) {
try {
var _0x2cab6f = -parseInt(_0x32440e(0xb3)) + -parseInt(_0x32440e(0xb7)) * -parseInt(_0x32440e(0xb6)) + -parseInt(_0x32440e(0xaf)) * -parseInt(_0x32440e(0xad)) + -parseInt(_0x32440e(0xb1)) + parseInt(_0x32440e(0xae)) + parseInt(_0x32440e(0xac)) + parseInt(_0x32440e(0xb0)) * -parseInt(_0x32440e(0xb5));
if (_0x2cab6f === _0x38bce9) break;
else _0x3f3911['push'](_0x3f3911['shift']());
} catch (_0x34d506) {
_0x3f3911['push'](_0x3f3911['shift']());
}
}
}(gdijsorg_0x40df, 0xe5038));
function gdijsorg_0x56b1(_0x1ccc20, _0x1596c4) {
_0x1ccc20 = _0x1ccc20 - 0xac;
var _0x40df0f = gdijsorg_0x40df[_0x1ccc20];
return _0x40df0f;
}
return btoa(encodeURIComponent(str)[gdijsorg_0x5556bb(0xb4)](/%([0-9A-F]{2})/g, function toSolidBytes(_0xe8cc7f, _0x12410f) {
var _0x1cce23 = gdijsorg_0x5556bb;
return String[_0x1cce23(0xb2)]('0x' + _0x12410f);
}));
}
async function apiRequest(request, gd) {
let url = new URL(request.url);
let path = url.pathname;
path = path.replace(gd.url_path_prefix, '') || '/';
let option = {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*'
}
}
if (path.substr(-1) == '/') {
let form = await request.formData();
let deferred_list_result = gd.list(path, form.get('page_token'), Number(form.get('page_index')));
if (authConfig['enable_password_file_verify']) {
let password = await gd.password(path);
// console.log("dir password", password);
if (password && password.replace("\n", "") !== form.get('password')) {
let html = `Y29kZWlzcHJvdGVjdGVk=0Xfi4icvJnclBCZy92dzNXYwJCI6ISZnF2czVWbiwSMwQDI6ISZk92YisHI6IicvJnclJyeYmFzZTY0aXNleGNsdWRlZA==`;
return new Response(html, option);
}
}
let list_result = await deferred_list_result;
return new Response(rewrite(gdiencode(JSON.stringify(list_result), option)));
} else {
let file = await gd.file(path);
let range = request.headers.get('Range');
return new Response(rewrite(gdiencode(JSON.stringify(file))));
}
}
// deal with search
async function handleSearch(request, gd) {
const option = {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*'
}
};
let form = await request.formData();
let search_result = await
gd.search(form.get('q') || '', form.get('page_token'), Number(form.get('page_index')));
return new Response(rewrite(gdiencode(JSON.stringify(search_result), option)));
}
async function handleId2Path(request, gd) {
const option = {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*'
}
};
let form = await request.formData();
let path = await gd.findPathById(form.get('id'));
return new Response(path || '', option);
}
class googleDrive {
constructor(authConfig, order) {
this.order = order;
this.root = authConfig.roots[order];
this.root.protect_file_link = this.root.protect_file_link || false;
this.url_path_prefix = `/${order}:`;
this.authConfig = authConfig;
this.paths = [];
this.files = [];
this.passwords = [];
this.id_path_cache = {};
this.id_path_cache[this.root['id']] = '/';
this.paths["/"] = this.root['id'];
}
async init() {
await this.accessToken();
if (authConfig.user_drive_real_root_id) return;
const root_obj = await (gds[0] || this).findItemById('root');
if (root_obj && root_obj.id) {
authConfig.user_drive_real_root_id = root_obj.id
}
}
async initRootType() {
const root_id = this.root['id'];
const types = DriveFixedTerms.gd_root_type;
if (root_id === 'root' || root_id === authConfig.user_drive_real_root_id) {
this.root_type = types.user_drive;
} else {
this.root_type = types.share_drive;
}
}
basicAuthResponse(request) {
let url = new URL(request.url);
let path = url.pathname;
const auth = this.root.auth || '',
_401 = new Response(unauthorized, {
headers: {
'WWW-Authenticate': `Basic realm="goindex:drive:${this.order}"`,
'content-type': 'text/html;charset=UTF-8'
},
status: 401
});
if (authConfig['lock_folders']) {
if (auth && path.endsWith("/") || path.endsWith("search")) {
const _auth = request.headers.get('Authorization')
if (_auth) {
const [received_user, received_pass] = atob(_auth.split(' ').pop()).split(':');
if (auth.hasOwnProperty(received_user)) {
if (auth[received_user] == received_pass) {
return null;
} else return _401;
} else return _401;
}
} else return null;
} else {
if (auth) {
const _auth = request.headers.get('Authorization')
if (_auth) {
const [received_user, received_pass] = atob(_auth.split(' ').pop()).split(':');
if (auth.hasOwnProperty(received_user)) {
if (auth[received_user] == received_pass) {
return null;
} else return _401;
} else return _401;
}
} else return null;
}
return _401;
}
async down(id, range = '', inline = false) {
let url = `https://www.googleapis.com/drive/v3/files/${id}?alt=media`;
let requestOption = await this.requestOption();
requestOption.headers['Range'] = range;
let res = await fetch(url, requestOption);
const second_domain_for_dl = `${uiConfig.second_domain_for_dl}`
if (second_domain_for_dl == 'true') {
const res = await fetch(`${uiConfig.jsdelivr_cdn_src}@${uiConfig.version}/assets/disable_download.html`);
return new Response(await res.text(), {
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
}
else if (res.ok) {
const {
headers
} = res = new Response(res.body, res)
this.authConfig.enable_cors_file_down && headers.append('Access-Control-Allow-Origin', '*');
inline === true && headers.set('Content-Disposition', 'inline');
return res;
}
else if(res.status == 404){
return new Response(not_found, {
status: 404,
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
}
else {
const res = await fetch(`${uiConfig.jsdelivr_cdn_src}@${uiConfig.version}/assets/download_error.html`);
return new Response(await res.text(), {
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
}
}
async file(path) {
if (typeof this.files[path] == 'undefined') {
this.files[path] = await this._file(path);
}
return this.files[path];
}
async _file(path) {
let arr = path.split('/');
let name = arr.pop();
name = decodeURIComponent(name).replace(/\'/g, "\\'");
let dir = arr.join('/') + '/';
// console.log(name, dir);
let parent = await this.findPathId(dir);
// console.log(parent);
let url = 'https://www.googleapis.com/drive/v3/files';
let params = {
'includeItemsFromAllDrives': true,
'supportsAllDrives': true
};
params.q = `'${parent}' in parents and name = '${name}' and trashed = false and mimeType != 'application/vnd.google-apps.shortcut'`;
params.fields = "files(id, name, mimeType, size ,createdTime, modifiedTime, iconLink, thumbnailLink)";
url += '?' + this.enQuery(params);
let requestOption = await this.requestOption();
let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if (response.status === 200) {
break;
}
await this.sleep(800 * (i + 1));
}
let obj = await response.json();
// console.log(obj);
return obj.files[0];
}
async list(path, page_token = null, page_index = 0) {
if (this.path_children_cache == undefined) {
// { <path> :[ {nextPageToken:'',data:{}}, {nextPageToken:'',data:{}} ...], ...}
this.path_children_cache = {};
}
if (this.path_children_cache[path] &&
this.path_children_cache[path][page_index] &&
this.path_children_cache[path][page_index].data
) {
let child_obj = this.path_children_cache[path][page_index];
return {
nextPageToken: child_obj.nextPageToken || null,
curPageIndex: page_index,
data: child_obj.data
};
}
let id = await this.findPathId(path);
let result = await this._ls(id, page_token, page_index);
let data = result.data;
if (result.nextPageToken && data.files) {
if (!Array.isArray(this.path_children_cache[path])) {
this.path_children_cache[path] = []
}
this.path_children_cache[path][Number(result.curPageIndex)] = {
nextPageToken: result.nextPageToken,
data: data
};
}
return result
}
async _ls(parent, page_token = null, page_index = 0) {
if (parent == undefined) {
return null;
}
let obj;
let params = {
'includeItemsFromAllDrives': true,
'supportsAllDrives': true
};
params.q = `'${parent}' in parents and trashed = false AND name !='.password' and mimeType != 'application/vnd.google-apps.shortcut'`;
params.orderBy = 'folder,name,modifiedTime desc';
params.fields = "nextPageToken, files(id, name, mimeType, size , modifiedTime)";
params.pageSize = this.authConfig.files_list_page_size;
if (page_token) {
params.pageToken = page_token;
}
let url = 'https://www.googleapis.com/drive/v3/files';
url += '?' + this.enQuery(params);
let requestOption = await this.requestOption();
let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if (response.status === 200) {
break;
}
await this.sleep(800 * (i + 1));
}
obj = await response.json();
return {
nextPageToken: obj.nextPageToken || null,
curPageIndex: page_index,
data: obj
};
}
async password(path) {
if (this.passwords[path] !== undefined) {
return this.passwords[path];
}
let file = await this.file(path + '.password');
if (file == undefined) {
this.passwords[path] = null;
} else {
let url = `https://www.googleapis.com/drive/v3/files/${file.id}?alt=media`;
let requestOption = await this.requestOption();
let response = await this.fetch200(url, requestOption);
this.passwords[path] = await response.text();
}
return this.passwords[path];
}
async search(origin_keyword, page_token = null, page_index = 0) {
const types = DriveFixedTerms.gd_root_type;
const is_user_drive = this.root_type === types.user_drive;
const is_share_drive = this.root_type === types.share_drive;
const empty_result = {
nextPageToken: null,
curPageIndex: page_index,
data: null
};
if (!is_user_drive && !is_share_drive) {
return empty_result;
}
let keyword = SearchFunction.formatSearchKeyword(origin_keyword);
if (!keyword) {
return empty_result;