DevUploads | Auto download

Get download link from devuploads

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name           DevUploads | Auto download
// @name:vi        DevUploads | Tự động tải
// @namespace      DevUploads
// @version        25.02.13.c
// @description    Get download link from devuploads
// @description:vi Tự động lấy link tải file từ DevUploads
// @author         https://t.me/DariasLuc
// @icon           https://www.google.com/s2/favicons?sz=128&domain=devuploads.com
// @homepage       https://xem.li/DevUl
// @match          https://djxmaza.in/*
// @match          https://gujjukhabar.in/*
// @match          https://devuploads.com/*
// @grant          none
// ==/UserScript==

(function() {
    'use strict';

    function createLogPanel() {
        const logPanel = document.createElement('div');
        logPanel.id = 'logPanel';
        logPanel.style.position = 'fixed';
        logPanel.style.bottom = '10px';
        logPanel.style.left = '10px';
        logPanel.style.padding = '10px';
        logPanel.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
        logPanel.style.color = 'white';
        logPanel.style.fontSize = '12px';
        logPanel.style.zIndex = '999999';
        logPanel.style.maxWidth = '300px';
        logPanel.style.overflow = 'hidden';
        logPanel.style.borderRadius = '5px';
        logPanel.innerHTML = '<b>Auto Download Log</b><br>';
        document.body.appendChild(logPanel);
    }

    function logMessage(message) {
        const logPanel = document.getElementById('logPanel');
        if (logPanel) {
            logPanel.innerHTML += message + '<br>';
            logPanel.scrollTop = logPanel.scrollHeight;
        }
    }

    function waitForElement(selector, callback) {
        const observer = new MutationObserver((mutations, obs) => {
            const element = document.querySelector(selector);
            if (element) {
                obs.disconnect();
                callback(element);
            }
        });
        observer.observe(document.body, { childList: true, subtree: true });
    }

    function protectElements() {
        const style = document.createElement('style');
        style.textContent = `
            #dlndiv {
                display: block !important;
                visibility: visible !important;
                opacity: 1 !important;
                position: relative !important;
                z-index: 999999 !important;
            }
            #dlndiv img {
                display: block !important;
                visibility: visible !important;
                opacity: 1 !important;
            }
        `;
        document.head.appendChild(style);
    }

    function findDownloadLink() {
        const scripts = document.scripts;
        for (let script of scripts) {
            if (script.textContent.includes(".devuploads.com/d")) {
                const match = script.textContent.match(/https?:\/\/[^\s"']+\.devuploads\.com\/d\/[^\s"']+/);
                if (match) {
                    const downloadLink = match[0];
                    logMessage("Tìm thấy link tải: " + downloadLink);

                    const downloadImage = document.querySelector("#dlndiv img");
                    if (downloadImage) {
                        downloadImage.onclick = () => window.open(downloadLink, '_self');
                    }

                    window.location.href = downloadLink;
                    return;
                }
            }
        }
    }

    function runScript() {
        waitForElement('#gdl', (gdlButton) => {
            gdlButton.click();
            logMessage("Đã click nút 'Generate Download Link'");

            waitForElement('#gdlf', (gdlfButton) => {
                gdlfButton.click();
                logMessage("Đã click nút 'Go to Generated Link'");
            });
        });
    }

    function autoRun() {
        document.addEventListener("visibilitychange", () => {
            if (!document.hidden) {
                logMessage("Tab active, chạy lại script...");
                findDownloadLink();
                runScript();
            }
        });
    }

    createLogPanel();
    protectElements();
    findDownloadLink();
    runScript();
    autoRun();
})();