Greasy Fork镜像 支持简体中文。

YouTube: Copy Comment Link

You can conveniently copy the link of any comment and send it to your friend

目前為 2023-08-25 提交的版本,檢視 最新版本

// ==UserScript==
// @name         YouTube: Copy Comment Link
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  You can conveniently copy the link of any comment and send it to your friend
// @author       Grihail
// @match        *://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      CC-BY
// ==/UserScript==

function addCopyLinkToHeaderAuthor() {
    const headerAuthorElements = document.querySelectorAll('#header-author.ytd-comment-renderer');

    headerAuthorElements.forEach(element => {
        const copyLink = element.querySelector('.copy-comment-link');

        if (!copyLink) {
            const ytFormattedString = element.querySelector('yt-formatted-string a');
            
            if (ytFormattedString) {
                const originalHref = ytFormattedString.getAttribute('href');
                const fullHref = 'https://www.youtube.com' + originalHref;
                
                const copyLink = document.createElement('a');
                copyLink.classList.add('copy-comment-link');
                copyLink.href = fullHref;
                copyLink.style.marginLeft = '10px';
                copyLink.style.width = '24px';
                copyLink.style.height = '24px';
                copyLink.innerHTML = '<svg height="100%" viewBox="0 0 36 36" width="100%"><path d="M5.85 18.0c0.0-2.56 2.08-4.65 4.65-4.65h6.0V10.5H10.5c-4.14 .0-7.5 3.36-7.5 7.5s3.36 7.5 7.5 7.5h6.0v-2.85H10.5c-2.56 .0-4.65-2.08-4.65-4.65zM12.0 19.5h12.0v-3.0H12.0v3.0zm13.5-9.0h-6.0v2.85h6.0c2.56 .0 4.65 2.08 4.65 4.65s-2.08 4.65-4.65 4.65h-6.0V25.5h6.0c4.14 .0 7.5-3.36 7.5-7.5s-3.36-7.5-7.5-7.5z" fill="#606060"></path></svg>';

                copyLink.addEventListener('click', event => {
                    event.preventDefault();
                    navigator.clipboard.writeText(fullHref);
                });

                element.style.alignItems = 'center';
                element.appendChild(copyLink);
            }
        }
    });
}

setInterval(addCopyLinkToHeaderAuthor, 1000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址