Anna's Archive Wait Skipper (v4.1)

Finds the real download link on the slow download page and bypasses the timer.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Anna's Archive Wait Skipper (v4.1)
// @namespace    http://tampermonkey.net/
// @version      4.1
// @description  Finds the real download link on the slow download page and bypasses the timer.
// @author       You & Your Friend
// @match        *://annas-archive.org/slow_download/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // --- The Problem ---
    // The website now hides the real download button and shows a fake, disabled one first.
    // The real button is present in the HTML from the start but isn't immediately clickable.
    // Our goal is to find the correct button and click it as soon as the page lets us.

    // This is the selector for the main download button. It seems they now use this ID for it.
    const DOWNLOAD_BUTTON_SELECTOR = '#download-button';

    const attemptBypass = () => {
        // Find the one and only download button.
        const downloadButton = document.querySelector(DOWNLOAD_BUTTON_SELECTOR);

        // Check if the button exists and if it has an 'href' attribute.
        // The disabled button might not have an href, but the real one will.
        if (downloadButton && downloadButton.hasAttribute('href')) {
            console.log('Anna\'s Archive Skipper: Found the active download link. Clicking now!');

            // Stop the page's countdown timer script, just in case.
            window.stop();

            // Click the button to start the download.
            downloadButton.click();

            return true; // Signal that we're done.
        }

        // If we're here, the button wasn't ready yet.
        console.log('Anna\'s Archive Skipper: Waiting for the download button to become active...');
        return false;
    };

    // --- The Solution ---
    // A MutationObserver is the perfect tool for this job. It's super efficient.
    // It will watch the page for any changes and run our code only when something happens.
    const observer = new MutationObserver((mutationsList, obs) => {
        // We run our bypass function on every change until it succeeds.
        if (attemptBypass()) {
            // Once we've successfully clicked the button, we don't need to watch anymore.
            console.log('Anna\'s Archive Skipper: Bypass successful. Disconnecting observer.');
            obs.disconnect();
        }
    });

    // Start observing the whole document for changes to elements and their attributes.
    // This is robust because it will catch the moment the 'href' is added to the button.
    observer.observe(document.documentElement, {
        childList: true,
        subtree: true,
        attributes: true // We also watch for attribute changes now!
    });

    // We can also try one initial time right away, just in case the button is ready on page load.
    attemptBypass();

})();