Media Link Extractor

Extract media links from various websites.

Устаревшая версия за 14.01.2025. Перейдите к последней версии.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name         Media Link Extractor
// @namespace    http://tampermonkey.net/
// @version      3.2
// @description  Extract media links from various websites.
// @author       1axx
// @icon         https://img.freepik.com/premium-photo/link-icon-3d-render-illustration_567294-4275.jpg?semt=ais_hybrid
// @include      https://cyberdrop.me/*
// @include      https://files.fm/*
// @include      https://app.koofr.net/*
// @include      https://bunkr.*/*
// @include      https://*.dropbox.com/*
// @grant        GM_setClipboard
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    //  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': {
            selector: 'a[href^="https://bunkrrr.org/"], a[href^="/f/"]',
            process: (el) => el.getAttribute('href'),
        },
        'dropbox.com': {
            selector: 'a[href^="https://www.dropbox.com/scl/"]',
            process: (el) => el.getAttribute('href'),
        }
    };

    let mediaLinks = new Set(); //  avoid duplicates

    // Function to collect media links
    function collectMediaLinks() {
        const host = window.location.host;
        const configKey = Object.keys(siteConfigs).find((key) => host.includes(key));
        const config = siteConfigs[configKey];
        if (!config) {
            return; // Do nothing if the site is not supported
        }

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

    // Function to display the links
    function displayLinksUI() {
        if (mediaLinks.size === 0) return;

        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');
        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}`;
        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 only if the site is supported
    const host = window.location.host;
    const configKey = Object.keys(siteConfigs).find((key) => host.includes(key));

    if (configKey) {
        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();
            displayLinksUI();
        });

        document.body.appendChild(extractButton);

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

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