Countdown and auto-click download on Google Drive download page
当前为
// ==UserScript==
// @name Google Drive Auto Download Countdown
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Countdown and auto-click download on Google Drive download page
// @author MoodyMonkey
// @match *://drive.usercontent.google.com/download?id=*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function startCountdown() {
const downloadButton = document.getElementById('uc-download-link');
if (!downloadButton) {
console.log('Waiting for download button...');
setTimeout(startCountdown, 500);
return;
}
const countdownText = document.createElement('div');
countdownText.style.marginBottom = '10px';
countdownText.style.fontSize = '16px';
countdownText.style.fontWeight = 'bold';
countdownText.style.color = '#d9534f';
downloadButton.parentNode.insertBefore(countdownText, downloadButton);
let count = 5;
countdownText.textContent = `Download will start automatically in ${count}...`;
const timer = setInterval(() => {
count--;
if (count >= 0) {
countdownText.textContent = `Download will start automatically in ${count}...`;
}
if (count === 0) {
clearInterval(timer);
console.log('Triggering the download automatically!');
downloadButton.click();
}
}, 1000);
// User clicks manually so stop automatic download
downloadButton.addEventListener('click', () => {
console.log('Manual download detected! Countdown canceled!');
clearInterval(timer);
countdownText.textContent = 'Download starting manually...';
});
}
startCountdown();
})();