CLI
List
gdrive files list --max 1000 --order-by "folder,name_natural" --query "trashed = false and '<email>' in readers"Share
gdrive permissions share --type user --role reader --email <email> <file_id>Revoke Permissions
| Reference | https://developers.google.com/apps-script/reference/drive |
| Script | https://script.google.com/d/1bCyZmPi6C8YFWdFlr4YZQreHivdg9XSM0Xwb-3aqf_7vO5VI9LOBjIYs/edit?usp=sharing |
- Run
removeFoldersAccessto revoke permissions from folders - Run
revokeFilesPermissionsto revoke permissions from files
After each execution that has timed out, we should copy and paste back in the continuation token and call DriveApp.continueFolderIterator() to continue the script at the pervious stopping point
Logs will be saved to _scripts/logs in the format of <yyyymmddhhmmss>_revoke_<folders|files>_permissions.json, with the following structure indicating the folders/files where the permissions from viewers have been revoked
[
{
"id": "",
"name": "",
"path": "",
"url": "",
"viewers": [
{
"name": "",
"email" "",
"photoUrl": ""
}
]
}
]
Download View-Only
- Open the PDF
- Paste the script into console, which handles auto scrolling and downloading
- OCR the PDF to make the words searchable, single/batch processing
ocrmypdf -O2 <in>.pdf <out>.pdfmkdir output && parallel --tag -j 2 ocrmypdf -O2 '{}' 'output/{}' ::: *.pdfCite
https://github.com/zeltox/Google-Drive-PDF-Downloader
https://codingcat.codes/2019/01/09/download-view-protected-pdf-google-drive-js-code/
Google Doc
- Change
/editto/mobilebasic - Disable javasciprt
- Save as PDF
Google Slides
- Change
/editto/htmlpresent - Disable JavaScript
document.body.style.background = "#ffffff"- Remove
<noscript>and extra strings inside HTML - Save as PDF
OR
- Change
/editto/htmlpresent - Paste the below script to download all slides as images
- Convert into PDF
let i = 0
const images = $$(".slide-content");
const interval = setInterval(() => {
const anchor = document.createElement("a");
anchor.href = images[i].style.backgroundImage.slice(5, -2).toString();
anchor.download = (i + 1) + ".png";
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
if (i + 1 === images.length) {
clearInterval(interval);
}
i++;
}, 200)Google Sheets
- Change
/editto/preview - Save as PDF
Image Folder
- Allow pop up
// Image class selector
// Since there is authentication, need to manually download
$$('.a-b-ta-Ua').forEach((e) => {
window.open(e.src)
})