// ==UserScript== // @name SOOP 채널 프로필 & 배너 이미지 다운로드 // @namespace http://tampermonkey.net/ // @version 2.7 // @description Soop 채널(방송국)의 프로필 이미지와 배너 이미지를 다운로드 // @author WakViewer // @match https://ch.sooplive.co.kr/* // @icon https://res.sooplive.co.kr/afreeca.ico // @grant GM_download // @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.cloud/scripts/521613/SOOP%20%EC%B1%84%EB%84%90%20%ED%94%84%EB%A1%9C%ED%95%84%20%20%EB%B0%B0%EB%84%88%20%EC%9D%B4%EB%AF%B8%EC%A7%80%20%EB%8B%A4%EC%9A%B4%EB%A1%9C%EB%93%9C.user.js // @updateURL https://update.greasyfork.cloud/scripts/521613/SOOP%20%EC%B1%84%EB%84%90%20%ED%94%84%EB%A1%9C%ED%95%84%20%20%EB%B0%B0%EB%84%88%20%EC%9D%B4%EB%AF%B8%EC%A7%80%20%EB%8B%A4%EC%9A%B4%EB%A1%9C%EB%93%9C.meta.js // ==/UserScript== (function() { 'use strict'; let shortcutKey = GM_getValue('shortcutKey', 'Y').toLowerCase(); // Helper function to download an image function downloadImage(url, filename) { GM_download({ url: url, name: filename, onerror: (err) => { console.error(`Failed to download ${filename}:`, err); } }); } // Function to show toast message using Soop's default style function showToast(message) { const toastContainer = document.querySelector('#toastr > div'); if (toastContainer) { const toastMessage = document.createElement('div'); toastMessage.classList.add('warning'); toastMessage.innerHTML = `

${message.replace(/\n/g, '
')}

`; toastContainer.appendChild(toastMessage); setTimeout(() => { toastMessage.remove(); }, 3000); } else { console.warn('Toast container not found!'); } } // Get streamer name for filenames function getStreamerName() { const nameElement = document.querySelector('#bs-navi > div > article.article_bj_box > section > div > div > h2'); return nameElement ? nameElement.textContent.trim() : 'streamer'; } // Functions to download profile and banner images function downloadProfile() { const streamerName = getStreamerName(); const profileImg = document.querySelector('#bs-navi > div > article.article_bj_box > section > a > div > img'); if (profileImg && profileImg.src) { downloadImage(profileImg.src, `${streamerName} 프로필.jpg`); showToast('프로필 이미지 다운로드 완료!'); } else { showToast('프로필 이미지가 없습니다!'); } } function downloadBanner() { const streamerName = getStreamerName(); const bannerSection = document.querySelector('#bs-contents > article.bs-contents-header.expansion > section.ch-art'); if (bannerSection) { const bannerStyle = getComputedStyle(bannerSection).backgroundImage; const bannerUrl = bannerStyle.match(/url\((['"]?)(https?:\/\/[^\)]+)\1\)/)?.[2] || bannerStyle.match(/url\((['"]?)(\/\/[^\)]+)\1\)/)?.[2]; const defaultBanner = 'https://res.sooplive.co.kr/images/bj/img_ch-default.png'; if (bannerUrl && !bannerUrl.includes(defaultBanner)) { const fullBannerUrl = bannerUrl.startsWith('//') ? 'https:' + bannerUrl : bannerUrl; downloadImage(fullBannerUrl, `${streamerName} 배너.jpg`); showToast('배너 이미지 다운로드 완료!'); } else { showToast('배너 이미지가 없습니다!'); } } else { showToast('배너 이미지가 없습니다!'); } } function downloadBoth() { downloadProfile(); downloadBanner(); } // Shortcut key setting function function setShortcutKey() { const newKey = prompt('새로운 단축키를 입력하세요!\n\n( 예: Y, Ctrl+Y, Alt+Y, F7 )', shortcutKey); if (newKey) { GM_setValue('shortcutKey', newKey.toLowerCase()); shortcutKey = newKey.toLowerCase(); showToast(`단축키 설정 완료: ${newKey}`); } else { showToast('단축키 설정이 취소되었습니다.'); } } // Register the download commands in the GM menu GM_registerMenuCommand('프로필/배너 모두 다운로드', downloadBoth); GM_registerMenuCommand('프로필 이미지만 다운로드', downloadProfile); GM_registerMenuCommand('배너 이미지만 다운로드', downloadBanner); GM_registerMenuCommand('단축키 설정', setShortcutKey); // Shortcut key event listener document.addEventListener('keydown', function(event) { let keyPressed = ''; if (event.ctrlKey) keyPressed += 'ctrl+'; if (event.shiftKey) keyPressed += 'shift+'; if (event.altKey) keyPressed += 'alt+'; keyPressed += event.key.toLowerCase(); if (keyPressed === shortcutKey) { downloadBoth(); } }); })();