You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,4 @@
1
-
# Google-Drive-View-Only-PDF-Script-Downloader
2
-
1
+
```markdown
3
2
Here you can use this script to download view only pdf file from Google Drive. This script works like a screenshot capturing all pdf pages to bulk of images with better resolution quality and combine it all into one pdf file.
4
3
5
4
### Big-Note: Use this script wisely!
@@ -87,8 +86,11 @@ Here you can use this script to download view only pdf file from Google Drive. T
87
86
}
88
87
89
88
// check if title contains .pdf in end of the title
90
-
let title =document.querySelector('meta[itemprop="name"]').content;
91
-
if (title.split(".").pop() !=="pdf") {
89
+
// Use optional chaining to avoid errors if the meta tag isn't present.
90
+
// Fall back to document.title when necessary. Note: if the PDF is inside a cross-origin iframe,
91
+
// parent scripts cannot access the iframe document due to same-origin policy.
92
+
let title = document.querySelector('meta[itemprop="name"]')?.content || document.title || 'download.pdf';
93
+
if ((title.split(".").pop() || "").toLowerCase() !== "pdf") {
92
94
title = title + ".pdf";
93
95
}
94
96
@@ -126,3 +128,4 @@ Here you can use this script to download view only pdf file from Google Drive. T
0 commit comments