DevUploads | Auto download

Get download link from devuploads

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