Media Link Extractor

Extract media links from various websites.

当前为 2025-01-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Media Link Extractor
// @namespace    http://tampermonkey.net/
// @version      3.1
// @description  Extract media links from various websites.
// @author       1axx
// @match        https://cyberdrop.me/*
// @match        https://files.fm/*
// @match        https://app.koofr.net/*
// @match        https://bunkr.site/*
// @match        https://bunkr.si/*
// @grant        GM_setClipboard
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // Site configuration for selectors and processing
    const siteConfigs = {
        'cyberdrop.me': {
            selector: '.image-container.column a.image',
            process: (el) => el.getAttribute('href'),
        },
        'files.fm': {
            selector: '.item.file.image-item a.top_button_download.my_tooltip, .item.file.video-item a.top_button_download.my_tooltip',
            process: (el) => el.getAttribute('href'),
        },
        'app.koofr.net': {
            selector: 'a[href^="/content/links/"]',
            process: (el) => el.getAttribute('href'),
        },
        'bunkr.site': {
            selector: 'a[href^="https://bunkrrr.org/"]',
            process: (el) => el.getAttribute('href'),
        },
        'bunkr.si': {
            selector: 'a[href^="https://bunkrrr.org/"]',
            process: (el) => el.getAttribute('href'),
        },
    };

    let mediaLinks = new Set(); // Use a Set to avoid duplicates

    // Function to collect media links
    function collectMediaLinks() {
        const host = window.location.host;
        const config = siteConfigs[Object.keys(siteConfigs).find((key) => host.includes(key))];
        if (!config) {
            alert('Unsupported site.');
            return;
        }

        mediaLinks.clear(); // Clear previous links
        const elements = document.querySelectorAll(config.selector);
        elements.forEach((el) => {
            const link = config.process(el);
            if (link) {
                // Add the link to the Set
                mediaLinks.add(link.startsWith('http') ? link : `${window.location.origin}${link}`);
            }
        });
    }

    // Function to display the links
    function displayLinksUI() {
        const popup = document.createElement('div');
        popup.style.cssText = `
            position: fixed;
            top: 20%;
            left: 50%;
            transform: translate(-50%, -20%);
            background-color: #121212;
            padding: 20px;
            border: 2px solid #444;
            border-radius: 10px;
            z-index: 10000;
            width: 60%;
            box-shadow: 0px 0px 20px rgba(0, 255, 255, 0.3);
        `;

        const textarea = document.createElement('textarea');
        textarea.value = Array.from(mediaLinks).join('\n'); // Convert Set to Array and join with newlines
        textarea.style.cssText = `
            width: 100%;
            height: 200px;
            margin-bottom: 10px;
            background-color: #181818;
            color: #00FFFF;
            border: 1px solid #555;
            border-radius: 5px;
            padding: 10px;
            font-family: Consolas, "Courier New", monospace;
            font-size: 14px;
            resize: none;
        `;
        popup.appendChild(textarea);

        const counter = document.createElement('div');
        counter.textContent = `Total Unique Links: ${mediaLinks.size}`; // Show unique count
        counter.style.cssText = `
            margin-bottom: 10px;
            font-weight: bold;
            text-align: center;
            color: #00FFFF;
        `;
        popup.appendChild(counter);

        const copyButton = document.createElement('button');
        copyButton.textContent = 'Copy to Clipboard';
        copyButton.style.cssText = `
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        `;
        copyButton.addEventListener('click', () => {
            textarea.select();
            document.execCommand('copy');
            alert('Links copied to clipboard!');
        });
        popup.appendChild(copyButton);

        const closeButton = document.createElement('button');
        closeButton.textContent = 'Close';
        closeButton.style.cssText = `
            margin-left: 10px;
            padding: 10px;
            background-color: #dc3545;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        `;
        closeButton.addEventListener('click', () => {
            document.body.removeChild(popup);
        });
        popup.appendChild(closeButton);

        document.body.appendChild(popup);
    }

    // Add a button to trigger the process
    const extractButton = document.createElement('button');
    extractButton.textContent = 'Extract Media Links';
    extractButton.style.cssText = `
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 9999;
        background-color: #007bff;
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 5px;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    `;
    extractButton.addEventListener('click', () => {
        collectMediaLinks();
        if (mediaLinks.size > 0) {
            displayLinksUI();
        } else {
            alert('No media links found! Make sure the content is fully loaded.');
        }
    });

    document.body.appendChild(extractButton);

    // Monitor for dynamic content loading
    const observer = new MutationObserver(() => {
        collectMediaLinks();
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();