Media Link Extractor

Extract all media links from sites like Cyberdrop.me and Files.fm, display them in a UI for easy copying, and show a link counter. More to come!

As of 06.01.2025. See апошняя версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Media Link Extractor
// @namespace    http://tampermonkey.net/
// @version      2.8
// @description  Extract all media links from sites like Cyberdrop.me and Files.fm, display them in a UI for easy copying, and show a link counter. More to come!
// @author       1axx
// @match        https://cyberdrop.me/*
// @match        https://files.fm/*
// @match        https://app.koofr.net/*
// @match        https://mega.nz/*
// @grant        GM_setClipboard
// @license      MIT
// @icon         https://media.discordapp.net/attachments/1265290591009247232/1325655730744987729/6ff7c29d-92ae-44b1-9a05.png?ex=677c949b&is=677b431b&hm=9d7fc817525b5fdf5dba28d778c83e24b93bd274b58f6dbdfb17af0be6b81865&=&width=620&height=620
// ==/UserScript==

(function () {
    'use strict';

    let mediaLinks = [];

    // Function to collect media links for Cyberdrop
    function collectCyberdropLinks() {
        const mediaElements = document.querySelectorAll('.image-container.column a.image');
        mediaElements.forEach((el) => {
            const href = el.getAttribute('href');
            if (href) {
                mediaLinks.push(href.startsWith('http') ? href : `https://cyberdrop.me${href}`);
            }
        });
    }

    // Function to collect media links for Files.fm
    function collectFilesFmLinks() {
        const itemElements = document.querySelectorAll('.item.file.image-item a.top_button_download.my_tooltip, .item.file.video-item a.top_button_download.my_tooltip');
        itemElements.forEach((item) => {
            const href = item.getAttribute('href');
            if (href) {
                mediaLinks.push(href.startsWith('http') ? href : `https://files.fm${href}`);
            }
        });
    }

    // Function to collect media links for app.koofr.net (modified for the /content/links/ pattern)
    function collectKoofrLinks() {
        const linkElements = document.querySelectorAll('a[href^="/content/links/"]');
        linkElements.forEach((el) => {
            const href = el.getAttribute('href');
            if (href) {
                mediaLinks.push(`https://app.koofr.net${href}`);
            }
        });
    }

        // Function to collect media links for mega.nz
    function collectMegaNzLinks() {
        const linkElements = document.querySelectorAll('img[src^="blob:https://mega.nz/"]');
        linkElements.forEach((el) => {
            const src = el.getAttribute('src');
            if (src) {
                mediaLinks.push(`https://mega.nz${src}`);
            }
        });
    }

    // Function to detect the site and collect media links accordingly
    function collectMediaLinks() {
        mediaLinks = []; // Clear previous links
        if (window.location.host.includes('cyberdrop.me')) {
            collectCyberdropLinks();
        } else if (window.location.host.includes('files.fm')) {
            collectFilesFmLinks();
        } else if (window.location.host.includes('app.koofr.net')) {
            collectKoofrLinks();
        } else if (window.location.host.includes('mega.nz')) {
            collectMegaNzLinks();
        }
    }

    // Function to display the collected links in a UI
    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 = 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 Links: ${mediaLinks.length}`;
        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.length > 0) {
            displayLinksUI();
        } else {
            alert('No media links found!');
        }
    });

    document.body.appendChild(extractButton);
})();