-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgoogle_drive_autoclick.user.js
51 lines (48 loc) · 1.83 KB
/
google_drive_autoclick.user.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
// ==UserScript==
// @name google drive auto click
// @namespace https://github.com/x94fujo6rpg/SomeTampermonkeyScripts
// @updateURL https://github.com/x94fujo6rpg/SomeTampermonkeyScripts/raw/master/google_drive_autoclick.user.js
// @downloadURL https://github.com/x94fujo6rpg/SomeTampermonkeyScripts/raw/master/google_drive_autoclick.user.js
// @version 0.2
// @description auto skip & click download
// @author x94fujo6
// @match https://drive.google.com/*
// @match https://docs.google.com/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
document.body.onload = main();
function main() {
let link = window.location.href;
let list = [
"drive",
"docs",
];
let index = list.findIndex(key => link.includes(`//${key}.`));
if (index == -1) {
return;
}
if (link.includes("google.com/file/d/")) {
// https://drive.google.com/file/d/*/view
let id = link.split("/");
id = id[id.length - 2];
window.location.href = `https://${list[index]}.google.com/u/0/uc?id=${id}&export=download`;
} else if (link.includes("uc?")) {
if (!link.includes("confirm=")) {
// https://drive.google.com/u/0/uc?id=*&export=download
let id = setInterval(() => clickDL(id), 100);
} else if (link.includes("export=download") && link.includes("confirm=")) {
// https://drive.google.com/u/0/uc?export=download&confirm=*&id=*
let id = setInterval(() => clickDL(id), 100);
}
}
}
function clickDL(id) {
let button = document.getElementById("uc-download-link");
if (button) {
button.click();
clearInterval(id);
}
}
})();