// ==UserScript== // @name TMDB 한국 지원 강화 // @namespace http://tampermonkey.net/ // @version 1.2.12 // @description TMDB 영화/TV 시리즈 페이지에 한국어, 영어, 원어 제목 추가, 개별 클립보드 복사 기능, 한국 시청등급 및 제작국 표시 // @match https://www.themoviedb.org/* // @grant GM_xmlhttpRequest // @grant GM_addStyle // @author DongHaerang // @downloadURL none // ==/UserScript== // 주의사항: 아래 YOUR_API_KEY 부분을 실제 TMDB API 키로 교체하는 것을 잊지 마세요. const apiKey = "YOUR_API_KEY"; (function() { 'use strict'; GM_addStyle(` .additional-titles { font-size: 1.1em; line-height: 1.4; margin-bottom: 10px; } .additional-title { cursor: pointer; transition: color 0.3s; } .additional-title:hover { color: blue !important; } #additional-info { margin-top: 10px; clear: both; display: flex; align-items: center; width: 100%; } #production-countries { font-size: inherit; margin-right: 20px; } #external-links { font-size: inherit; } #external-links a { margin-right: 10px; text-decoration: none; color: inherit; transition: color 0.3s; } #external-links a:hover { color: blue; } .title-label { cursor: pointer; transition: color 0.3s; } .title-label:hover { color: blue !important; } .ko-title-text { cursor: pointer; text-decoration: none; transition: color 0.3s; } .ko-title-text:hover { color: blue !important; } .main-link { cursor: pointer; text-decoration: none; transition: color 0.3s; } .main-link:hover { color: blue !important; } .en-original-link { cursor: pointer; text-decoration: none; transition: color 0.3s; } .en-original-link:hover { color: blue !important; } .type-link { cursor: pointer; text-decoration: none; transition: color 0.3s; margin: 0 5px; } .type-link:hover { color: blue !important; } `); const copyToClipboard = text => { navigator.clipboard.writeText(text).then(() => { showTemporaryMessage(`${text} 클립보드에 복사됨`); }); }; const showTemporaryMessage = message => { const messageElement = document.createElement('div'); Object.assign(messageElement.style, { position: 'fixed', top: '10px', left: '50%', transform: 'translateX(-50%)', backgroundColor: 'rgba(0, 0, 0, 0.7)', color: 'white', padding: '10px', borderRadius: '5px', zIndex: '9999' }); messageElement.textContent = message; document.body.appendChild(messageElement); setTimeout(() => document.body.removeChild(messageElement), 1000); }; // 국가 코드를 한글로 변환하는 함수 const translateCountry = (englishName) => { const countryMap = { 'United States of America': '미국', 'United Kingdom': '영국', 'South Korea': '한국', 'Japan': '일본', 'China': '중국', 'France': '프랑스', 'Germany': '독일', 'Italy': '이탈리아', 'Spain': '스페인', 'Canada': '캐나다', 'Australia': '호주', 'Russia': '러시아', 'India': '인도', 'Brazil': '브라질', 'Mexico': '멕시코', 'Netherlands': '네덜란드', 'Belgium': '벨기에', 'Sweden': '스웨덴', 'Denmark': '덴마크', 'Norway': '노르웨이', 'Finland': '핀란드', 'Poland': '폴란드', 'Turkey': '터키', 'Thailand': '태국', 'Vietnam': '베트남', 'Indonesia': '인도네시아', 'Malaysia': '말레이시아', 'Singapore': '싱가포르', 'Philippines': '필리핀', 'Taiwan': '대만', 'Hong Kong': '홍콩', 'New Zealand': '뉴질랜드' }; return countryMap[englishName] || englishName; }; const getIdAndType = () => { const [, type, id] = window.location.pathname.split('/'); return { id: id?.split('-')[0], type }; }; const goToMainPage = () => { const currentUrl = window.location.href; const mainUrl = currentUrl.split('-')[0]; window.location.href = mainUrl; }; const getCountryPrefix = (country) => { const countryName = translateCountry(country); if (['뉴질랜드', '미국', '캐나다', '호주'].includes(countryName)) return '영'; if (['대만', '홍콩'].includes(countryName)) return '중'; if (countryName === '멕시코') return '스'; if (countryName === '브라질') return '포'; return countryName.charAt(0); }; const displayTitles = (koTitle, enTitle, originalTitle, type, id, koreanRating, productionCountries, year) => { const titleElement = document.querySelector('.title h2') || document.querySelector('.header .title h2'); if (!titleElement) return; const titleContainer = document.createElement('div'); titleContainer.className = 'additional-titles'; const titleColor = window.getComputedStyle(titleElement).color; const typeText = type === 'tv' ? 'TV' : 'MOVIE'; // 제목에서 특수문자 변환 함수 const formatTitle = (title) => { return title.replace(/:/g, ';').replace(/\?/g, '?'); }; titleContainer.innerHTML = ` 메인 / ${typeText} / 한제: ${koTitle} / 영제+원제 / 영제: ${enTitle} / 원제: ${originalTitle} `; titleElement.parentNode.insertBefore(titleContainer, titleElement); // 이벤트 리스너 수정 titleContainer.querySelector('.type-link').addEventListener('click', function() { let copyText = `${formatTitle(koTitle)} (${year})`; const countryPrefix = getCountryPrefix(productionCountries); if (type === 'tv') { copyText += ` ${countryPrefix}A`; } else { copyText += ` {tmdb-${id}} ${countryPrefix}A`; } if (koreanRating && koreanRating !== '등급미정') { copyText += ` !${koreanRating}`; } copyText += ` $${translateCountry(productionCountries)}`; copyToClipboard(copyText); }); titleContainer.querySelector('.en-original-link').addEventListener('click', function() { copyToClipboard(`[${formatTitle(enTitle)}] [${formatTitle(originalTitle)}]`); }); titleContainer.querySelector('.ko-title-text').addEventListener('click', function() { copyToClipboard(`${formatTitle(koTitle)} (${year})`); }); ['ko-title', 'en-title', 'original-title'].forEach(className => { titleContainer.querySelector(`.${className}`).addEventListener('click', function() { copyToClipboard(formatTitle(this.textContent)); }); }); document.getElementById('en-title-label').addEventListener('click', function() { copyToClipboard(`[${formatTitle(enTitle)}]`); }); document.getElementById('original-title-label').addEventListener('click', function() { copyToClipboard(`[${formatTitle(originalTitle)}]`); }); }; const getKoreanCertification = (data, type) => { const ratings = type === 'movie' ? data.release_dates?.results : data.content_ratings?.results; const koreanRating = ratings?.find(r => r.iso_3166_1 === 'KR')?.release_dates?.[0]?.certification || ratings?.find(r => r.iso_3166_1 === 'KR')?.rating; return koreanRating || '등급미정'; }; const getProductionCountries = (data) => { return data.production_countries?.[0]?.name || '정보 없음'; }; const displayKoreanRating = rating => { if (!rating) return; const factsElement = document.querySelector('.facts'); if (!factsElement) return; let koreanRatingElement = document.getElementById('korean-rating'); if (!koreanRatingElement) { koreanRatingElement = Object.assign(document.createElement('span'), { id: 'korean-rating', style: 'font-size: 1em; margin-right: 10px; font-weight: bold;' }); factsElement.insertBefore(koreanRatingElement, factsElement.firstChild); } koreanRatingElement.textContent = rating; }; const displayAdditionalInfo = (countries, koTitle, imdbId, wikidataId, tvdbId) => { const factsElement = document.querySelector('.facts'); let additionalInfoContainer = document.getElementById('additional-info'); if (!additionalInfoContainer) { additionalInfoContainer = document.createElement('div'); additionalInfoContainer.id = "additional-info"; factsElement.parentNode.insertBefore(additionalInfoContainer, factsElement.nextSibling); additionalInfoContainer.innerHTML = `