Skip to content

Commit 72ce9fc

Browse files
author
hoang.tran12
committed
gg drive ppt + pdf
1 parent 37e798c commit 72ce9fc

File tree

11 files changed

+85
-22
lines changed

11 files changed

+85
-22
lines changed

popup/tabs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const tabs = [
9595
createTitle("--- Download ---", "--- Tải xuống ---"),
9696
s.ggdrive_generateDirectLink,
9797
s.ggdrive_downloadPdf,
98+
s.ggdrive_downloadPresentation,
9899
s.ggdrive_downloadVideo,
99100
s.google_downloadAllYourData,
100101
createTitle("--- Bulk Download ---", "--- Tải hàng loạt ---"),

scripts/content-scripts/scripts/ufs_global_webpage_context.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,27 @@ const UsefulScriptGlobalPageContext = {
151151
return policy.createHTML(html);
152152
},
153153

154-
injectScriptSrc(src, callback) {
154+
injectScriptSrc(srcs, callback) {
155155
let policy = UsefulScriptGlobalPageContext.DOM.getTrustedPolicy();
156-
let jsSrc = policy.createScriptURL(src);
157156

158-
let script = document.createElement("script");
159-
script.onload = function () {
160-
callback?.(true);
161-
};
162-
script.onerror = function (e) {
163-
callback?.(false, e);
164-
};
165-
script.src = jsSrc; // Assigning the TrustedScriptURL to src
166-
document.head.appendChild(script);
157+
let listSrcs = srcs;
158+
if (!Array.isArray(listSrcs)) {
159+
listSrcs = [listSrcs];
160+
}
161+
162+
for (let src of listSrcs) {
163+
let jsSrc = policy.createScriptURL(src);
164+
165+
let script = document.createElement("script");
166+
script.onload = function () {
167+
callback?.(true);
168+
};
169+
script.onerror = function (e) {
170+
callback?.(false, e);
171+
};
172+
script.src = jsSrc; // Assigning the TrustedScriptURL to src
173+
document.head.appendChild(script);
174+
}
167175
},
168176

169177
isElementInViewport(el) {

scripts/ggdrive_downloadPdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
vi: "Tải file PDF không có nút download trên google drive",
1010
},
1111

12-
whiteList: ["https://drive.google.com/file/*"],
12+
whiteList: ["https://drive.google.com/file/d/*"],
1313

1414
onClick: () => {
1515
UsefulScriptGlobalPageContext.DOM.injectScriptSrc(
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { getCurrentTab } from "./helpers/utils.js";
2+
3+
export default {
4+
icon: "https://drive.google.com/favicon.ico",
5+
name: {
6+
en: "GG Drive - Download PowerPoint (Slides/Presentation)",
7+
vi: "GG Drive - Tải PowerPoint (Slides)",
8+
},
9+
description: {
10+
en: "Download google drive Presentation file that dont have download button, covert to HTML file.",
11+
vi: "Tải file Powerpoint (Slides) không có nút download trên google drive, tải về định dạng HTML.",
12+
},
13+
14+
whiteList: ["https://docs.google.com/presentation/*"],
15+
16+
onClickExtension: async () => {
17+
let tab = await getCurrentTab();
18+
let { url, title } = tab;
19+
20+
if (url.includes("/htmlpresent")) {
21+
alert(
22+
"Ban hãy bấm Ctrl+S để lưu toàn bộ slides trong trang hiện tại nhé."
23+
);
24+
} else {
25+
url = prompt(
26+
"Nhập link file powerpoint (slide) google drive: \nĐịnh dạng: https://docs.google.com/presentation/*",
27+
url
28+
);
29+
if (!url) return;
30+
31+
let id = /d\/([^\/]+)\/?/.exec(url)?.[1];
32+
if (!id) {
33+
alert("Không tìm được id file trên url");
34+
return;
35+
}
36+
37+
alert(
38+
"File sẽ được mở trong trang mới. Bạn có thể bấm Ctrl+S để lưu toàn bộ slides trong trang mới."
39+
);
40+
41+
window.open(
42+
"https://docs.google.com/presentation/d/" + id + "/htmlpresent"
43+
);
44+
}
45+
},
46+
};

scripts/ggdrive_downloadVideo.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default {
1515
en: "Download google drive video that dont have download button",
1616
vi: "Tải video không có nút download trên google drive",
1717
},
18+
infoLink:
19+
"https://www.facebook.com/groups/j2team.community/posts/974953859503401/",
1820

1921
onClickExtension: async function () {
2022
let { closeLoading } = showLoading("Đang tìm link video...");

scripts/ggdrive_generateDirectLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
if (url == null) return;
2020

2121
let directLink = shared.generateDirectLinkFromUrl(url);
22-
prompt("Thành công! Link tải ngay của bạn: ", directLink);
22+
if (directLink) window.open(directLink);
2323
} catch (e) {
2424
alert("ERROR: " + e);
2525
}

scripts/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ import fireship_vip from "./fireship_vip.js";
182182
import vuiz_createLogo from "./vuiz_createLogo.js";
183183
import vuiz_getLink from "./vuiz_getLink.js";
184184
import ggdrive_downloadPdf from "./ggdrive_downloadPdf.js";
185+
import ggdrive_downloadPresentation from "./ggdrive_downloadPresentation.js";
185186

186187
// inject badges
187188
const allScripts = {
@@ -385,6 +386,10 @@ const allScripts = {
385386
vuiz_createLogo: addBadge(vuiz_createLogo, BADGES.new),
386387
vuiz_getLink: addBadge(vuiz_getLink, BADGES.new),
387388
ggdrive_downloadPdf: addBadge(ggdrive_downloadPdf, BADGES.new),
389+
ggdrive_downloadPresentation: addBadge(
390+
ggdrive_downloadPresentation,
391+
BADGES.new
392+
),
388393
};
389394

390395
// alert(Object.keys(allScripts).length);

scripts/injectScriptToWebsite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ export default {
1919
url,
2020
(success, error) => {
2121
if (success) {
22-
alert("Inject SUCCESS: " + url);
22+
alert("Inject SUCCESS.\n\n" + url);
2323
} else {
24-
alert("Inject FAILED. " + error);
24+
alert("Inject FAILED.\n\n" + JSON.stringify(error));
2525
}
2626
}
2727
);

scripts/libs/html2img/index.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/medium_readFullArticle.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ export default {
2020
url = prompt("Nhập link medium:", url);
2121

2222
if (url) {
23-
window.open(
24-
"https://freedium.cfd/" + encodeURIComponent(window.location)
25-
);
23+
window.open("https://freedium.cfd/" + url);
2624
}
2725
},
2826
};

0 commit comments

Comments
 (0)