Media Link Extractor

Extract media links from various websites.

Per 14-01-2025. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==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 });
    }
})();