Advanced Clipboard Manager

Son 10 kopyalamayı saklar ve hızlı erişim sağlar.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Advanced Clipboard Manager
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Son 10 kopyalamayı saklar ve hızlı erişim sağlar.
// @author       Mustafa Hakan
// @match        *://*/*
// @grant        GM_addStyle
// @grant        GM_setClipboard
// @grant        GM_getValue
// @grant        GM_setValue
// ==/UserScript==

(function() {
    'use strict';

    GM_addStyle(`
        #clip-panel {
            position: fixed;
            top: 50%;
            right: 0;
            transform: translateY(-50%);
            z-index: 2147483647;
            background: #1a1a1b;
            border: 1px solid #343435;
            border-right: none;
            border-radius: 8px 0 0 8px;
            width: 250px;
            transition: all 0.3s ease;
            font-family: sans-serif;
            box-shadow: -4px 0 15px rgba(0,0,0,0.5);
            display: flex;
            flex-direction: column;
            max-height: 80vh;
            margin-right: -250px;
        }
        #clip-panel.open {
            margin-right: 0;
        }
        #clip-handle {
            position: absolute;
            left: -35px;
            top: 50%;
            transform: translateY(-50%);
            width: 35px;
            height: 60px;
            background: #1a1a1b;
            border: 1px solid #343435;
            border-right: none;
            border-radius: 8px 0 0 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 20px;
        }
        #clip-list {
            overflow-y: auto;
            padding: 10px;
            flex-grow: 1;
        }
        .clip-item {
            background: #272729;
            padding: 8px 12px;
            margin-bottom: 8px;
            border-radius: 4px;
            font-size: 12px;
            color: #d7dadc;
            cursor: pointer;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            transition: background 0.2s;
            border: 1px solid transparent;
        }
        .clip-item:hover {
            background: #343435;
            border-color: #444;
        }
        #clip-header {
            padding: 10px;
            border-bottom: 1px solid #343435;
            font-size: 13px;
            font-weight: bold;
            color: #fff;
            text-align: center;
        }
    `);

    let history = GM_getValue('clipHistory', []);

    const saveHistory = (text) => {
        if (!text || text === history[0]) return;
        history.unshift(text);
        if (history.length > 10) history.pop();
        GM_setValue('clipHistory', history);
        renderList();
    };

    const renderList = () => {
        const list = document.getElementById('clip-list');
        if (!list) return;
        list.innerHTML = '';
        history.forEach((text) => {
            const item = document.createElement('div');
            item.className = 'clip-item';
            item.innerText = text;
            item.title = text;
            item.onclick = () => {
                GM_setClipboard(text);
                document.getElementById('clip-panel').classList.remove('open');
            };
            list.appendChild(item);
        });
    };

    const panel = document.createElement('div');
    panel.id = 'clip-panel';
    panel.innerHTML = `
        <div id="clip-handle">📋</div>
        <div id="clip-header">Kopyalananlar</div>
        <div id="clip-list"></div>
    `;

    document.body.appendChild(panel);
    renderList();

    panel.querySelector('#clip-handle').onclick = () => {
        panel.classList.toggle('open');
    };

    document.addEventListener('copy', () => {
        setTimeout(async () => {
            const text = await navigator.clipboard.readText();
            saveHistory(text);
        }, 100);
    });

})();