Archive.org Auto-Resume Upload

Automatically clicks the Resume Upload button on the upload page in archive.org

目前為 2025-11-17 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Archive.org Auto-Resume Upload
// @namespace    https://greasyfork.org/en/scripts/556054-archive-org-auto-resume-upload
// @license      MIT
// @version      1.0
// @description  Automatically clicks the Resume Upload button on the upload page in archive.org
// @author       Adam Jensen
// @match        https://archive.org/upload/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    const TARGET_BUTTON_TEXT = 'Resume Uploading';
    const BUTTON_SELECTOR = 'button.js-uploader-resume_upload';
    const MINUTE_IN_MS = 60000;

    // --- Configuration ---
    const CHECK_INTERVAL_MINUTES = 1; // How often to look for the button (in minutes)
    const CLICK_COOLDOWN_MINUTES = 5; // How long to wait before clicking the button again (in minutes)
    // ---------------------

    const CLICK_COOLDOWN_MS = MINUTE_IN_MS * CLICK_COOLDOWN_MINUTES;
    const CHECK_INTERVAL_MS = MINUTE_IN_MS * CHECK_INTERVAL_MINUTES;

    let lastClickTime = 0;

    async function isOnline() {
        try {
            await fetch('https://archive.org/', { method: 'HEAD', mode: 'no-cors', cache: 'no-store' });
            return true;
        } catch (error) {
            console.warn("❌ Internet connection check failed.");
            return false;
        }
    }

    async function findAndClickButton() {
        const resumeButton = document.querySelector(BUTTON_SELECTOR);
        const currentTime = Date.now();

        if (resumeButton && resumeButton.textContent.trim() === TARGET_BUTTON_TEXT) {
            if (currentTime - lastClickTime >= CLICK_COOLDOWN_MS) {
                if (await isOnline()) {
                    console.log(`✅ Button found and connection is online. Clicking "${TARGET_BUTTON_TEXT}".`);
                    resumeButton.click();
                    lastClickTime = currentTime;
                } else {
                    console.log(`⚪ Button found, but no internet connection. Skipping click.`);
                }
            } else {
                const timeLeftMS = CLICK_COOLDOWN_MS - (currentTime - lastClickTime);
                const timeLeftMinutes = timeLeftMS / MINUTE_IN_MS;
                console.warn(`⚠️ Button found, but on cooldown. Click skipped. Time remaining: ${timeLeftMinutes.toFixed(2)} minutes.`);
            }
        } else {
            console.log(`⚪ Button not found. Next check in ${CHECK_INTERVAL_MINUTES} minute(s).`);
        }
    }

    setInterval(findAndClickButton, CHECK_INTERVAL_MS);

    console.log(`UserScript started. Checking for button every ${CHECK_INTERVAL_MINUTES} minute(s) with a ${CLICK_COOLDOWN_MINUTES} minute(s) cooldown.`);

})();