-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
383 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Not a mirror bot | ||
###### Now that being out of the way, lets start: | ||
--- | ||
## What is it ? | ||
|
||
This is a clone bot, which clones google drive urls, to your own Teamdrive or Personal Google Drive. | ||
|
||
## How it works ? | ||
|
||
The bot requires your google drive authentication to clone the files to which you have access. It also clones public google drive links, moreover you can add your service accounts, to increase the limit of cloning public urls | ||
|
||
## Features: | ||
|
||
### Clone google drive links | ||
- Continue reading to see which links can the bot clone | ||
|
||
### Service Accounts | ||
- Features a `quickstart` command for the newbies to quickly generate 100 service accounts. | ||
- Featues commands like `saemails` , `downloadsazip`, `createsas` etc. which enables users to downlad that emails.txt file (those who know, know), download zip file of service accounts and even create service accounts for a given project id. | ||
|
||
### Database | ||
- Has a mongodb database, which stores service accounts and their emails, so that the bot doesn't ping the google api everytime it uses them. [because for a given project, google api only allows the service account to be downloaded 10 times.] | ||
- Also used to store the default location for cloning (changable via `set_folder` command.) | ||
|
||
|
||
|
||
## Which links can it clone ? | ||
|
||
| From | To | Can Clone ? | Using S.A. | Limit | Bot Command | | ||
| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | | ||
| Public Url (**everyone has access**) | Public/Private folder (**you have uploading access** but S.A. do not) | yes |no| 750GB |`prefix privclone`| | ||
| Public Url (**everyone has access**) | Public/Private folder (**S.A. have uploading access**) | yes |yes| (750 x no. of S.A.) GB |`prefix pubclone`| | ||
| Public Url (**everyone has access**) | Public/Private folder (neither have uploading access) | no |-| - |-| | ||
| Private Url** (**you have access**) | Public/Private folder (**you have uploading access** but S.A. do not) | yes |no| 750GB |`prefix privclone`| | ||
| Private Url (**S.A. have access**) | Public/Private folder (**S.A. have uploading access**) | yes |yes| (750 x no. of S.A.) GB |`prefix pubclone`| | ||
| Private Url (you do not have access) | Public/Private folder | no |-| - |-| | ||
--- | ||
|
||
> `S.A.` stands for "Service Accounts" | ||
> | ||
> All S.A. have access of public links (everyone can access) | ||
> | ||
> ** For example you are a part of a teamdrive (but that teamdrive does not have your S.A.) and you need to clone a folder from it to your personal drive or teamdrive. | ||
> | ||
> `no.` stands for "number of" | ||
> | ||
> The Bot can clone to Teamdrive (Shared drive) if and only if you or your S.A. have uploading access. | ||
# How to deploy ? | ||
|
||
video coming soon | ||
<p><a href="https://www.google.com"> <img src="https://img.shields.io/badge/See%20Video-black?style=for-the-badge&logo=YouTube" width="160""/></a></p> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
function getAllUrlParams(url) { | ||
|
||
// get query string from url (optional) or window | ||
var queryString = url ? url.split('?')[1] : window.location.search.slice(1); | ||
|
||
// we'll store the parameters here | ||
var obj = {}; | ||
|
||
// if query string exists | ||
if (queryString) { | ||
|
||
// stuff after # is not part of query string, so get rid of it | ||
queryString = queryString.split('#')[0]; | ||
|
||
// split our query string into its component parts | ||
var arr = queryString.split('&'); | ||
|
||
for (var i = 0; i < arr.length; i++) { | ||
// separate the keys and the values | ||
var a = arr[i].split('='); | ||
|
||
// set parameter name and value (use 'true' if empty) | ||
var paramName = a[0]; | ||
var paramValue = typeof (a[1]) === 'undefined' ? true : a[1]; | ||
|
||
// (optional) keep case consistent | ||
paramName = paramName.toLowerCase(); | ||
if (typeof paramValue === 'string') paramValue = paramValue.toLowerCase(); | ||
|
||
// if the paramName ends with square brackets, e.g. colors[] or colors[2] | ||
if (paramName.match(/\[(\d+)?\]$/)) { | ||
|
||
// create key if it doesn't exist | ||
var key = paramName.replace(/\[(\d+)?\]/, ''); | ||
if (!obj[key]) obj[key] = []; | ||
|
||
// if it's an indexed array e.g. colors[2] | ||
if (paramName.match(/\[\d+\]$/)) { | ||
// get the index value and add the entry at the appropriate position | ||
var index = /\[(\d+)\]/.exec(paramName)[1]; | ||
obj[key][index] = paramValue; | ||
} else { | ||
// otherwise add the value to the end of the array | ||
obj[key].push(paramValue); | ||
} | ||
} else { | ||
// we're dealing with a string | ||
if (!obj[paramName]) { | ||
// if it doesn't exist, create property | ||
obj[paramName] = paramValue; | ||
} else if (obj[paramName] && typeof obj[paramName] === 'string'){ | ||
// if property does exist and it's a string, convert it to an array | ||
obj[paramName] = [obj[paramName]]; | ||
obj[paramName].push(paramValue); | ||
} else { | ||
// otherwise add the property | ||
obj[paramName].push(paramValue); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return obj; | ||
} | ||
|
||
function allpermutations(inputArr) { | ||
var results = []; | ||
|
||
function permute(arr, memo) { | ||
var cur, memo = memo || []; | ||
|
||
for (var i = 0; i < arr.length; i++) { | ||
cur = arr.splice(i, 1); | ||
if (arr.length === 0) { | ||
results.push(memo.concat(cur)); | ||
} | ||
permute(arr.slice(), memo.concat(cur)); | ||
arr.splice(i, 0, cur[0]); | ||
} | ||
|
||
return results; | ||
} | ||
|
||
return permute(inputArr); | ||
} | ||
|
||
function get_auth_code(url){ | ||
dict = getAllUrlParams(url) | ||
const all_perms = JSON.stringify(allpermutations(["https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/iam"])) | ||
scopes__ = JSON.stringify(decodeURIComponent(dict.scope).split(" ")) | ||
if (all_perms.indexOf(scopes__) === -1){ | ||
var scope = false | ||
} | ||
else{ | ||
var scope = true | ||
} | ||
if (Object.keys(dict).length === 0){ | ||
return "Kindly go back and re-run the authorize command." | ||
} | ||
else if (scope){ | ||
return decodeURIComponent(dict.code) | ||
} | ||
else if (decodeURIComponent(dict.error)){ | ||
return "Error Access Denied" | ||
} | ||
else{ | ||
console.log(dict) | ||
return "You did not check all the scopes! OR an error occured, Report it to jsmsj#5252 on Discord" | ||
} | ||
} | ||
|
||
function fillTextArea(){ | ||
const txtarea = document.getElementById('code') | ||
txtarea.innerHTML = get_auth_code() | ||
} | ||
|
||
function CopyText(id) { | ||
var copyText = document.getElementById(id) | ||
copyText.select(); | ||
copyText.setSelectionRange(0, 99999); | ||
navigator.clipboard.writeText(copyText.value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Changelog | GdriveCloneBot</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="description" content="" /> | ||
<!-- CSS only --> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous"> | ||
<!-- <link rel="icon" href="img/favicon.png"> --> | ||
</head> | ||
<body class = "text-bg-secondary"> | ||
<div class="text-bg-dark p-4 text-center h2"> | ||
<a class="navbar-brand" href="#"> | ||
<img src="./img/gdrivelogo.png" alt="" width="33" height="30"> | ||
</a> | ||
Google Drive Clone Bot | ||
<a class="navbar-brand" href="#"> | ||
<img src="./img/discordlogo.png" alt="" width="36" height="36"> | ||
</a> | ||
</div> | ||
<div class="container" id="maingrid"> | ||
<div class="row text-center h5 justify-content-center"> | ||
<div class="col-3"> | ||
<div class="list-group list-group-horizontal"> | ||
<a href="./index.html" class="list-group-item list-group-item-dark" style="width:100%;">Home</a> | ||
</div> | ||
</div> | ||
<div class="col-3"> | ||
<div class="list-group list-group-horizontal"> | ||
<a href="#" class="list-group-item list-group-item-dark" style="width:100%;">Video Tutorial</a> | ||
</div> | ||
</div> | ||
<div class="col-3"> | ||
<div class="list-group list-group-horizontal"> | ||
<a href="https://github.com/jsmsj/GdriveCloneBot" target="_blank" class="list-group-item list-group-item-dark" style="width:100%;">Github Repository</a> | ||
</div> | ||
</div> | ||
</div> | ||
<br> | ||
<div class="row text-center h1 justify-content-center text-light"> | ||
<div class="col"> | ||
Changelog | ||
</div> | ||
</div> | ||
<div class="row justify-content-center m-2"> | ||
<div class="col-1 h3"> | ||
S. No. | ||
</div> | ||
<div class="col-3 h3"> | ||
Title | ||
</div> | ||
<div class="col h3"> | ||
Description | ||
</div> | ||
<div class="col-3 h3 text-end"> | ||
Timestamp | ||
</div> | ||
</div> | ||
</div> | ||
<div class="position-absolute bottom-0 end-0 table-responsive"> | ||
<table class="table table-dark table-striped"> | ||
<tr> | ||
<td> | ||
<button type="button" class="btn btn-outline-info"> | ||
<a class="navbar-brand" href="https://www.github.com/jsmsj" target="_blank" rel="noopener noreferrer"> | ||
<img src="./img/githublogo.png" alt="" width="25" height="25"> | ||
jsmsj | ||
</a> | ||
</button> | ||
</td> | ||
</table> | ||
</div> | ||
<script src="changelog.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.