Greasy Fork

Greasy Fork is available in English.

Summarize Rapidgator links

Summarize Rapidgator links and display them with a copy button.

当前为 2025-02-28 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Summarize Rapidgator links
// @namespace    http://tampermonkey.net/
// @version      0.9
// @description  Summarize Rapidgator links and display them with a copy button.
// @author       Setcher
// @match        https://rapidgator.net/folder/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=rapidgator.net
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    // Function to extract and prepend links
    function extractAndDisplayLinks() {
        // Find the container div where we want to insert the new div (summary div)
        let summaryDiv = document.querySelector('.summary');

        if (!summaryDiv) return;  // If summary div is not found, do nothing

        // Create a new div under the summary div with the 'table_header' class
        let newDiv = document.createElement('div');
        newDiv.setAttribute('class', 'btm');  // Set the class to table_header

        // Heading for the new div
        let heading = document.createElement('div');
        heading.innerHTML = "Rapidgator Links";  // Simplified heading
        newDiv.appendChild(heading);

        // Create a table for displaying the links
        let table = document.createElement('table');
        table.classList.add('items');  // Apply the 'items' class for consistent styling

        // Add table header row
        let thead = document.createElement('thead');
        let headerRow = document.createElement('tr');
        let nameHeader = document.createElement('th');
        nameHeader.textContent = "File Name";
        let sizeHeader = document.createElement('th');
        headerRow.appendChild(nameHeader);
        thead.appendChild(headerRow);
        table.appendChild(thead);

        // Extract all file links that start with href="/file/"
        let links = document.querySelectorAll('a[href^="/file/"]');
        let tbody = document.createElement('tbody');

        links.forEach(link => {
            let fileLink = link.getAttribute('href');
            if (fileLink && fileLink.startsWith("/file/")) {
                let fullLink = 'https://www.rapidgator.net' + fileLink;

                // Create a new table row for each link
                let row = document.createElement('tr');
                row.setAttribute('class', 'odd');
                let nameCell = document.createElement('td');

                // Create a link in the first cell
                let fileLinkElement = document.createElement('a');
                fileLinkElement.href = fullLink;
                fileLinkElement.textContent = fullLink; // Use the text of the link
                nameCell.appendChild(fileLinkElement);


                row.appendChild(nameCell);
                tbody.appendChild(row);
            }
        });

        // Add the tbody to the table
        table.appendChild(tbody);

        // Add the table to the new div
        newDiv.appendChild(table);

        // Create the "Copy all" button
        let copyButton = document.createElement('button');
        copyButton.textContent = 'Copy all';

        // Button click handler to copy all links to the clipboard
        copyButton.addEventListener('click', function() {
            let allLinks = Array.from(tbody.querySelectorAll('tr')).map(row => {
                let link = row.querySelector('a');
                return link ? link.href : '';
            }).join('\n');
            GM_setClipboard(allLinks);
            alert('Links copied to clipboard!');
        });

        // Add the button below the table
        newDiv.appendChild(copyButton);

        // Append the new div with the table to the summary div
        summaryDiv.appendChild(newDiv);
    }

    // Run the script when the page is fully loaded
    window.addEventListener('load', extractAndDisplayLinks);
})();