自动展开“安娜的档案”外部下载列表

自动点击书籍页面中的 "show external downloads"(Automatically click "show external downloads" on Anna's Archive pages)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         自动展开“安娜的档案”外部下载列表
// @namespace    http://tampermonkey.net/
// @version      1.61
// @description  自动点击书籍页面中的 "show external downloads"(Automatically click "show external downloads" on Anna's Archive pages)
// @author       GPT-4o
// @match        https://*.annas-archive.*/md5/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to click the "show external downloads" button
    function clickShowExternalDownloads() {
        let button = document.querySelector('a.js-show-external-button');
        if (!button) {
            const buttons = document.querySelectorAll('a');
            buttons.forEach(btn => {
                if (btn.textContent.trim() === 'show external downloads') {
                    button = btn;
                }
            });
        }

        if (button) {
            button.click();
        } else {
            console.log('Button not found.');
        }
    }

    // Retry mechanism to ensure the button is clicked even if the page takes time to load
    function retryClick(retries, delay) {
        if (retries <= 0) return;
        setTimeout(function() {
            clickShowExternalDownloads();
            retryClick(retries - 1, delay);
        }, delay);
    }

    // Wait for the page to load completely before executing the function
    window.addEventListener('load', function() {
        retryClick(20, 1000);  // Try 20 times with a 1-second interval
    });
})();