Scat.Gold Doodstream Copy Button

Adds a button to copy the Doodstream link (first) and then the page title (after delay) on scat.gold

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Scat.Gold Doodstream Copy Button
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Adds a button to copy the Doodstream link (first) and then the page title (after delay) on scat.gold
// @author       Your Name
// @match        *://scat.gold/*
// @grant        GM_setClipboard
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Inject styles
    const style = document.createElement('style');
    style.textContent = `
        .copy-dood-btn {
            position: fixed;
            top: 20px;
            right: 20px;
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            z-index: 9999;
            font-size: 14px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
            transition: background-color 0.3s;
        }

        .copy-dood-btn:hover {
            background-color: #45a049;
        }

        .copy-dood-btn.success {
            background-color: #45a049;
        }

        .copy-dood-btn.error {
            background-color: #f44336;
        }

        .copy-notification {
            position: fixed;
            top: 70px;
            right: 20px;
            padding: 10px 20px;
            border-radius: 5px;
            color: white;
            z-index: 9999;
            font-size: 14px;
            opacity: 0;
            transition: opacity 0.3s;
        }

        .copy-notification.show {
            opacity: 1;
        }
    `;
    document.head.appendChild(style);

    // Add button
    const button = document.createElement('button');
    button.className = 'copy-dood-btn';
    button.textContent = 'Copy Doodstream';
    document.body.appendChild(button);

    // Add notification
    const notification = document.createElement('div');
    notification.className = 'copy-notification';
    document.body.appendChild(notification);

    function showNotification(message, isSuccess) {
        notification.textContent = message;
        notification.style.backgroundColor = isSuccess ? '#4CAF50' : '#f44336';
        notification.classList.add('show');
        setTimeout(() => {
            notification.classList.remove('show');
        }, 2000);
    }

    function findDoodstreamIframe() {
        const doodHeading = Array.from(document.getElementsByClassName('tabtitle')).find(heading =>
            heading.textContent.toLowerCase().includes('doodstream')
        );

        if (doodHeading) {
            let currentElement = doodHeading;
            while (currentElement && !currentElement.classList.contains('tabcontent')) {
                currentElement = currentElement.nextElementSibling;
            }

            if (currentElement) {
                return currentElement.querySelector('iframe');
            }
        }

        return document.querySelector('iframe[src*="dood"], iframe[src*="d0o0d"], iframe[src*="ds2play"]');
    }

    button.addEventListener('click', () => {
        try {
            const iframe = findDoodstreamIframe();

            if (iframe && iframe.src) {
                // Copy link immediately
                GM_setClipboard(iframe.src);
                button.classList.add('success');
                showNotification('Link copied!', true);
                setTimeout(() => button.classList.remove('success'), 1000);

                // After 1 second, overwrite with link + title
                setTimeout(() => {
                    const pageTitle = document.title;
                    GM_setClipboard(pageTitle);
                }, 1000);
            } else {
                button.classList.add('error');
                showNotification('No Doodstream link found', false);
                setTimeout(() => button.classList.remove('error'), 1000);
            }
        } catch (error) {
            button.classList.add('error');
            showNotification('An error occurred', false);
            setTimeout(() => button.classList.remove('error'), 1000);
        }
    });
})();