Direct Download Card

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

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