Thisvid Copy Link Button

Adds copy link buttons to video thumbnails on thisvid.com

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Thisvid Copy Link Button
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds copy link buttons to video thumbnails on thisvid.com
// @license      MIT
// @author       You
// @match        https://*.thisvid.com/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Add CSS
    GM_addStyle(`
        .thumbs-items .info,
        .thumbs-items .percent {
            display: none !important;
        }

        .thumb {
            position: relative !important;
        }

        .copy-link-btn {
            position: absolute !important;
            top: 5px !important;
            right: 5px !important;
            background: rgba(0,0,0,0.7) !important;
            color: white !important;
            border: none !important;
            border-radius: 3px !important;
            padding: 2px 6px !important;
            font-size: 12px !important;
            cursor: pointer !important;
            z-index: 1000 !important;
            display: none !important;
        }

        .thumb:hover .copy-link-btn {
            display: block !important;
        }

        .copy-link-btn:hover {
            background: rgba(0,0,0,0.9) !important;
        }

        .copy-link-btn.copied {
            background: #4CAF50 !important;
        }
    `);

    // Function to add copy buttons
    function addCopyButtons() {
        const thumbs = document.querySelectorAll('.thumbs-items a');
        
        thumbs.forEach(thumb => {
            // Only add button if it doesn't already exist
            if (!thumb.querySelector('.copy-link-btn')) {
                const copyBtn = document.createElement('button');
                copyBtn.className = 'copy-link-btn';
                copyBtn.textContent = '📋';
                copyBtn.title = 'Copy link';
                
                copyBtn.addEventListener('click', async (e) => {
                    e.preventDefault();
                    e.stopPropagation();
                    
                    try {
                        await navigator.clipboard.writeText(thumb.href);
                        copyBtn.textContent = '✓';
                        copyBtn.classList.add('copied');
                        
                        setTimeout(() => {
                            copyBtn.textContent = '📋';
                            copyBtn.classList.remove('copied');
                        }, 1000);
                    } catch (err) {
                        console.error('Failed to copy:', err);
                    }
                });

                // Add button to the thumbnail container
                const thumbContainer = thumb.querySelector('.thumb');
                if (thumbContainer) {
                    thumbContainer.appendChild(copyBtn);
                }
            }
        });
    }

    // Initial setup
    addCopyButtons();

    // Watch for dynamic content changes
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.addedNodes.length) {
                addCopyButtons();
            }
        });
    });

    // Start observing the document for added nodes
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})();