-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathggdrive_downloadPresentation.js
63 lines (57 loc) · 2.13 KB
/
ggdrive_downloadPresentation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
export default {
icon: "https://drive-thirdparty.googleusercontent.com/32/type/application/vnd.openxmlformats-officedocument.presentationml.presentation",
name: {
en: "GG Drive - Download PowerPoint (Slides/Presentation)",
vi: "GG Drive - Tải PowerPoint (Slides)",
},
description: {
en: "Download google drive Presentation file that dont have download button, covert to HTML file.",
vi: "Tải file Powerpoint (Slides) không có nút download trên google drive, tải về định dạng HTML.",
},
whiteList: ["https://docs.google.com/presentation/*"],
popupScript: {
onClick: async () => {
const { t } = await import("../popup/helpers/lang.js");
const { getCurrentTab, openWebAndRunScript } = await import(
"./helpers/utils.js"
);
let tab = await getCurrentTab();
let { url, title } = tab;
let guide = t({
vi: "Sử dụng chức năng\nTự động > In web ra PDF hoặc\nTự động > Chụp ảnh toàn bộ web\nđể tải slides nhé.",
en: "Please use feature\nAutomation > Screenshot full page OR\nAutomation > Web to PDF\nto download this slides",
});
if (url.includes("/htmlpresent")) {
alert(guide);
} else {
url = prompt(
t({
vi: "Nhập link file powerpoint (slide) google drive: \nĐịnh dạng: https://docs.google.com/presentation/*",
en: "Enter google drive presentation url: \nFormat: https://docs.google.com/presentation/*",
}),
url
);
if (!url) return;
let id = /d\/([^\/]+)\/?/.exec(url)?.[1];
if (!id) {
alert(
t({
vi: "Không tìm được id file trên url",
en: "Can not find file id in url",
})
);
return;
}
openWebAndRunScript({
url: "https://docs.google.com/presentation/d/" + id + "/htmlpresent",
func: async (guide) => {
window.onload = alert(guide);
},
args: [guide],
focusImmediately: true,
waitUntilLoadEnd: false,
});
}
},
},
};