Google Drive | wget copy&paste command creator - EN Version

A easy tool to use to use your terminal to download your files from Google Drive!

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Google Drive | wget copy&paste command creator - EN Version
// @namespace    http://tampermonkey.net/
// @version      Final-2021
// @description  A easy tool to use to use your terminal to download your files from Google Drive!
// @author       xAlcahest
// @match        https://drive.google.com/file/d/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';
    var url_parttens = window.location.href.split('/');
    var file_id = url_parttens[url_parttens.length - 2]
    var file_name = jQuery("meta[property='og:title']").attr("content");
    var command = `wget --load-cookies cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=${file_id}' ` + "-O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\\1\\n/p')&id=" + `${file_id}" -O ${file_name} && rm -rf cookies.txt`;
    GM_setClipboard(command);
    alert('The [wget] command is ready, the command has been automatically copied to the clipboard.')
   })();