[Go to site: main page, start]

0% found this document useful (0 votes)
7 views40 pages

Configuring Web App UI Settings

The document contains configuration settings for a web application, including UI elements like logos, navigation links, and footer options. It specifies styles, colors, and behavior for various components such as headers, alerts, and buttons. Additionally, it includes scripts for rendering the application and managing user interactions, along with links to external resources and libraries.

Uploaded by

yvaauast
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views40 pages

Configuring Web App UI Settings

The document contains configuration settings for a web application, including UI elements like logos, navigation links, and footer options. It specifies styles, colors, and behavior for various components such as headers, alerts, and buttons. Additionally, it includes scripts for rendering the application and managing user interactions, along with links to external resources and libraries.

Uploaded by

yvaauast
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

true then link otherwise just text for name

"logo_link_name":
"[Link]
[Link]",
"login_image": "[Link] // Login page logo image
"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", //
[Link]
"search_button_class": "btn btn-danger", //
[Link]
"path_nav_alert_class": "alert alert-primary", //
[Link]
"file_view_alert_class": "alert alert-danger", //
[Link]
"file_count_alert_class": "alert alert-secondary", //
[Link]
"contact_link": "[Link] // Link to Contact Button
on Menu
"copyright_year": "2025", // year of copyright, can be anything like 2015 - 2020
or just 2020
"company_name": "The Bay Index", // Name next to copyright
"company_link": "[Link] // 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
"disable_video_download": false, // Remove Download, Copy Button on Videos
"allow_selecting_files": true, // Disable Selecting Files to Download in Bulk
"second_domain_for_dl": false, // If you want to display other URL for
Downloading to protect your main domain.
"poster":
"[Link] // Video
poster URL or see Readme to how to load from Drive
"audioposter":
"[Link] // Video
poster URL or see Readme to how to load from Drive
"jsdelivr_cdn_src": "[Link] // If
Project is Forked, then enter your GitHub repo
"render_head_md": true, // Render [Link]
"render_readme_md": true, // Render [Link]
"unauthorized_owner_link": "[Link] // Unauthorized
Error Page Link to Owner
"unauthorized_owner_email": "abuse@[Link]", // Unauthorized Error Page
Owner Email
"downloaddomain": domain_for_dl, // Ignore this and set domains at top of this
page after service accounts.
"show_logout_button": authConfig.enable_login ? true : false, // set to true if
you want to add logout button
};

const player_config = {
"player": "videojs", // videojs || plyr || dplayer || jwplayer
"videojs_version": "8.3.0", // Change videojs version in future when needed.
"plyr_io_version": "3.7.8",
"jwplayer_version": "8.16.2"
}

// DON'T TOUCH BELOW THIS UNLESS YOU KNOW WHAT YOU'RE DOING
var gds = [];
const drive_list = [Link](it => [Link])
let app_js_file
if (environment === 'production') {
app_js_file = uiConfig.jsdelivr_cdn_src + '@' + [Link] +
'/src/[Link]'
} else if (environment === 'development') {
app_js_file = '/[Link]'
} else if (environment === 'local') {
app_js_file = '[Link]
}

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>${[Link]}</title>
<meta name="robots" content="noindex" />
<link rel="icon" href="${[Link]}">
<style>
.navbar-brand {font-family: Cinemathic Visualation;font-size: 30px;}.footer-text
{font-family: Cinemathic Visualation;font-size: 40px;}a {color:white;}p
{color:white;} .logo_new {font-family: Cinemathic Visualation;font-size:
50px;color:white;} .loading {position: fixed;z-index: 999;height: 2em;width:
2em;overflow: show;margin: auto;top: 0;left: 0;bottom: 0;right: 0;}.loading:before
{content: '';display: block;position: fixed;top: 0;left: 0;width: 100%;height:
100%;background: radial-gradient(rgba(20, 20, 20,.8), rgba(0, 0,
0, .8));background: -webkit-radial-gradient(rgba(20, 20, 20,.8), rgba(0, 0,
0,.8));}.loading:not(:required) {font: 0/0 a;color: transparent;text-shadow:
none;background-color: transparent;border: 0;}.loading:not(:required):after
{content: '';display: block;font-size: 10px;width: 1em;height: 1em;margin-top: -
0.5em;-webkit-animation: spinner 150ms infinite linear;-moz-animation: spinner
150ms infinite linear;-ms-animation: spinner 150ms infinite linear;-o-animation:
spinner 150ms infinite linear;animation: spinner 150ms infinite linear;border-
radius: 0.5em;-webkit-box-shadow: rgba(255,255,255, 0.75) 1.5em 0 0 0,
rgba(255,255,255, 0.75) 1.1em 1.1em 0 0, rgba(255,255,255, 0.75) 0 1.5em 0 0,
rgba(255,255,255, 0.75) -1.1em 1.1em 0 0, rgba(255,255,255, 0.75) -1.5em 0 0 0,
rgba(255,255,255, 0.75) -1.1em -1.1em 0 0, rgba(255,255,255, 0.75) 0 -1.5em 0 0,
rgba(255,255,255, 0.75) 1.1em -1.1em 0 0;box-shadow: rgba(255,255,255, 0.75) 1.5em
0 0 0, rgba(255,255,255, 0.75) 1.1em 1.1em 0 0, rgba(255,255,255, 0.75) 0 1.5em 0
0, rgba(255,255,255, 0.75) -1.1em 1.1em 0 0, rgba(255,255,255, 0.75) -1.5em 0 0 0,
rgba(255,255,255, 0.75) -1.1em -1.1em 0 0, rgba(255,255,255, 0.75) 0 -1.5em 0 0,
rgba(255,255,255, 0.75) 1.1em -1.1em 0 0;}@-webkit-keyframes spinner {0% {-webkit-
transform: rotate(0deg);-moz-transform: rotate(0deg);-ms-transform: rotate(0deg);-
o-transform: rotate(0deg);transform: rotate(0deg);}100% {-webkit-transform:
rotate(360deg);-moz-transform: rotate(360deg);-ms-transform: rotate(360deg);-o-
transform: rotate(360deg);transform: rotate(360deg);}}@-moz-keyframes spinner {0%
{-webkit-transform: rotate(0deg);-moz-transform: rotate(0deg);-ms-transform:
rotate(0deg);-o-transform: rotate(0deg);transform: rotate(0deg);}100% {-webkit-
transform: rotate(360deg);-moz-transform: rotate(360deg);-ms-transform:
rotate(360deg);-o-transform: rotate(360deg);transform: rotate(360deg);}}@-o-
keyframes spinner {0% {-webkit-transform: rotate(0deg);-moz-transform:
rotate(0deg);-ms-transform: rotate(0deg);-o-transform: rotate(0deg);transform:
rotate(0deg);}100% {-webkit-transform: rotate(360deg);-moz-transform:
rotate(360deg);-ms-transform: rotate(360deg);-o-transform:
rotate(360deg);transform: rotate(360deg);}}@keyframes spinner {0% {-webkit-
transform: rotate(0deg);-moz-transform: rotate(0deg);-ms-transform: rotate(0deg);-
o-transform: rotate(0deg);transform: rotate(0deg);}100% {-webkit-transform:
rotate(360deg);-moz-transform: rotate(360deg);-ms-transform: rotate(360deg);-o-
transform: rotate(360deg);transform: rotate(360deg);}} </style>
<script>
window.drive_names = [Link]('${[Link]([Link](it =>
[Link]))}');
[Link] = [Link]('${[Link](model)}');
window.current_drive_order = ${current_drive_order};
[Link] = [Link]('${[Link](uiConfig)}');
window.player_config = [Link]('${[Link](player_config)}');
</script>
<script src="[Link]
script>
<link href="[Link]
{[Link]}/[Link]" rel="stylesheet" crossorigin="anonymous">
<link rel="stylesheet" href="[Link]
icons@1.10.5/font/[Link]">
<style>a{color:${uiConfig.css_a_tag_color};}p{color:$
{uiConfig.css_p_tag_color};}</style>
<script src="${app_js_file}"></script>
<script
src="[Link]
<script src="[Link]
script>
</head>
<body>
</body>
<script
src="[Link]
integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8"
crossorigin="anonymous"></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>${[Link]}</title>
<meta name="robots" content="noindex">
<link rel="icon" href="${[Link]}">
<script>
window.drive_names = [Link]('${[Link]([Link](it =>
[Link]))}');
[Link] = [Link]('${[Link](uiConfig)}');
</script>
<script src="[Link]
script>
<link href="[Link]
{[Link]}/[Link]" 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="'+[Link]+'" 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">
<div class="dropdown-menu" aria-labelledby="navbarDropdown"><a
class="dropdown-item" href="/">&gt; ${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>
${uiConfig.show_logout_button ?'<li class="nav-item"><a class="nav-
link" href="/logout">Logout</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" >('#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> ${[Link] ?
'<p>Redesigned with <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-
heart-fill" fill="red" xmlns="[Link] <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="[Link]
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}@${[Link]}/assets/[Link]"></
script>
<script
src="[Link]
integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8"
crossorigin="anonymous"></script>
</html>`
const login_html = `<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Sign in - ${[Link]}</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="${[Link]}">
<script type="text/javascript" src="//[Link]/jquery-
[Link]"></script>
<link rel="stylesheet"
href="[Link]
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z"
crossorigin="anonymous">
<link rel="stylesheet"
href="[Link]
[Link]" integrity="sha384-
wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
crossorigin="anonymous">
<style id="compiled-css" type="text/css">.login,.image{min-height:100vh}.bg-
image{background-image:url('[Link]
[Link]');background-size:cover;background-position:center center}#error-
message{display:none}</style>
<link rel="preconnect" href="[Link]
<link rel="preconnect" href="[Link] crossorigin>
<link href="[Link]
rel="stylesheet">
<style>
.logo {
font-family: 'Orbitron', sans-serif;
color: #007bff;
}
</style>
<script src="[Link]
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
$("#btn-login").click(function() {
const formData = new URLSearchParams();
[Link]('username', $("#email").val());
[Link]('password', $("#password").val());

fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: [Link]()
})
.then(res => [Link]())
.then(data => {
if (![Link]) {
[Link]("error-message").[Link] = "block";
[Link]("error-message").innerHTML = "Invalid
Credentials";
} else {
[Link]();
}
});
});
const queryparams = new URLSearchParams([Link]);
if ([Link]('error')) {
[Link]("error-message").[Link] = "block";
[Link]("error-message").innerHTML =
[Link]('error');
}
});
</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">
<img src="${uiConfig.login_image}" class="img-fluid" style="width:
150px; display: block; margin-left: auto; margin-right: auto; margin-bottom:
20px;">
<div id="error-message" class="alert alert-danger"></div>
<form 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>
${authConfig.enable_signup ? `<a href="/signup" class="btn btn-
outline-danger btn-block text-uppercase mb-2 rounded-pill shadow-sm">Signup</a>` :
''}
</form>
<hr class="solid">
${authConfig.enable_social_login ? `<div id="allsociallogins"
style="display:block;">
<a href="[Link]
client_id=`+authConfig.google_client_id_for_login+`&redirect_uri=`+[Link]
ect_domain+`/google_callback&response_type=code&scope=email
%20profile&response_mode=query" id="btn-google" class="btn btn-block btn-social
btn-google"><span class="fa fa-google"></span> Sign in with Google</a>
</div>` : ''}
</div>
</div>
</div>
</div>
<center>
<p>
&copy; <script>[Link](new Date().getFullYear())</script> $
{uiConfig.company_name}
</p>
</center>
</div>
</div>
</div>
</body>
</html>`

const signup_html = `<html>


<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Sign UP - ${[Link]}</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="${[Link]}">
<script type="text/javascript" src="//[Link]/jquery-
[Link]"></script>
<link rel="stylesheet"
href="[Link]
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z"
crossorigin="anonymous">
<link rel="stylesheet"
href="[Link]
[Link]" integrity="sha384-
wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
crossorigin="anonymous">
<style id="compiled-css" type="text/css">.login,.image{min-height:100vh}.bg-
image{background-image:url('[Link]
[Link]');background-size:cover;background-position:center center}#error-
message{display:none}</style>
<link rel="preconnect" href="[Link]
<link rel="preconnect" href="[Link] crossorigin>
<link href="[Link]
rel="stylesheet">
<style>
.logo {
font-family: 'Orbitron', sans-serif;
color: #007bff;
}
</style>
<script src="[Link]
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
$("#btn-login").click(function() {
const formData = new URLSearchParams();
[Link]('username', $("#email").val());
[Link]('password', $("#password").val());

fetch('/signup_api', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: [Link]()
})
.then(res => [Link]())
.then(data => {
if (![Link]) {
[Link]("error-message").[Link] = "block";
[Link]("error-message").innerHTML = "Failed to Create
Account, Error: " + [Link];
} else {
[Link]("error-message").[Link] = "block";
[Link]("error-message").innerHTML = "Account Created,
Please Login";
}
});
});
const queryparams = new URLSearchParams([Link]);
if ([Link]('error')) {
[Link]("error-message").[Link] = "block";
[Link]("error-message").innerHTML =
[Link]('error');
}
});
</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 text-center mb-3">${[Link]}</h3>
<div id="error-message" class="alert alert-danger"></div>
<form 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">SIGNUP</button>
<a href="/login" class="btn btn-outline-danger btn-block text-
uppercase mb-2 rounded-pill shadow-sm">LOGIN</a>
</form>
<hr class="solid">
${authConfig.enable_social_login ? `<div id="allsociallogins"
style="display:block;">
<a href="[Link]
client_id=`+authConfig.google_client_id_for_login+`&redirect_uri=`+[Link]
ect_domain+`/google_callback&response_type=code&scope=email
%20profile&response_mode=query" id="btn-google" class="btn btn-block btn-social
btn-google"><span class="fa fa-google"></span> Sign in with Google</a>
</div>` : ''}
</div>
</div>
</div>
</div>
<center>
<p>
&copy; <script>[Link](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(//[Link]/images/errors/[Link]) 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(//[Link]/images/branding/
googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only
screen and (min-resolution:192dpi){#logo{background:url(//[Link]/images/
branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-
moz-border-image:url(//[Link]/images/branding/googlelogo/2x/
googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-
ratio:2){#logo{background:url(//[Link]/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=//[Link]/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p id="status"></p>

<script>
[Link]("status").innerHTML =
"The requested URL <code>" + [Link] + "</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='[Link] 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='[Link] 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 [Link](/(!=)|['"=<>/\\:]/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/[Link]';
})();

// Token Generation for Service Accounts


const JSONWebToken = {
header: {
alg: 'RS256',
typ: 'JWT'
},
importKey: async function(pemKey) {
var pemDER = [Link].base64ToArrayBuffer([Link]('\n').map(s =>
[Link]()).filter(l => [Link] && ![Link]('---')).join(''));
return [Link]('pkcs8', pemDER, {
name: 'RSASSA-PKCS1-v1_5',
hash: 'SHA-256'
}, false, ['sign']);
},
createSignature: async function(text, key) {
const textBuffer = [Link](text);
return [Link]('RSASSA-PKCS1-v1_5', key, textBuffer)
},
generateGCPToken: async function(serviceAccount) {
const iat = parseInt([Link]() / 1000);
var payload = {
"iss": serviceAccount.client_email,
"scope": "[Link]
"aud": "[Link]
"exp": iat + 3600,
"iat": iat
};
const encPayload = btoa([Link](payload));
const encHeader = btoa([Link]([Link]));
var key = await [Link](serviceAccount.private_key);
var signed = await [Link](encHeader + "." + encPayload, key);
return encHeader + "." + encPayload + "." +
[Link].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 [Link];
},
stringToArrayBuffer: function(str) {
var len = [Link];
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = [Link](i);
}
return [Link];
},
arrayBufferToBase64: function(buffer) {
let binary = '';
let bytes = new Uint8Array(buffer);
let len = [Link];
for (let i = 0; i < len; i++) {
binary += [Link](bytes[i]);
}
return btoa(binary);
}
}
};

// web crypto functions


async function encryptString(string, iv) {
const key = await [Link](
"raw",
new TextEncoder().encode(crypto_base_key),
"AES-CBC",
false,
["encrypt"]
);
const encodedId = new TextEncoder().encode(string);
const encryptedData = await [Link]({
name: "AES-CBC",
iv: encrypt_iv
},
key,
encodedId
);
const encryptedString = btoa([Link](new Uint8Array(encryptedData), (byte) =>
[Link](byte)).join(""));
return encryptedString;
}

async function decryptString(encryptedString) {


const key = await [Link](
"raw",
new TextEncoder().encode(crypto_base_key),
"AES-CBC",
false,
["decrypt"]
);
const encryptedBytes = [Link](atob(encryptedString), (char) =>
[Link](0));
const decryptedData = await [Link]({
name: "AES-CBC",
iv: encrypt_iv
},
key,
encryptedBytes
);
const decryptedString = new TextDecoder().decode(decryptedData);
return decryptedString;
}

// Web Crypto Integrity Generate API


async function genIntegrity(data, key = hmac_base_key) {
const encoder = new TextEncoder();
const dataBuffer = [Link](data);
const hmacKey = await [Link](
'raw',
[Link](key), {
name: 'HMAC',
hash: 'SHA-256'
},
false,
['sign']
);
const hmacBuffer = await [Link]('HMAC', hmacKey, dataBuffer);

// Convert the HMAC buffer to hexadecimal string


const hmacArray = [Link](new Uint8Array(hmacBuffer));
const hmacHex = [Link](byte => [Link](16).padStart(2,
'0')).join('');

return hmacHex;
}

async function checkintegrity(text1, text2) {


return text1 === text2;
}

function login() {
return new Response(login_html, {
status: 401,
headers: {
'Content-Type': 'text/html; charset=utf-8'
}
});
}

// start handlerequest
async function handleRequest(request, event) {
const region = [Link]('cf-ipcountry');
const asn_servers = [Link];
const referer = [Link]("Referer");
var user_ip = [Link]("CF-Connecting-IP");
let url = new URL([Link]);
let path = [Link];
let hostname = [Link];
if (path == '/[Link]') {
const js = await fetch('[Link]
Index/-/raw/dev/src/[Link]', {
method: 'GET',
})
const data = await [Link]()
return new Response(data, {
status: 200,
headers: {
'Content-Type': 'application/javascript; charset=utf-8',
'Access-Control-Allow-Origin': '*', // Required for CORS support to work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
}
if (path == '/logout') {
let response = new Response("", {});
[Link]('Set-Cookie', `session=; HttpOnly; Secure;
SameSite=Lax;`);
[Link]("Refresh", "1; url=/?error=Logged Out");
return response;
}
if (path == '/findpath') {
const params = [Link];
const id = [Link]('id');
const view = [Link]('view') || 'false';
return [Link]([Link] + hostname + '/0:findpath?id=' + id +
'&view=' + view, 307);
}
if (authConfig.enable_login) {
const login_database = authConfig.login_database.toLowerCase();
//[Link]("Login Enabled")
if (path == '/[Link]' && !authConfig.disable_anonymous_download) {
[Link]("Anonymous Download")
} else if (path == '/google_callback') {
// Extract the authorization code from the query parameters
const code = [Link]('code')
if (!code) {
return new Response('Missing authorization code.', {
status: 400
});
}

// Use the authorization code to obtain access token and ID token


const response = await fetch('[Link] {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
code,
client_id: authConfig.google_client_id_for_login,
client_secret: authConfig.google_client_secret_for_login,
redirect_uri: authConfig.redirect_domain + '/google_callback',
grant_type: 'authorization_code',
}),
});

const data = await [Link]();


[Link]([Link](data));
if ([Link]) {
const idToken = data.id_token;
const decodedIdToken = await decodeJwtToken(idToken);
const username = [Link];
let kv_key
let user_found = false;
// Check if user email exist in the list
if (login_database == 'kv') {
kv_key = await [Link](username);
if (kv_key == null) {
user_found = false;
} else {
user_found = true;
}
} else if (login_database == 'mongodb') {
// to be implemented later
} else { // local database
for (i = 0; i < authConfig.users_list.length; i++) {
if (authConfig.users_list[i].username == username) {
user_found = true;
[Link]("User Found")
break;
}
}
}
if (!user_found) {
if (authConfig.enable_signup && login_database == 'kv') {
await [Link](username, [Link]().toString(36).substring(2, 15) +
[Link]().toString(36).substring(2, 15));
kv_key = await [Link](username);
if (kv_key == null) {
user_found = false;
} else {
user_found = true;
}
} else {
let response = new Response('Invalid User! Google Login', {});
[Link]('Set-Cookie', `session=; HttpOnly; Secure;
SameSite=Lax;`);
[Link]("Refresh", "1; url=/?error=Invalid User");
return response;
}
}
const current_time = [Link](); // this results in a timestamp of the
number of milliseconds since epoch.
const session_time = current_time + 86400000 * authConfig.login_days;
const encryptedSession = `${await encryptString(username)}|${await
encryptString(kv_key)}|${await encryptString(session_time.toString())}`;
if (authConfig.single_session) {
await [Link](username + '_session', encryptedSession);
}
if (authConfig.ip_changed_action && user_ip) {
await [Link](username + '_ip', user_ip);
}
// reload page with cookie
let response = new Response("", {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Set-Cookie': `session=${encryptedSession}; path=/; HttpOnly; Secure;
SameSite=Lax`,
'Access-Control-Allow-Origin': '*', // Required for CORS support to
work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
'Refresh': '0; url=/',
}
});
return response;
} else {
let response = new Response('Invalid Token!', {});
[Link]('Set-Cookie', `session=; HttpOnly; Secure;
SameSite=Lax;`);
[Link]("Refresh", "1; url=/?error=Invalid Token");
return response;
}
} else if (authConfig.enable_login && [Link] === 'POST' && path ===
'/login') {
[Link]("POST Request for Login")
const formdata = await [Link]();
const username = [Link]('username');
const password = [Link]('password');
if (login_database == 'kv') {
const kv_key = await [Link](username);
if (kv_key == null) {
var user_found = false;
} else {
if (kv_key == password) {
var user_found = true;
} else {
var user_found = false;
}
}
} else if (login_database == 'mongodb') {
// to be implemented later
} else { // local database
for (i = 0; i < authConfig.users_list.length; i++) {
if (authConfig.users_list[i].username == username &&
authConfig.users_list[i].password == password) {
var user_found = true;
break;
}
}
}

if (!user_found) {
const jsonResponse = {
ok: false,
}
let response = new Response([Link](jsonResponse), {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Access-Control-Allow-Origin': '*', // Required for CORS support to
work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
return response;
}
if (user_found) {
const current_time = [Link](); // this results in a timestamp of the
number of milliseconds since epoch.
const session_time = current_time + 86400000 * authConfig.login_days;
const encryptedSession = `${await encryptString(username)}|${await
encryptString(password)}|${await encryptString(session_time.toString())}`;
if (authConfig.single_session) {
await [Link](username + '_session', encryptedSession);
}
if (authConfig.ip_changed_action && user_ip) {
await [Link](username + '_ip', user_ip);
}
const jsonResponse = {
ok: true,
}
let response = new Response([Link](jsonResponse), {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Set-Cookie': `session=${encryptedSession}; path=/; HttpOnly; Secure;
SameSite=Lax`,
'Access-Control-Allow-Origin': '*', // Required for CORS support to
work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
return response;
} else {
const jsonResponse = {
ok: false,
}
let response = new Response([Link](jsonResponse), {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Access-Control-Allow-Origin': '*', // Required for CORS support to
work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
return response;
}
} else if (path == '/signup' && authConfig.enable_signup) {
return new Response(signup_html, {
status: 200,
headers: {
'Content-Type': 'text/html; charset=utf-8',
'Access-Control-Allow-Origin': '*', // Required for CORS support to work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
} else if (authConfig.enable_signup && [Link] === 'POST' && path ===
'/signup_api') {
if (login_database == 'kv') {
const formdata = await [Link]();
const username = [Link]('username');
const password = [Link]('password');
if (username == null || password == null) {
const jsonResponse = {
ok: true,
error: "Username or Password is null"
}
let response = new Response([Link](jsonResponse), {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Set-Cookie': `session=; path=/; HttpOnly; Secure; SameSite=Lax`,
'Access-Control-Allow-Origin': '*', // Required for CORS support to
work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
return response;
} else if ([Link] > 8 && [Link] > 8) {
const checkKey = await [Link](username);
let jsonResponse;
if (checkKey != null) {
jsonResponse = {
ok: false,
error: "User Already Exists"
}
} else {
await [Link](username, password);
jsonResponse = {
ok: true,
error: "User Created"
}
}
let response = new Response([Link](jsonResponse), {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Set-Cookie': `session=; path=/; HttpOnly; Secure; SameSite=Lax`,
'Access-Control-Allow-Origin': '*', // Required for CORS support to
work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
return response;
} else {
const jsonResponse = {
ok: false,
error: "Username or Password length is less than 8 characters"
}
let response = new Response([Link](jsonResponse), {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Set-Cookie': `session=; path=/; HttpOnly; Secure; SameSite=Lax`,
'Access-Control-Allow-Origin': '*', // Required for CORS support to
work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
return response;
}
} else if (login_database == 'mongodb') {
// to be implemented later
} else {
return new Response("Signup is not supported with local database", {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Access-Control-Allow-Origin': '*', // Required for CORS support to
work
'Access-Control-Allow-Credentials': true, // Required for cookies,
authorization headers with HTTPS
}
});
}
} else if ([Link] === 'GET') {
//[Link]("GET Request")
const cookie = [Link]('cookie');
if (cookie && [Link]('session=')) {
const session = [Link]('session=').pop().split(';').shift().trim();
if (session == 'null' || session == '' || session == null) {
return login()
}
const username = await decryptString([Link]('|')[0]);
let kv_session
if (authConfig.single_session) {
kv_session = await [Link](username + '_session');
if (kv_session != session) {
let response = new Response('User Logged in Someplace Else!', {
headers: {
'Set-Cookie': `session=; HttpOnly; Secure; SameSite=Lax;`,
}
});
[Link]("Refresh", "1; url=/?error=User Logged in
Someplace Else!");
return response;
}
}
if (authConfig.ip_changed_action && user_ip) {
const kv_ip = await [Link](username + '_ip');
if (kv_ip != user_ip) {
let response = new Response('IP Changed! Login Required', {
headers: {
'Set-Cookie': `session=; HttpOnly; Secure; SameSite=Lax;`,
}
});
[Link]("Refresh", "1; url=/?error=IP Changed! Login
Required");
return response;
}
}
const session_time = await decryptString([Link]('|')[2]);
[Link]("User: " + username + " | Session Time: " + session_time)
const current_time = [Link](); // this results in a timestamp of the
number of milliseconds since epoch.
if (Number(session_time) < current_time) {
let response = new Response('Session Expired!', {
headers: {
'Set-Cookie': `session=; HttpOnly; Secure; SameSite=Lax;`,
}
});
[Link]("Refresh", "1; url=/?error=Session Expired!");
return response;
}
if (login_database == 'kv') {
const kv_key = await [Link](username);
if (kv_key == null) {
var user_found = false;
} else {
if (kv_key) {
var user_found = true;
} else {
var user_found = false;
}
}
} else if (login_database == 'mongodb') {
// to be implemented later
} else { // local database
for (i = 0; i < authConfig.users_list.length; i++) {
if (authConfig.users_list[i].username == username) {
var user_found = true;
break;
}
}
}
if (user_found) {
[Link]("User Found")
} else {
let response = new Response('Invalid User! Something Wrong', {});
[Link]('Set-Cookie', `session=; HttpOnly; Secure;
SameSite=Lax;`);
[Link]("Refresh", "1; url=/?error=Invalid User");
return response;
}
} else {
return login()
}
}
}

if ([Link] === 0) {
for (let i = 0; i < [Link]; i++) {
const gd = new googleDrive(authConfig, i);
await [Link]();
[Link](gd)
}
let tasks = [];
[Link](gd => {
[Link]([Link]());
});
for (let task of tasks) {
await task;
}
}

let gd;

function redirectToIndexPage() {
return new Response('', {
status: 307,
headers: {
'Location': `${[Link]}/0:/`
}
});
}

if (region && blocked_region.includes([Link]())) {


return new Response(asn_blocked, {
status: 403,
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
} else if (asn_servers && 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",
},
})
} else if (path == '/fallback') {
return new Response(html(0, {
is_search_page: false,
root_type: 1
}), {
status: 200,
headers: {
'Content-Type': 'text/html; charset=utf-8'
}
});
} else if (path == '/[Link]') {
[Link]("[Link] started");
const file = await decryptString([Link]('file'));
[Link](file)
const expiry = await decryptString([Link]('expiry'));
let integrity_result = false;
if (authConfig['enable_ip_lock'] && user_ip) {
const integrity = await genIntegrity(`${file}|${expiry}|${user_ip}`);
const mac = [Link]('mac');
integrity_result = await checkintegrity(mac, integrity);
} else {
const integrity = await genIntegrity(`${file}|${expiry}`);
const mac = [Link]('mac');
integrity_result = await checkintegrity(mac, integrity);
}
if (integrity_result) {
let range = [Link]('Range');
const inline = 'true' === [Link]('inline');
[Link](file, range)
return download(file, range, inline);
} else {
return new Response('Invalid Request!', {
status: 401,
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
});
} else if ([Link](hostname)) {
[Link]("Refer Detected");
} else {
return new Response(directlink, {
headers: {
'content-type': 'text/html;charset=UTF-8'
},
status: 401
});
}
}
const command_reg = /^\/(?<num>\d+):(?<command>[a-zA-Z0-9]+)(\/.*)?$/g;
const match = command_reg.exec(path);
if (match) {
const num = [Link];
const order = Number(num);
if (order >= 0 && order < [Link]) {
gd = gds[order];
} else {
return redirectToIndexPage()
}
//for (const r = [Link](request); r;) return r;
const command = [Link];
if (command === 'search') {
if ([Link] === 'POST') {
return handleSearch(request, gd, user_ip);
} else {
const params = [Link];
return new Response(html([Link], {
q: [Link]("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' && [Link] === 'POST') {
return handleId2Path(request, gd)
} else if (command === 'fallback' && [Link] === 'POST') {
const formdata = await [Link]();
const id = await decryptString([Link]);
const type = [Link];
if (type && type == 'folder') {
const page_token = formdata.page_token || null;
const page_index = formdata.page_index || 0;
const details = await gd._list_gdrive_files(id, page_token, page_index);
for (const file of [Link]) {
if ([Link] != 'application/[Link]') {
[Link] = await generateLink([Link], user_ip);
}
[Link] = await encryptString([Link]);
[Link] = await encryptString([Link]);
}
const encryptedDetails = details;
return new Response([Link](encryptedDetails), {});
}
const details = await [Link](id)
[Link] = await generateLink([Link], user_ip);
[Link] = [Link];
[Link][0] = null;
return new Response([Link](details), {});
} else if (command === 'findpath' && [Link] === 'GET') {
return findId2Path(gd, url)
}
}
const common_reg = /^\/\d+:\/.*$/g;
try {
if (![Link](common_reg)) {
return redirectToIndexPage();
}
let split = [Link]("/");
let order = Number(split[1].slice(0, -1));
if (order >= 0 && order < [Link]) {
gd = gds[order];
} else {
return redirectToIndexPage()
}
} catch (e) {
return redirectToIndexPage()
}

//path = [Link](gd.url_path_prefix, '') || '/';


if ([Link] == 'POST') {
return apiRequest(request, gd, user_ip);
}

let action = [Link]('a');


if ([Link](-1) == '/' || action != null) {
return new Response(html([Link], {
root_type: gd.root_type
}), {
status: 200,
headers: {
'Content-Type': 'text/html; charset=utf-8'
}
});
} else {
/*if ([Link]('/').pop().toLowerCase() == ".password") {
return new Response("", {
status: 404
});
}*/
[Link](path)
const file = await gd.get_single_file([Link](3));
[Link](file)
let range = [Link]('Range');
const inline = 'true' === [Link]('inline');
if ([Link].protect_file_link && enable_login) return login();
return download([Link], range, inline);

}
// end handlerequest

function enQuery(data) {
const ret = [];
for (let d in data) {
[Link](encodeURIComponent(d) + '=' + encodeURIComponent(data[d]));
}
return [Link]('&');
}

async function getAccessToken() {


if ([Link] == undefined || [Link] < [Link]()) {
const obj = await fetchAccessToken();
if (obj.access_token != undefined) {
[Link] = obj.access_token;
[Link] = [Link]() + 3500 * 1000;
}
}
return [Link];
}

async function fetchAccessToken() {


[Link]("fetchAccessToken");
const url = "[Link]
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
var post_data;
if (authConfig.service_account && typeof authConfig.service_account_json !=
"undefined") {
const jwttoken = await
[Link](authConfig.service_account_json);
post_data = {
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
assertion: jwttoken,
};
} else {
post_data = {
client_id: authConfig.client_id,
client_secret: authConfig.client_secret,
refresh_token: authConfig.refresh_token,
grant_type: "refresh_token",
};
}

let requestOption = {
'method': 'POST',
'headers': headers,
'body': enQuery(post_data)
};

let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if ([Link]) {
break;
}
await sleep(800 * (i + 1));
}
return await [Link]();
}

async function sleep(ms) {


return new Promise(function(resolve, reject) {
let i = 0;
setTimeout(function() {
[Link]('sleep' + ms);
i++;
if (i >= 2) reject(new Error('i>=2'));
else resolve(i);
}, ms);
})
}
async function generateLink(file_id, user_ip, iv) {
const encrypted_id = await encryptString(file_id, iv);
const expiry = [Link]() + 1000 * 60 * 60 * 24 * authConfig.file_link_expiry;
const encrypted_expiry = await encryptString([Link](), iv);
let url
if (authConfig['enable_ip_lock'] && user_ip) {
const encrypted_ip = await encryptString(user_ip, iv);
const integrity = await genIntegrity(`${file_id}|${expiry}|${user_ip}`);
url = `/[Link]?file=${encodeURIComponent(encrypted_id)}&expiry=$
{encodeURIComponent(encrypted_expiry)}&ip=${encodeURIComponent(encrypted_ip)}&mac=$
{encodeURIComponent(integrity)}`;
} else {
const integrity = await genIntegrity(`${file_id}|${expiry}`);
url = `/[Link]?file=${encodeURIComponent(encrypted_id)}&expiry=$
{encodeURIComponent(encrypted_expiry)}&mac=${encodeURIComponent(integrity)}`;
}
return url;
}

async function apiRequest(request, gd, user_ip) {


let url = new URL([Link]);
let path = [Link];
path = [Link](gd.url_path_prefix, '') || '/';
[Link]("handling apirequest: " + path);
let option = {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*'
}
}

if ([Link](-1) == '/') {
let requestData = await [Link]();
let list_result = await gd.request_list_of_files(
path,
requestData.page_token || null,
Number(requestData.page_index) || 0
);

if (authConfig['enable_password_file_verify']) {
let password = await [Link](path);
// [Link]("dir password", password);
if (password && [Link]("\n", "") !== [Link]('password')) {
let html =
`Y29kZWlzcHJvdGVjdGVk=0Xfi4icvJnclBCZy92dzNXYwJCI6ISZnF2czVWbiwSMwQDI6ISZk92YisHI6I
icvJnclJyeYmFzZTY0aXNleGNsdWRlZA==`;
return new Response(html, option);
}
}

list_result.[Link] = await [Link](list_result.[Link](async


(file) => {
const {
driveId,
id,
mimeType,
...fileWithoutId
} = file;

const encryptedId = await encryptString(id);


const encryptedDriveId = await encryptString(driveId);

let link = null;


if (mimeType !== 'application/[Link]') {
link = await generateLink(id, user_ip);
}

return {
...fileWithoutId,
id: encryptedId,
driveId: encryptedDriveId,
mimeType: mimeType,
link: link,
};
}));

const encryptedFiles = list_result;


const data = [Link](encryptedFiles)
return new Response(data, {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json;charset=UTF-8'

}
});
} else {
let file_json = await gd.get_single_file(path);
const {
driveId,
id,
...fileWithoutId
} = file_json;

const encryptedId = await encryptString(id);


const encryptedDriveId = await encryptString(driveId);
const link = await generateLink(id, user_ip);
const encryptedFile = {
...fileWithoutId,
id: encryptedId,
driveId: encryptedDriveId,
link: link,
};

const encryptedFiles = encryptedFile;

const data = [Link](encryptedFiles)


return new Response(data, {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json;charset=UTF-8'

}
});
}
}

// deal with search


async function handleSearch(request, gd, user_ip = '') {
const option = {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*'
}
};
const requestData = await [Link]();
const q = requestData.q || '';
const pageToken = requestData.page_token || null;
const pageIndex = Number(requestData.page_index) || 0;
if (q == '') return new Response([Link]({
"nextPageToken": null,
"curPageIndex": 0,
"data": {
"files": []
}
}), option);
const searchResult = await [Link](q, pageToken, pageIndex);
[Link] = await [Link]([Link](async
(file) => {
const {
driveId,
id,
...fileWithoutId
} = file;

const encryptedId = await encryptString(id);


const encryptedDriveId = await encryptString(driveId);
const link = await generateLink(id, user_ip);
return {
...fileWithoutId,
id: encryptedId,
driveId: encryptedDriveId,
link: link,
};
}));
return new Response([Link](searchResult), option);
}

async function handleId2Path(request, gd) {


let url = new URL([Link]);
const option = {
status: 200,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": authConfig.cors_domain,
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS",
}
};
try {
const data = await [Link]();
const id = await decryptString([Link]);
let [path, prefix] = await [Link](id);
let jsonpath = '{"path": "/' + prefix + ':' + path + '"}'
[Link](jsonpath)
return new Response(jsonpath || '', option);
} catch (error) {
[Link](error)
return new Response('{"message":"Request Failed or Path Not Found","error":"' +
error + '"}', {
status: 500,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": authConfig.cors_domain,
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS",
}
});
}
}

async function findId2Path(gd, url) {


try {
let [path, prefix] = await [Link]([Link]('id'));
[Link](path, prefix)
if (!path) {
return new Response("Invalid URL");
} else if ([Link]('view') && [Link]('view')
== 'true') {
//return new Response("[Link] + [Link] + "/" + prefix +
":" + path + "?a=view" || '');
return [Link]("[Link] + [Link] + "/" + prefix
+ ":" + path + "?a=view" || '', 302);
} else {
//return new Response("[Link] + [Link] + "/" + prefix +
":" + path + "?a=view" || '');
return [Link]("[Link] + [Link] + "/" + prefix
+ ":" + path || '', 302);
}
} catch (error) {
const encrypted_id = await encryptString([Link]('id'),
encrypt_iv)
return [Link]("[Link] + [Link] + "/fallback?id=" +
encrypted_id || '', 302);
}
}

/*async function findItemById(gd, id) {


[Link](id)
const is_user_drive = this.root_type === DriveFixedTerms.gd_root_type.user_drive;
let url = `[Link]
{DriveFixedTerms.default_file_fields}${is_user_drive ? '' :
'&supportsAllDrives=true'}`;
let requestOption = await [Link]();
let res = await fetch(url, requestOption);
return await [Link]();
}*/

// start of class googleDrive


class googleDrive {
constructor(authConfig, order) {
[Link] = order;
[Link] = [Link][order];
[Link].protect_file_link = [Link].protect_file_link || false;
this.url_path_prefix = `/${order}:`;
[Link] = authConfig;
[Link] = [];
[Link] = [];
[Link] = [];
[Link]["/"] = [Link]['id'];
}
async init() {
await getAccessToken();
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 = [Link]['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;
}
}

async get_single_file(path) {
if (typeof [Link][path] == 'undefined') {
[Link][path] = await this.get_single_file_api(path);
}
return [Link][path];
}

async get_single_file_api(path) {
let arr = [Link]('/');
let name = [Link]();
name = decodeURIComponent(name).replace(/\'/g, "\\'");
let dir = [Link]('/') + '/';
[Link]("try " + name, dir);
let parent = await [Link](dir);
[Link]("try " + parent)
let url = '[Link]
let params = {
'includeItemsFromAllDrives': true,
'supportsAllDrives': true
};
params.q = `'${parent}' in parents and name = '${name}' and trashed = false and
mimeType != 'application/[Link]'`;
[Link] = "files(id, name, mimeType, size ,createdTime, modifiedTime,
iconLink, thumbnailLink, driveId, fileExtension)";
url += '?' + enQuery(params);
let requestOption = await [Link]();
let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if ([Link]) {
break;
}
await sleep(800 * (i + 1));
}
let obj = await [Link]();
// [Link](obj);
return [Link][0];
}

async request_list_of_files(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 [Link](path);


let result = await this._list_gdrive_files(id, page_token, page_index);
let data = [Link];
if ([Link] && [Link]) {
if (![Link](this.path_children_cache[path])) {
this.path_children_cache[path] = []
}
this.path_children_cache[path][Number([Link])] = {
nextPageToken: [Link],
data: data
};
}

return result
}

// listing files usign google drive api


async _list_gdrive_files(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/[Link]' and mimeType !=
'application/[Link]' and mimeType != 'application/[Link]-
[Link]' and mimeType != 'application/[Link]' and mimeType !
= 'application/[Link]'`;
[Link] = 'folder, name, modifiedTime desc';
[Link] = "nextPageToken, files(id, name, mimeType, size, modifiedTime,
driveId, kind, fileExtension)";
[Link] = [Link].files_list_page_size;

if (page_token) {
[Link] = page_token;
}
let url = '[Link]
url += '?' + enQuery(params);
let requestOption = await [Link]();
let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if ([Link]) {
break;
}
await sleep(800 * (i + 1));
}
obj = await [Link]();

return {
nextPageToken: [Link] || null,
curPageIndex: page_index,
data: obj
};
}

async password(path) {
if ([Link][path] !== undefined) {
return [Link][path];
}

let file = await this.get_single_file(path + '.password');


if (file == undefined) {
[Link][path] = null;
} else {
let url = `[Link]
let requestOption = await [Link]();
let response = await this.fetch200(url, requestOption);
[Link][path] = await [Link]();
}

return [Link][path];
}

async searchFilesinDrive(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 = [Link](origin_keyword);
if (!keyword) {
return empty_result;
}
let words = [Link](/\s+/);
let name_search_str = `name contains '${[Link]("' AND name contains '")}'`;
let params = {};
if (is_user_drive) {
if (authConfig.search_all_drives) {
[Link] = 'allDrives';
[Link] = true;
[Link] = true;
} else {
[Link] = 'user';
}
}
if (is_share_drive) {
if (authConfig.search_all_drives) {
[Link] = 'allDrives';
} else {
[Link] = 'drive';
[Link] = [Link];
}
[Link] = true;
[Link] = true;
}
if (page_token) {
[Link] = page_token;
}
params.q = `trashed = false AND mimeType != 'application/[Link]-
[Link]' and mimeType != 'application/[Link]' and
mimeType != 'application/[Link]' and mimeType !=
'application/[Link]' and mimeType != 'application/[Link]-
[Link]' AND name !='.password' AND (${name_search_str})`;
[Link] = "nextPageToken, files(id, driveId, name, mimeType, size ,
modifiedTime)";
[Link] = [Link].search_result_list_page_size;
[Link] = 'folder, name, modifiedTime desc';

let url = '[Link]


url += '?' + enQuery(params);
let requestOption = await [Link]();
let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if ([Link]) {
break;
}
await sleep(800 * (i + 1));
}
let res_obj = await [Link]();

return {
nextPageToken: res_obj.nextPageToken || null,
curPageIndex: page_index,
data: res_obj
};
}

async findParentFilesRecursion(child_id, drive_index_no, contain_myself = true) {


const gd = this;
const gd_root_id = [Link];
const user_drive_real_root_id = authConfig.user_drive_real_root_id;
const is_user_drive = gd.root_type === DriveFixedTerms.gd_root_type.user_drive;
const target_top_id = is_user_drive ? user_drive_real_root_id : gd_root_id;
const fields = DriveFixedTerms.default_file_fields;
const parent_files = [];
let meet_top = false;
async function addItsFirstParent(file_obj) {
if (!file_obj) return;
if (!file_obj.parents) return null;
if (file_obj.[Link] < 1) return;
let p_ids = file_obj.parents;
if (p_ids && p_ids.length > 0) {
const first_p_id = p_ids[0];
[Link](first_p_id)
if (drive_list.includes(first_p_id)) {
meet_top = true;
drive_index_no = drive_list.indexOf(first_p_id);
return drive_index_no;
}
const p_file_obj = await [Link](first_p_id);
if (p_file_obj && p_file_obj.id) {
parent_files.push(p_file_obj);
await addItsFirstParent(p_file_obj);
}
}
return drive_index_no;
}

const child_obj = await [Link](child_id);


if (contain_myself) {
parent_files.push(child_obj);
}
const drive_id = await addItsFirstParent(child_obj);
[Link]("parents -- " + [Link](parent_files))
return meet_top ? [parent_files, drive_index_no] : null;
}

async findPathById(child_id) {
let p_files
let drive_index_no = 0;
try {
[p_files, drive_index_no] = await [Link](child_id);
} catch (error) {
return null;
}

if (!p_files || p_files.length < 1) return '';

let cache = [];


// Cache the path and id of each level found
p_files.forEach((value, idx) => {
const is_folder = idx === 0 ? (p_files[idx].mimeType ===
DriveFixedTerms.folder_mime_type) : true;
let path = '/' + p_files.slice(idx).map(it =>
encodeURIComponent([Link])).reverse().join('/');
if (is_folder) path += '/';
[Link]({
id: p_files[idx].id,
path: path
})
});
return [cache[0].path, drive_index_no];
}

async findItemById(id) {
const is_user_drive = this.root_type ===
DriveFixedTerms.gd_root_type.user_drive;
let url = `[Link]
{DriveFixedTerms.default_file_fields}${is_user_drive ? '' :
'&supportsAllDrives=true'}`;
let requestOption = await [Link]();
let res = await fetch(url, requestOption);
return await [Link]()
}

async findPathId(path) {
let c_path = '/';
let c_id = [Link][c_path];

let arr = [Link]('/').split('/');


for (let name of arr) {
c_path += name + '/';

if (typeof [Link][c_path] == 'undefined') {


let id = await this._findDirId(c_id, name);
[Link][c_path] = id;
}

c_id = [Link][c_path];
if (c_id == undefined || c_id == null) {
break;
}
}
[Link]('findPathId: ', path, c_id)
return [Link][path];
}

async _findDirId(parent, name) {


name = decodeURIComponent(name).replace(/\'/g, "\\'");
if (parent == undefined) {
return null;
}

let url = '[Link]


let params = {
'includeItemsFromAllDrives': true,
'supportsAllDrives': true
};
params.q = `'${parent}' in parents and mimeType = 'application/[Link]-
[Link]' and name = '${name}' and trashed = false`;
[Link] = "nextPageToken, files(id, name, mimeType)";
url += '?' + enQuery(params);
let requestOption = await [Link]();
let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if ([Link]) {
break;
}
await sleep(800 * (i + 1));
}
let obj = await [Link]();
if ([Link][0] == undefined) {
return null;
}
return [Link][0].id;
}

/*async getAccessToken() {
[Link]("accessToken");
if ([Link] == undefined || [Link] <
[Link]()) {
const obj = await fetchAccessToken();
if (obj.access_token != undefined) {
[Link] = obj.access_token;
[Link] = [Link]() + 3500 * 1000;
}
}
return [Link];
}*/

/*async fetchAccessToken() {
[Link]("fetchAccessToken");
const url = "[Link]
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
var post_data;
if ([Link].service_account && typeof
[Link].service_account_json != "undefined") {
const jwttoken = await
[Link]([Link].service_account_json);
post_data = {
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
assertion: jwttoken,
};
} else {
post_data = {
client_id: [Link].client_id,
client_secret: [Link].client_secret,
refresh_token: [Link].refresh_token,
grant_type: "refresh_token",
};
}

let requestOption = {
'method': 'POST',
'headers': headers,
'body': enQuery(post_data)
};
let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if ([Link]) {
break;
}
await sleep(800 * (i + 1));
}
return await [Link]();
}*/

async fetch200(url, requestOption) {


let response;
for (let i = 0; i < 3; i++) {
response = await fetch(url, requestOption);
if ([Link]) {
break;
}
await sleep(800 * (i + 1));
}
return response;
}

async requestOptions(headers = {}, method = 'GET') {


const Token = await getAccessToken();
headers['authorization'] = 'Bearer ' + Token;
return {
'method': method,
'headers': headers
};
}

/*sleep(ms) {
return new Promise(function(resolve, reject) {
let i = 0;
setTimeout(function() {
[Link]('sleep' + ms);
i++;
if (i >= 2) reject(new Error('i>=2'));
else resolve(i);
}, ms);
})
}*/
}
// end of class googleDrive
const drive = new googleDrive(authConfig, 0);
async function download(id, range = '', inline) {
let url = `[Link]
const requestOption = await [Link]();
[Link]['Range'] = range;
let file = await [Link](id);
if (![Link]) {
return new Response(`{"error":"Unable to Find this File, Try Again."}`, {
status: 500,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": authConfig.cors_domain,
"Cache-Control": "max-age=3600",
}
});
}
let res;
for (let i = 0; i < 3; i++) {
res = await fetch(url, requestOption);
if ([Link]) {
break;
}
sleep(800 * (i + 1));
[Link](res);
}
const second_domain_for_dl = `${uiConfig.second_domain_for_dl}`
if (second_domain_for_dl == 'true') {
const res = await
fetch(`${uiConfig.jsdelivr_cdn_src}@${[Link]}/assets/disable_download.htm
l`);
return new Response(await [Link](), {
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
} else if ([Link]) {
const {
headers
} = res = new Response([Link], res)
[Link]("Content-Disposition", `attachment; filename="${[Link]}"`);
[Link]("Content-Length", [Link]);
authConfig.enable_cors_file_down && [Link]('Access-Control-Allow-
Origin', '*');
inline === true && [Link]('Content-Disposition', 'inline');
return res;
} else if ([Link] == 404) {
return new Response(not_found, {
status: 404,
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
} else if ([Link] == 403) {
const details = await [Link]()
return new Response(details, {
status: 403,
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
} else {
const details = await [Link]()
/*const res = await
fetch(`${uiConfig.jsdelivr_cdn_src}@${[Link]}/assets/download_error.html`
);
return new Response(await [Link](), {
headers: {
"content-type": "text/html;charset=UTF-8",
},
})*/
return new Response(details, {})
}
}

[Link] = function(char) {
if (char) {
return [Link](new RegExp('^\\' + char + '+|\\' + char + '+$', 'g'), '');
}
return [Link](/^\s+|\s+$/g, '');
};

function decodeJwtToken(token) {
const base64Url = [Link]('.')[1];
const base64 = [Link](/-/g, '+').replace(/_/g, '/');
const jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + [Link](0).toString(16)).slice(-2);
}).join(''));

return [Link](jsonPayload);
}

addEventListener('fetch', event => {


[Link](handleRequest([Link], event).catch(
(err) => new Response("Report this page when asked at the time of support...
==> " + [Link], { status: 500 })
)
);
});

You might also like