SOOP 채팅창 아이디 복사 버튼

SOOP 채팅창에 아이디 복사 버튼을 추가합니다.

// ==UserScript==
// @name         SOOP 채팅창 아이디 복사 버튼
// @namespace    https://www.sooplive.co.kr/
// @version      1.1
// @description  SOOP 채팅창에 아이디 복사 버튼을 추가합니다.
// @match        https://play.sooplive.co.kr/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=play.sooplive.co.kr
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.addedNodes.length) {
                mutation.addedNodes.forEach((node) => {
                    if (node.nodeType === 1 && node.classList.contains('chatIct-card')) {
                        addCopyButton(node);
                    }
                });
            }
        });
    });

    observer.observe(document.body, { childList: true, subtree: true });

    function addCopyButton(card) {
        let userId = card.getAttribute('user_id');
        userId = userId.replace(/\(\d+\)/g, ''); // 괄호 안의 숫자를 제거
        const menuList = card.querySelector('.menu-list');

        if (menuList) {
            const copyButton = document.createElement('button');
            copyButton.type = 'button';
            copyButton.id = 'copyUserId';
            copyButton.textContent = '아이디 복사';
            copyButton.addEventListener('click', () => {
                navigator.clipboard.writeText(userId).then(() => {
                    alert('아이디가 복사되었습니다: ' + userId);
                }).catch((err) => {
                    console.error('아이디 복사 실패: ', err);
                });
            });

            const listItem = document.createElement('li');
            listItem.appendChild(copyButton);
            menuList.insertBefore(listItem, menuList.firstChild);
        }
    }
})();

QingJ © 2025

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