DevUploads | Auto download

Get download link from devuploads

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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