EromeDL

Download videos from EROME with ease, bypassing download restrictions.

Versión del día 29/12/2024. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         EromeDL
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Download videos from EROME with ease, bypassing download restrictions.
// @author       BLOCKCHAIN021
// @match        https://*.erome.com/*
// @grant        GM_download
// @grant        GM_xmlhttpRequest
// @icon         https://cdn.statically.io/img/i2.wp.com/whatdoesmean.net/wp-content/uploads/2023/09/icon.png
// @license      MIT
// ==/UserScript==


(function () {
    'use strict';

    // Helper function to create styled buttons
    function createButton(text, onClick) {
        const button = document.createElement('button');
        button.textContent = text;
        button.style.position = 'absolute';
        button.style.bottom = '10px';
        button.style.right = '10px';
        button.style.zIndex = '1000';
        button.style.padding = '12px 18px';
        button.style.backgroundColor = '#28a745';
        button.style.color = '#fff';
        button.style.border = 'none';
        button.style.borderRadius = '8px';
        button.style.fontSize = '16px';
        button.style.cursor = 'pointer';
        button.style.boxShadow = '0px 5px 10px rgba(0, 0, 0, 0.2)';
        button.addEventListener('mouseover', () => {
            button.style.backgroundColor = '#218838';
        });
        button.addEventListener('mouseout', () => {
            button.style.backgroundColor = '#28a745';
        });
        button.onclick = onClick;
        return button;
    }

    // Function to add download buttons to videos
    function addDownloadButtons() {
        const videos = document.querySelectorAll('video');
        videos.forEach(video => {
            if (!video.parentNode.querySelector('.download-button')) {
                const downloadButton = createButton('Download', () => downloadVideo(video));
                downloadButton.className = 'download-button';
                video.parentNode.style.position = 'relative'; // Ensure parent has relative position for button placement
                video.parentNode.appendChild(downloadButton);
            }
        });
    }

    // Function to download video
    function downloadVideo(video) {
        let videoUrl = '';

        // Attempt to get URL from <source> tag
        const sourceTag = video.querySelector('source');
        if (sourceTag && sourceTag.src) {
            videoUrl = sourceTag.src;
        }

        // Fallback: Try direct video attributes
        if (!videoUrl) {
            videoUrl = video.src || video.getAttribute('data-src') || '';
        }

        // Advanced Fallback: Attempt to fetch video URL via GM_xmlhttpRequest
        if (!videoUrl) {
            const videoId = video.id;
            const config = video.getAttribute('data-setup');
            if (config) {
                try {
                    const parsedConfig = JSON.parse(config.replace(/&quot;/g, '"'));
                    if (parsedConfig.poster) {
                        videoUrl = parsedConfig.poster.replace(/\.jpg$/, '_720p.mp4');
                    }
                } catch (e) {
                    console.error('Failed to parse video config:', e);
                }
            }
        }

        // Log the URL to the console for debugging
        console.log('Video URL:', videoUrl);

        // If URL is found, attempt download
        if (videoUrl) {
            openVideoInNewTab(videoUrl);
        } else {
            alert('Could not locate the video URL. Please ensure the video is loaded.');
        }
    }

    // Function to open video in a new tab with styling
    function openVideoInNewTab(videoUrl) {
        const newWindow = window.open('', '_blank');
        newWindow.document.write(`
            <html>
                <head>
                    <title>Video</title>
                    <style>
                        body {
                            margin: 0;
                            background-color: black;
                            display: flex;
                            justify-content: center;
                            align-items: center;
                            height: 100vh;
                        }
                        video {
                            max-width: 90%;
                            max-height: 90%;
                            object-fit: contain;
                        }
                    </style>
                </head>
                <body>
                    <video controls autoplay>
                        <source src="${videoUrl}" type="video/mp4">
                        Your browser does not support the video tag.
                    </video>
                </body>
            </html>
        `);
    }

    // Observe DOM changes to dynamically add buttons
    const observer = new MutationObserver(() => addDownloadButtons());
    observer.observe(document.body, { childList: true, subtree: true });

    // Initial call to add buttons
    addDownloadButtons();
})();