Copy Confirmation Feedback

Provides a visual feedback when you copy text using Ctrl+C.

当前为 2025-06-10 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Copy Confirmation Feedback
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Provides a visual feedback when you copy text using Ctrl+C.
// @author       Donff Roodus
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('keydown', function(e) {
        if (e.ctrlKey && e.key === 'c') {
            showCopyFeedback();
        }
    });

    function showCopyFeedback() {
        // Create the feedback element
        let feedbackElement = document.createElement('div');
        feedbackElement.textContent = 'Copied to clipboard!';
        document.body.appendChild(feedbackElement);

        // Style the feedback element
        Object.assign(feedbackElement.style, {
            position: 'fixed',
            top: '20px',
            right: '20px',
            backgroundColor: '#4CAF50',
            color: 'white',
            padding: '15px',
            borderRadius: '5px',
            zIndex: '9999',
            fontSize: '16px',
            opacity: '0',
            transition: 'opacity 0.5s'
        });

        // Animate the feedback
        setTimeout(() => {
            feedbackElement.style.opacity = '1';
        }, 10);

        // Remove the feedback element after a few seconds
        setTimeout(() => {
            feedbackElement.style.opacity = '0';
            setTimeout(() => {
                document.body.removeChild(feedbackElement);
            }, 500);
        }, 2000);
    }
})();