-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
studocu_downs.js
74 lines (69 loc) · 2.02 KB
/
studocu_downs.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
64
65
66
67
68
69
70
71
72
73
74
import { BADGES } from "./helpers/badge.js";
export default {
icon: "https://d20ohkaloyme4g.cloudfront.net/img/favicon.ico",
name: {
en: "Studocu - Download documents",
vi: "Studocu - Tải documents",
},
description: {
en: "Download documents on Studocu.com for free",
vi: "Tải tài liệu trên Studocu.com miễn phí",
},
badges: [BADGES.hot],
changeLogs: {
"2024-05-11": "combine + auto download",
},
popupScript: {
onClick: async function () {
const { getCurrentTab, openWebAndRunScript } = await import(
"./helpers/utils.js"
);
let funcs = {
"dlstudocu.com": async (url) => {
openWebAndRunScript({
url: "https://dlstudocu.com/",
func: (url) => {
let interval = setInterval(() => {
if (window.st_url) {
try {
window.st_url.value = url;
document.querySelector("form").submit();
clearInterval(interval);
} catch (e) {
console.log(e);
}
}
}, 100);
},
args: [url],
waitUntilLoadEnd: false,
focusImmediately: true,
});
},
"downstudocu.com": async (url) => {
url = new URL(url);
url.hostname = "www.downstudocu.com";
window.open(url);
},
};
let tab = await getCurrentTab();
let url = prompt(
"Nhập link studocu document:\nĐịnh dạng: https://www.studocu.com/vn/document/...",
tab.url
);
if (url == null) return;
let keys = Object.keys(funcs);
let choice = prompt(
"Nhập website muốn download:\n\n" +
keys.map((a, i) => i + ": " + a).join("\n"),
0
);
if (choice == null) return;
if (keys[choice] == null) {
alert("Nhập sai dữ liệu. Invalid choice");
return;
}
funcs[keys[choice]]?.(url);
},
},
};