DownArchive Link Extractor

Extract links from DownArchive and copy them to clipboard

目前為 2025-02-28 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DownArchive Link Extractor
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Extract links from DownArchive and copy them to clipboard
// @author       Setcher
// @match        *://downarchive.org/*
// @grant        GM_xmlhttpRequest
// @grant        GM_setClipboard
// @connect      rg.to
// @connect      rapidgator.net
// @connect      uploadgig.com
// @connect      nitroflare.com
// @connect      filextras.com
// ==/UserScript==

(function() {
    'use strict';

    // Utility function to create copy button
    function createCopyButton(container, text, links) {
        const button = document.createElement('button');
        button.innerText = text;
        button.style.marginTop = '10px';
        button.style.marginBottom = '10px'; // Add space below button
        button.onclick = function() {
            const clipboardText = links.join('\n');
            GM_setClipboard(clipboardText);
            alert(`Copied ${links.length} links to clipboard!`);
        };
        container.appendChild(button);
    }

    // Extract rg.to folder links and add button to copy
    function extractRGLinks(folderUrl, container) {
        GM_xmlhttpRequest({
            method: 'GET',
            url: folderUrl,
            onload: function(response) {
                const doc = new DOMParser().parseFromString(response.responseText, 'text/html');
                const fileLinks = Array.from(doc.querySelectorAll('a[href^="/file/"]')).map(link => "https://rapidgator.net/" + link.getAttribute('href'));
                createCopyButton(container, `Copy all ${fileLinks.length} rapidgator.net links`, fileLinks);
            }
        });
    }

    // Main function to process each quote div
    function processQuoteDiv(quoteDiv) {
        const links = Array.from(quoteDiv.querySelectorAll('a'));

        let rgLink = null;
        const otherLinks = {
            'rapidgator.net': [],
            'uploadgig.com': [],
            'nitroflare.com': [],
            'filextras.com': []
        };

        links.forEach(link => {
            const href = link.href;

            if (href.startsWith('https://rg.to/folder/')) {
                rgLink = href;
            } else if (href.includes('rapidgator.net/file/')) {
                otherLinks['rapidgator.net'].push(href);
            } else if (href.includes('uploadgig.com/file/')) {
                otherLinks['uploadgig.com'].push(href);
            } else if (href.includes('nitroflare.com/')) {
                otherLinks['nitroflare.com'].push(href);
            } else if (href.includes('filextras.com/')) {
                otherLinks['filextras.com'].push(href);
            }
        });

        // First, create the buttons for rg.to links if available
        if (rgLink) {
            extractRGLinks(rgLink, quoteDiv);
        }

        // Then, create a "Copy all X links" button for each domain with links
        for (const domain in otherLinks) {
            if (otherLinks[domain].length > 0) {
                createCopyButton(quoteDiv, `Copy all ${otherLinks[domain].length} ${domain} links`, otherLinks[domain]);
            }
        }
    }

    // Main function to run on page load
    window.addEventListener('load', function() {
        const quoteDivs = document.querySelectorAll('div.quote');
        quoteDivs.forEach(quoteDiv => {
            processQuoteDiv(quoteDiv);
        });
    });
})();