Google Drive Direct Download Link

Добавляет кнопку для получения прямой ссылки на скачивание файла из Google Drive

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Google Drive Direct Download Link
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Добавляет кнопку для получения прямой ссылки на скачивание файла из Google Drive
// @author       Rodion & ChatGPT
// @match        https://drive.google.com/file/d/*
// @icon         https://ssl.gstatic.com/docs/doclist/images/infinite_arrow_favicon_5.ico
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    // Проверка, что страница загружена
    function waitForElement(selector, callback) {
        const interval = setInterval(() => {
            const el = document.querySelector(selector);
            if (el) {
                clearInterval(interval);
                callback(el);
            }
        }, 500);
    }

    function getFileId() {
        const match = window.location.pathname.match(/\/file\/d\/([a-zA-Z0-9_-]+)/);
        return match ? match[1] : null;
    }

    function createButton(fileId) {
        const button = document.createElement('button');
        button.innerText = '🔗 Получить прямую ссылку';
        button.style.cssText = `
            position: fixed;
            top: 80px;
            right: 20px;
            z-index: 9999;
            padding: 10px 14px;
            background-color: #0f9d58;
            color: white;
            border: none;
            border-radius: 5px;
            font-weight: bold;
            cursor: pointer;
        `;

        button.onclick = () => {
            const directLink = `https://drive.google.com/uc?export=download&id=${fileId}`;
            GM_setClipboard(directLink);
            alert("Прямая ссылка скопирована в буфер обмена:\n\n" + directLink);
        };

        document.body.appendChild(button);
    }

    const fileId = getFileId();
    if (fileId) {
        waitForElement('div[jscontroller]', () => {
            createButton(fileId);
        });
    }
})();