Direct Download Card

Creates a card top right Corner to Include all Files without timer

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Direct Download Card
// @namespace    SWScripts
// @match        https://www.cgtrader.com/items/*/download-page
// @grant        GM_addStyle
// @version      v1.0
// @license      MIT
// @description  Creates a card top right Corner to Include all Files without timer
// @author       BN_LOS
// ==/UserScript==

(function() {
    'use strict';

    GM_addStyle(`
        @import url("https://cdn.jsdelivr.net/npm/[email protected]/dist/full.min.css");
    `);
    const tailwindScript = document.createElement('script');
    tailwindScript.src = 'https://cdn.tailwindcss.com';
    document.head.appendChild(tailwindScript);

    const observer = new MutationObserver(() => {
        createDownloadCard();
    });

    observer.observe(document.body, { childList: true, subtree: true });

    function createDownloadCard() {
        const cardTitleElement = document.querySelector('.details-box__title');
        if (!cardTitleElement) return;
        const cardTitle = cardTitleElement.textContent.trim();

        const downloadList = document.querySelector('.details-box__list');
        if (!downloadList) return;

        if (document.getElementById('SWDirectDownloadCard')) return;

        const card = document.createElement('div');
        card.id = 'SWDirectDownloadCard';
        card.className = "card bg-base-200 shadow-xl fixed top-10 right-10 w-fit max-w-[300px]";

        const cardBody = document.createElement('div');
        cardBody.className = "card-body";
        card.appendChild(cardBody);

        const titleElement = document.createElement('h3');
        titleElement.className = "card-title text-white";
        titleElement.textContent = `SWCards - ${cardTitle}`;
        cardBody.appendChild(titleElement);

        const listItems = downloadList.querySelectorAll('li');
        listItems.forEach(item => {
            const buttonTitle = item.textContent.trim().replace(/Download$/, "");
            const downloadLink = item.querySelector('a[href*="/free-downloads/"]');

            if (downloadLink) {
                const button = document.createElement('button');
                button.className = "btn btn-outline w-full";
                button.textContent = buttonTitle;
                button.onclick = () => {
                    if (downloadLink.classList.contains('js-auth-control')) {
                        downloadLink.click();
                        return;
                    }
                    window.location.href = downloadLink.href;
                };
                cardBody.appendChild(button);
            }
        });

        document.body.appendChild(card);
    }
})();// ==UserScript==
// @name         Direct Download Card
// @namespace    SWScripts
// @match        https://www.cgtrader.com/items/*
// @grant        GM_addStyle
// @version      0.9
// @description  Create a daisyUI styled card with download buttons and white title
// @author       BN_LOS, Refined by Stack Overflow user
// ==/UserScript==

(function() {
    'use strict';

    GM_addStyle(`
        @import url("https://cdn.jsdelivr.net/npm/[email protected]/dist/full.min.css");
        #SWDirectDownloadCard .card-title { @apply text-white; }
    `);

    const tailwindScript = document.createElement('script');
    tailwindScript.src = 'https://cdn.tailwindcss.com';
    document.head.appendChild(tailwindScript);

    const observer = new MutationObserver(createDownloadCard);
    observer.observe(document.body, { childList: true, subtree: true });

    function createDownloadCard() {
        const cardTitleElement = document.querySelector('.details-box__title');
        if (!cardTitleElement || document.getElementById('SWDirectDownloadCard')) return;
        const cardTitle = cardTitleElement.textContent.trim();
        const downloadList = document.querySelector('.details-box__list');
        if (!downloadList) return;

        const card = document.createElement('div');
        card.id = 'SWDirectDownloadCard';
        card.className = "card bg-base-200 shadow-xl fixed top-10 right-10 w-fit max-w-[300px]";

        const cardBody = document.createElement('div');
        cardBody.className = "card-body";
        card.appendChild(cardBody);

        const titleElement = document.createElement('h3');
        titleElement.className = "card-title";
        titleElement.textContent = `SWCards - ${cardTitle}`;
        cardBody.appendChild(titleElement);

        downloadList.querySelectorAll('li').forEach(item => {
            const buttonTitle = item.textContent.trim().replace(/Download$/, "");
            const downloadLink = item.querySelector('a[href*="/free-downloads/"]');

            if (downloadLink) {
                const button = document.createElement('button');
                button.className = "btn btn-outline w-full";
                button.textContent = buttonTitle;
                button.onclick = () => {
                    if (downloadLink.classList.contains('js-auth-control')) downloadLink.click();
                    else window.location.href = downloadLink.href;
                };
                cardBody.appendChild(button);
            }
        });

        document.body.appendChild(card);
    }
})();