Archive.org Auto-Resume Upload

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

当前为 2025-11-17 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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.`);

})();