Dunamis Multi Downloader

Download High Quality music from Amazon, Qobuz, Deezer, Tidal, SoundCloud, and Apple Music.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name         Dunamis Multi Downloader
// @namespace    https://dunamis.local/
// @version      26.0
// @description  Download High Quality music from Amazon, Qobuz, Deezer, Tidal, SoundCloud, and Apple Music.
// @author       Dunamis
// @license      MIT
// @homepage     https://dunamiss.xyz
// @supportURL   https://dunamiss.xyz
// @match        *://music.amazon.co.uk/*
// @match        *://music.amazon.com/*
// @match        *://*.qobuz.com/*
// @match        *://*.deezer.com/*
// @match        *://*.yandex.com/music/*
// @match        *://music.yandex.ru/*
// @match        *://*.youtube.com/*
// @match        *://soundcloud.com/*
// @match        *://music.apple.com/*
// @match        *://*.tidal.com/*
// @match        *://lucida.to/*
// @match        *://music.binimum.org/*
// @match        *://spotubedl.com/*
// @match        *://am-dl.pages.dev/*
// @match        *://tidal.squid.wtf/*
// @match        *://scloudplaylistdownloader.app/*
// @match        *://aaplmusicdownloader.com/*
// @grant        GM_openInTab
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    const CONFIG = {
        btnId: "dunamis-float-btn",
        menuId: "dunamis-menu",
        zIndex: 9999999,
        sites: {
            lucida: "https://lucida.to/",
            binimum: "https://music.binimum.org/",
            amDL: "https://am-dl.pages.dev/",
            aaplDL: "https://aaplmusicdownloader.com/",
            tidalSquid: "https://tidal.squid.wtf/",
            scloudDL: "https://scloudplaylistdownloader.app/en1/",
        }
    };

    const SiteHandler = {
        detect: () => {
            const h = location.host;
            if (h.includes("amazon")) return "amazon";
            if (h.includes("qobuz.com")) return "qobuz";
            if (h.includes("deezer.com")) return "deezer";
            if (h.includes("yandex")) return "yandex";
            if (h.includes("youtube.com")) return "youtube";
            if (h.includes("soundcloud.com")) return "soundcloud";
            if (h.includes("apple.com")) return "apple";
            if (h.includes("tidal.com")) return "tidal";
            if (h.includes("lucida.to")) return "dl_lucida";
            if (h.includes("aaplmusicdownloader.com")) return "dl_aapl";
            if (h.includes("tidal.squid.wtf")) return "dl_tidalsquid";
            if (h.includes("scloudplaylistdownloader.app")) return "dl_scloud";
            if (h.includes("binimum.org")) return "dl_binimum";
            return "other";
        },
        getThemeColor: () => {
            const site = SiteHandler.detect();
            const colors = {
                amazon: "#00A8E1",
                qobuz: "#24b2f5",
                deezer: "#a238ff",
                yandex: "#ffcc00",
                youtube: "#ff0000",
                soundcloud: "#ff5500",
                apple: "#fa243c",
                tidal: "#00ffff"
            };
            return colors[site] || "#7b2cff";
        }
    };

    function safeOpen(url) {
        if (typeof GM_openInTab === "function") {
            GM_openInTab(url, { active: true, insert: true });
        } else {
            window.open(url, "_blank", "noopener");
        }
    }

    function runAutofill() {
        const site = SiteHandler.detect();
        if (!site.startsWith("dl_")) return;
        const params = new URLSearchParams(window.location.search);
        const term = params.get("url") || params.get("q");
        if (!term) return;

        const fillInterval = setInterval(() => {
            const input = document.querySelector("input#url, input[name='url'], input[placeholder*='Link'], input[placeholder*='URL'], .search-input, input[type='text']");
            if (input && input.offsetParent !== null) {
                input.focus();
                input.value = term;
                input.dispatchEvent(new Event('input', { bubbles: true }));
                setTimeout(() => {
                    const btn = document.querySelector("button#fetch-button, button[type='submit'], .btn-primary, #download-btn, button.search-button, button.go-button");
                    if (btn) btn.click();
                }, 500);
                clearInterval(fillInterval);
            }
        }, 1000);
    }

    function createInterface() {
        if (document.getElementById(CONFIG.btnId)) return;
        const color = SiteHandler.getThemeColor();
        const style = document.createElement("style");
        style.textContent = `
            #${CONFIG.btnId} { position: fixed; bottom: 30px; right: 30px; width: 56px; height: 56px; background: ${color}; border-radius: 50%; box-shadow: 0 4px 15px rgba(0,0,0,0.4); cursor: pointer; z-index: ${CONFIG.zIndex}; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; }
            #${CONFIG.btnId}:hover { transform: scale(1.1); }
            #${CONFIG.menuId} { position: fixed; bottom: 100px; right: 30px; width: 260px; background: #111; color: #fff; border-radius: 12px; display: none; z-index: ${CONFIG.zIndex}; border: 1px solid #333; font-family: 'Segoe UI', sans-serif; overflow: hidden; box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
            #${CONFIG.menuId}.active { display: block; }
            .dunamis-item { padding: 14px; border-bottom: 1px solid #222; cursor: pointer; transition: 0.2s; }
            .dunamis-item:hover { background: #222; }
            .dunamis-label { font-size: 14px; font-weight: bold; display: block; margin-bottom: 2px; }
            .dunamis-desc { font-size: 10px; color: #aaa; }
        `;
        document.head.appendChild(style);

        const btn = document.createElement("div");
        btn.id = CONFIG.btnId;
        btn.innerHTML = '<svg viewBox="0 0 24 24" width="28" height="28" fill="white"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg>';
        document.body.appendChild(btn);

        const menu = document.createElement("div");
        menu.id = CONFIG.menuId;
        document.body.appendChild(menu);

        btn.onclick = (e) => { 
            e.stopPropagation(); 
            menu.classList.toggle("active"); 
            if (menu.classList.contains("active")) renderMenu(); 
        };

        document.addEventListener('click', () => menu.classList.remove("active"));

        function renderMenu() {
            menu.innerHTML = "";
            const site = SiteHandler.detect();
            const currentUrl = window.location.href;
            const items = [];

            if (["amazon", "qobuz", "deezer", "yandex"].includes(site)) {
                items.push({ label: "✨ Lucida", desc: "FLAC / High Quality", action: () => safeOpen(CONFIG.sites.lucida + "?url=" + encodeURIComponent(currentUrl)) });
            } else if (site === "apple") {
                items.push({ label: "🍎 AM-DL", desc: "Web Bridge", action: () => safeOpen(CONFIG.sites.amDL + "?url=" + encodeURIComponent(currentUrl)) });
                items.push({ label: "🛡️ AAPL DL Backup", desc: "256K M4A", action: () => safeOpen(CONFIG.sites.aaplDL + "?url=" + encodeURIComponent(currentUrl)) });
            } else if (site === "tidal") {
                items.push({ label: "🐙 Tidal Squid", desc: "Studio Quality", action: () => safeOpen(CONFIG.sites.tidalSquid + "?url=" + encodeURIComponent(currentUrl)) });
                items.push({ label: "✨ Lucida Backup", desc: "FLAC Support", action: () => safeOpen(CONFIG.sites.lucida + "?url=" + encodeURIComponent(currentUrl)) });
            } else if (site === "youtube") {
                items.push({ label: "🚀 Binimum", desc: "Title Search", action: () => safeOpen(CONFIG.sites.binimum + "?q=" + encodeURIComponent(document.title.replace("- YouTube", "").trim())) });
            } else if (site === "soundcloud") {
                items.push({ label: "☁️ SoundCloud DL", desc: "Go+ Support", action: () => safeOpen(CONFIG.sites.scloudDL + "?url=" + encodeURIComponent(currentUrl)) });
                items.push({ label: "✨ Lucida Backup", desc: "High Quality", action: () => safeOpen(CONFIG.sites.lucida + "?url=" + encodeURIComponent(currentUrl)) });
            }

            if (items.length === 0) {
                menu.innerHTML = '<div class="dunamis-item" style="cursor:default;"><span class="dunamis-label">No downloaders for this site</span></div>';
            }

            items.forEach(i => {
                const el = document.createElement("div");
                el.className = "dunamis-item";
                el.innerHTML = `<span class="dunamis-label">${i.label}</span><span class="dunamis-desc">${i.desc}</span>`;
                el.onclick = i.action;
                menu.appendChild(el);
            });
        }
    }

    if (SiteHandler.detect().startsWith("dl_")) runAutofill();
    else createInterface();

    let lastUrl = location.href;
    setInterval(() => { 
        if (location.href !== lastUrl) { 
            lastUrl = location.href; 
            createInterface(); 
        } 
    }, 2000);
})();