// ==UserScript== // @name SOOP (숲) - 하이라이트 댓글 자동 생성 // @icon https://www.google.com/s2/favicons?sz=64&domain=www.sooplive.co.kr // @namespace http://tampermonkey.net/ // @version 250223 // @description 댓글 하이라이트 링크를 자동으로 생성하고 복사하는 버튼 추가 (추후 답글 안눌러도 복사 기능 추가 예정) // @author _고기_ // @license _고기_ // @match https://ch.sooplive.co.kr/cns4646 // @downloadURL none // ==/UserScript== (function() { 'use strict'; function generateHighlightLink(commentId) { if (!commentId) { alert("답글을 누른 후 눌러주세요."); return; } let url = window.location.href; let postId = url.match(/post\/(\d+)/); if (!postId) { alert("게시글 ID를 찾을 수 없습니다."); return; } let newUrl = `https://ch.sooplive.co.kr/${window.location.pathname.split("/")[1]}/post/${postId[1]}#comment_noti${commentId}`; GM_setClipboard(newUrl); alert("하이라이트 댓글이 복사되었습니다."); } function getCommentId(comment) { let replyButton = comment.querySelector("button[data-action='reply']"); if (replyButton) { replyButton.click(); // 자동으로 답글 클릭 let observer = new MutationObserver(mutations => { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.id && node.id.startsWith("reply_write_form_")) { let match = node.id.match(/reply_write_form_(\d+)_input/); if (match) { generateHighlightLink(match[1]); } replyButton.click(); // 답글 창 닫기 observer.disconnect(); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); } else { let replyInput = comment.querySelector("div[id^='reply_write_form_']"); if (replyInput) { let match = replyInput.id.match(/reply_write_form_(\d+)_input/); if (match) { generateHighlightLink(match[1]); } } else { alert("답글을 누른 후 눌러주세요"); } } } function addHighlightButtonToMenu(menu, comment) { if (!menu || menu.querySelector(".highlight-btn")) return; let highlightBtn = document.createElement("button"); highlightBtn.innerHTML = "하이라이트"; highlightBtn.className = "highlight-btn"; highlightBtn.style.backgroundColor = getComputedStyle(menu.querySelector("button")).backgroundColor; highlightBtn.style.color = getComputedStyle(menu.querySelector("button")).color; highlightBtn.addEventListener("click", () => { getCommentId(comment); }); menu.appendChild(highlightBtn); } function observeMoreLayer() { const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.classList && node.classList.contains("more-layer")) { let comment = node.closest("li"); if (comment) { addHighlightButtonToMenu(node, comment); } } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); } observeMoreLayer(); })();