google drive auto click

auto skip & click download

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         google drive auto click
// @namespace    https://github.com/x94fujo6rpg/SomeTampermonkeyScripts
// @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);
        }
    }
})();