// ==UserScript== // @name SOOP 타임 스탬프(라이브 & 다시보기) // @namespace http://tampermonkey.net/ // @version 1.1.1 // @description 숲 라이브 방송의 현재 방송시간, 숲 다시보기 영상의 현재 재생시간 복사를 위한 단축키(Y) 및 버튼. // @author WakViewer // @match https://play.sooplive.co.kr/* // @match https://vod.sooplive.co.kr/player/* // @icon https://www.google.com/s2/favicons?sz=64&domain=www.sooplive.co.kr // @grant unsafeWindow // @grant GM_addStyle // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @run-at document-end // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/521548/SOOP%20%ED%83%80%EC%9E%84%20%EC%8A%A4%ED%83%AC%ED%94%84%28%EB%9D%BC%EC%9D%B4%EB%B8%8C%20%20%EB%8B%A4%EC%8B%9C%EB%B3%B4%EA%B8%B0%29.user.js // @updateURL https://update.greasyfork.icu/scripts/521548/SOOP%20%ED%83%80%EC%9E%84%20%EC%8A%A4%ED%83%AC%ED%94%84%28%EB%9D%BC%EC%9D%B4%EB%B8%8C%20%20%EB%8B%A4%EC%8B%9C%EB%B3%B4%EA%B8%B0%29.meta.js // ==/UserScript== (function() { 'use strict'; // 단축키 설정 (고정: 'Y') const hotkey = 'Y'; // 라이브 전용 코드 if (window.location.href.includes('play.sooplive.co.kr')) { let offset = GM_getValue('offset', 0); GM_registerMenuCommand('시간 오프셋 설정', () => { let newOffset = prompt(`\n몇 초 전 시간을 복사할까요?\n\n[예시]\n60 입력 시, 1:00:00 → 00:59:00`, offset); if (newOffset !== null && !isNaN(newOffset)) { offset = parseInt(newOffset, 10); GM_setValue('offset', offset); showToastMessage(`오프셋이 ${offset}초로 설정되었습니다.`); } else { showToastMessage('숫자만 입력해주세요!'); } }); function formatTimeWithOffset(timeStr, offset) { const [hours, minutes, seconds] = timeStr.split(':').map(Number); let totalSeconds = hours * 3600 + minutes * 60 + seconds - offset; if (totalSeconds < 0) totalSeconds = 0; const newHours = Math.floor(totalSeconds / 3600).toString().padStart(2, '0'); const newMinutes = Math.floor((totalSeconds % 3600) / 60).toString().padStart(2, '0'); const newSeconds = (totalSeconds % 60).toString().padStart(2, '0'); return `${newHours}:${newMinutes}:${newSeconds}`; } function showToastMessage(message, isError = false) { const toastContainer = document.querySelector('#toastMessage'); if (toastContainer) { toastContainer.style.display = ''; const messageElement = toastContainer.querySelector('p'); messageElement.textContent = message; setTimeout(() => { messageElement.textContent = ''; toastContainer.style.display = 'none'; }, 2000); } else { alert(message); // Fallback alert } } // 기존 복사 버튼 제거 const button = document.querySelector('#broadInfo > ul > li.time'); if (button) { button.title = '현재 방송시간 복사 (Y)'; button.style.cursor = 'pointer'; button.addEventListener('click', () => { const time = document.querySelector('#time').innerText; const adjustedTime = formatTimeWithOffset(time, offset); navigator.clipboard.writeText(adjustedTime); showToastMessage(`복사 완료: ${adjustedTime}`); }); } document.addEventListener('keydown', (e) => { if (e.key.toUpperCase() === hotkey) { const time = document.querySelector('#time').innerText; const adjustedTime = formatTimeWithOffset(time, offset); navigator.clipboard.writeText(adjustedTime); showToastMessage(`복사 완료: ${adjustedTime}`); } }); } // 다시보기 전용 코드 if (window.location.href.includes('vod.sooplive.co.kr')) { function showToastMessage(message, isError = false) { const toastContainer = document.querySelector('#toastMessage'); if (toastContainer) { const toastWrapper = document.createElement('div'); const toastContent = document.createElement('p'); toastContent.textContent = message; toastWrapper.appendChild(toastContent); toastContainer.appendChild(toastWrapper); setTimeout(() => { toastContainer.removeChild(toastWrapper); }, 2000); } else { alert(message); } } // 클릭으로 시간 복사 기능 추가 document.addEventListener('click', (event) => { const timeDisplay = event.target.closest('.time_display'); if (timeDisplay) { timeDisplay.title = '현재 재생시간 복사 (Y)'; const timeElement = document.querySelector('.time_display .time-current'); if (timeElement) { const time = timeElement.innerText; navigator.clipboard.writeText(time); showToastMessage(`복사 완료: ${time}`); } else { showToastMessage('시간 정보를 찾을 수 없습니다.', true); } } }); document.addEventListener('keypress', (event) => { if (event.key.toUpperCase() === hotkey) { const timeElement = document.querySelector('.time_display .time-current'); if (timeElement) { const time = timeElement.innerText; navigator.clipboard.writeText(time); showToastMessage(`복사 완료: ${time}`); } else { showToastMessage('시간 정보를 찾을 수 없습니다.', true); } } }); } })();