ott-player / index.html
dongsik22's picture
Claude Opus 4.8 (1M context)
fix(tvchak): ํ†ต๊ณผ ํƒญ ํ† ํฐ ๋งŒ๋ฃŒ ์‹œ ์ž๋™ ์žฌํ†ต๊ณผ โ€” "all paths failed" ๋‹ค์Œํ™” ์žฌ์ƒ ๋ถˆ๊ฐ€ ํ•ด์†Œ
c3f1743
Raw History Blame Contribute Delete
220 kB
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" /> <meta name="theme-color" content="#0f1115" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <title>OTT Player</title> <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="manifest" href="/manifest.webmanifest"> <meta name="theme-color" content="#0f1115"> <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin> <link rel="preload" href="https://cdn.jsdelivr.net/npm/hls.js@1.5.15/dist/hls.min.js" as="script" crossorigin> <script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.15/dist/hls.min.js" defer></script> <link rel="apple-touch-icon" href="/favicon.svg" /> <style> :root { --bg: #0f1115; --panel: #161a22; --panel2: #1d222c; --border: #2a313d; --text: #e6e8ec; --muted: #8a93a6; --accent: #ff5b6a; --accent2: #4ea1ff; --new: #ffb020; --safe-top: env(safe-area-inset-top, 0px); --safe-bot: env(safe-area-inset-bottom, 0px); } * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; } html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; overscroll-behavior: none; } body { min-height: 100dvh; } button { font-family: inherit; } input { font-family: inherit; font-size: 16px; /* iOS ์คŒ ๋ฐฉ์ง€ */ } /* โ”€โ”€โ”€โ”€โ”€ ๊ณตํ†ต ํผ/๋ฒ„ํŠผ โ”€โ”€โ”€โ”€โ”€ */ .btn { background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer; } .btn:active { background: #2a313d; } .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:active { background: #e34758; } .btn.ghost { background: transparent; } .btn.icon { padding: 8px 10px; min-width: 38px; } input.text { background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 12px; outline: none; width: 100%; } input.text:focus { border-color: var(--accent2); } /* โ”€โ”€โ”€โ”€โ”€ ์ƒ๋‹จ ์•ฑ๋ฐ” โ”€โ”€โ”€โ”€โ”€ */ .appbar { position: sticky; top: 0; z-index: 30; background: var(--panel); border-bottom: 1px solid var(--border); padding: calc(8px + var(--safe-top)) 10px 8px; display: flex; align-items: center; gap: 8px; } .appbar h1 { margin: 0; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .appbar h1 small { color: var(--muted); font-weight: normal; font-size: 11px; margin-left: 6px; } .appbar .domain { font-size: 10px; color: #6ee7a8; } .appbar .domain.bad { color: #ff7b7b; } /* โ”€โ”€โ”€โ”€โ”€ ๋น„๋””์˜ค โ”€โ”€โ”€โ”€โ”€ */ .video-wrap { position: relative; background: #000; width: 100%; aspect-ratio: 16/9; } .video-wrap.fill { aspect-ratio: auto; height: 100%; flex: 1; } video { width: 100%; height: 100%; background: #000; display: block; } .video-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; padding: 16px; text-align: center; pointer-events: none; } .video-empty.hide { display: none; } .video-loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: var(--accent2); font-size: 13px; background: rgba(0,0,0,0.6); padding: 8px 12px; border-radius: 6px; } /* ์ƒ๋‹จ ํŽ˜์ด์ง€ ๋กœ๋”ฉ ๋ฐ” โ€” ๋ณด๊ด€ํ•จ ํด๋ฆญ ํ›„ episodes/play ๋กœ๋“œ ํ…€์— ํ‘œ์‹œ */ #topLoader { position: fixed; top: 0; left: 0; right: 0; height: 3px; background: transparent; z-index: 9999; pointer-events: none; opacity: 0; transition: opacity 0.2s; } #topLoader.show { opacity: 1; } #topLoader::before { content: ''; display: block; height: 100%; background: linear-gradient(90deg, transparent, var(--accent), var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: topLoaderSlide 1s linear infinite; box-shadow: 0 0 8px var(--accent); } @keyframes topLoaderSlide { 0% { background-position: -50% 0; } 100% { background-position: 150% 0; } } .rate-toast { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.75); color: #fff; padding: 8px 18px; border-radius: 999px; font-size: 20px; font-weight: 800; font-family: "Bebas Neue", sans-serif; letter-spacing: 0.05em; opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 6; } .rate-toast.show { opacity: 1; } /* ์ผ์‹œ์ •์ง€ ์˜ค๋ฒ„๋ ˆ์ด โ€” ๊ฐ€์šด๋ฐ ํฐ ์žฌ์ƒ๋ฒ„ํŠผ */ .pause-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 96px; height: 96px; border-radius: 50%; background: rgba(0,0,0,0.6); border: 2px solid rgba(255,255,255,0.3); color: #fff; font-size: 40px; padding-left: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 4; backdrop-filter: blur(6px); transition: transform 0.15s, background 0.15s; animation: pauseAppear 0.25s ease-out; } .pause-overlay:hover { transform: translate(-50%, -50%) scale(1.08); background: rgba(229,9,20,0.85); } .pause-overlay[hidden] { display: none; } @keyframes pauseAppear { from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } } /* ์˜คํ”„๋‹/์—”๋”ฉ ์Šคํ‚ต ๋ฒ„ํŠผ - ๋น„๋””์˜ค ์šฐํ•˜๋‹จ(์ปจํŠธ๋กค๋ฐ” ์œ„) */ .skip-btn { position: absolute; bottom: 60px; right: 16px; z-index: 6; background: rgba(0,0,0,0.75); color: #fff; border: 1px solid rgba(255,255,255,0.3); padding: 10px 18px; border-radius: 22px; font-size: 14px; font-weight: 600; cursor: pointer; opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; pointer-events: none; } .skip-btn.show { opacity: 1; transform: translateY(0); pointer-events: auto; } .skip-btn:hover { background: rgba(229,9,20,0.85); border-color: rgba(255,255,255,0.5); } .video-wrap.locked .skip-btn { display: none !important; } @media (max-width: 1023.98px) { .skip-btn { bottom: 50px; right: 12px; padding: 8px 14px; font-size: 13px; } } /* ์˜์ƒ ์šฐ์ƒ๋‹จ โ€” ์ปจํŠธ๋กค๋ฐ”์™€ ๊ฒน์น˜์ง€ ์•Š๊ฒŒ */ .fs-zoom-btn { position: absolute; top: 10px; right: calc(10px + env(safe-area-inset-right, 0px)); z-index: 5; background: rgba(0,0,0,0.55); color: #fff; border: 1px solid rgba(255,255,255,0.2); width: 36px; height: 36px; border-radius: 6px; font-size: 16px; cursor: pointer; opacity: 0; transition: opacity 0.15s; } .fs-zoom-btn:hover { background: rgba(0,0,0,0.75); } /* ํ„ฐ์น˜(hover ์—†์Œ) ํ™˜๊ฒฝ์—์„  ํ•ญ์ƒ ๋ณด์ž„ โ€” ๋ชจ๋ฐ”์ผ/Capacitor WebView ๋“ฑ */ @media (hover: none) { .fs-zoom-btn { opacity: 0.7; } } /* ํ™”๋ฉด ์ž ๊ธˆ ๋ฒ„ํŠผ โ€” ๋ชจ๋ฐ”์ผ ํ’€์Šคํฌ๋ฆฐ์ผ ๋•Œ๋งŒ ์ขŒ์ธก ์ค‘์•™ ํ‘œ์‹œ */ .lock-btn { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); z-index: 2147483646; background: rgba(0,0,0,0.55); color: #fff; border: 1px solid rgba(255,255,255,0.25); width: 48px; height: 48px; border-radius: 50%; font-size: 20px; cursor: pointer; padding: 0; display: none; align-items: center; justify-content: center; opacity: 0.85; transition: opacity 0.15s; } .lock-btn:active { opacity: 1; } /* ํ’€์Šคํฌ๋ฆฐ + ๋ชจ๋ฐ”์ผ/ํ„ฐ์น˜ ํ™˜๊ฒฝ์—์„œ๋งŒ ๋ณด์ด๊ฒŒ */ .video-wrap:fullscreen .lock-btn, .video-wrap:-webkit-full-screen .lock-btn { display: flex; } @media (any-pointer: fine) and (min-width: 1024px) { .video-wrap:fullscreen .lock-btn, .video-wrap:-webkit-full-screen .lock-btn { display: none; } } /* idle(ํ„ฐ์น˜/๋งˆ์šฐ์Šค ๋ฉˆ์ถค) ์‹œ ์ž๋™ ์ˆจ๊น€ โ€” show-controls๊ฐ€ ๋น ์ง€๋ฉด ํŽ˜์ด๋“œ์•„์›ƒ. ์ž ๊ธˆ ํ•ด์ œ ์ƒํƒœ: show-controls ์‹œ ์ง„ํ•˜๊ฒŒ(0.85) ์ž ๊ธˆ ์ƒํƒœ: show-controls ์‹œ ํฌ๋ฏธํ•˜๊ฒŒ(0.25), ๋ˆ„๋ฅด๋ฉด 1. ์‚ฌ์šฉ์ž๊ฐ€ ๋‹ค์‹œ ํƒญํ•˜๋ฉด ๋‹ค์‹œ 0.25๋กœ ์ž ๊น ๋…ธ์ถœ. */ .video-wrap:fullscreen .lock-btn, .video-wrap:-webkit-full-screen .lock-btn { opacity: 0; pointer-events: none; transition: opacity 0.25s ease; } .video-wrap:fullscreen.show-controls .lock-btn, .video-wrap:-webkit-full-screen.show-controls .lock-btn { opacity: 0.85; pointer-events: auto; } .video-wrap:fullscreen.locked.show-controls .lock-btn, .video-wrap:-webkit-full-screen.locked.show-controls .lock-btn { opacity: 0.25; pointer-events: auto; } .video-wrap:fullscreen.locked.show-controls .lock-btn:active, .video-wrap:-webkit-full-screen.locked.show-controls .lock-btn:active { opacity: 1; } /* ์ž ๊ธˆ ์ƒํƒœ: ๋น„๋””์˜ค ์ปจํŠธ๋กค/์คŒ ์ปจํŠธ๋กค/ํ’€์Šคํฌ๋ฆฐ ๋ฒ„ํŠผ ๋“ฑ ๋‹ค ๊ฐ€๋ฆฌ๊ณ  ์ž ๊ธˆ ๋ฒ„ํŠผ๋งŒ ํ™œ์„ฑ */ .video-wrap.locked video::-webkit-media-controls { display: none !important; } /* ๋ธŒ๋ผ์šฐ์ € ๊ธฐ๋ณธ ์ปจํŠธ๋กค๋ฐ”์˜ ์ „์ฒดํ™”๋ฉด ๋ฒ„ํŠผ ์™„์ „ ์ œ๊ฑฐ (controlslist ๋ฌด์‹œํ•˜๋Š” ๋ธŒ๋ผ์šฐ์ € ๋Œ€์‘) */ #player::-webkit-media-controls-fullscreen-button { display: none !important; } #player::-internal-media-controls-fullscreen-button { display: none !important; } /* ์˜์ƒ ์œ„ ๊ธธ๊ฒŒ๋ˆ„๋ฅด๊ธฐ ์‹œ '๋‹ค๋ฅธ ์ด๋ฆ„์œผ๋กœ ์ €์žฅ' / ํ…์ŠคํŠธ ์„ ํƒ ์ฝœ์•„์›ƒ ์ฐจ๋‹จ (3๋ฐฐ์† hold ์ถฉ๋Œ) */ #player { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; } /* 3๋ฐฐ์† hold ์บก์ฒ˜์šฉ ํˆฌ๋ช… ์˜ค๋ฒ„๋ ˆ์ด โ€” video ์œ„, ์ปจํŠธ๋กค๋ฐ” ์•„๋ž˜ */ .hold-overlay { position: absolute; inset: 0; z-index: 2; background: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; /* touch-action: none โ€” ๋ธŒ๋ผ์šฐ์ € native gesture(ํ•€์น˜/๋”๋ธ”ํƒญ์คŒ/ํŒฌ) ์ „๋ถ€ ๋„๊ณ  ์šฐ๋ฆฌ JS์—์„œ ์ง์ ‘ ์ฒ˜๋ฆฌ. 'manipulation'์€ ํ•€์น˜ ์ž์ฒด๋ฅผ ๋ง‰์•„๋ฒ„๋ ค NG. */ touch-action: none; } .video-wrap.locked .hold-overlay { display: none; } .video-wrap.locked .fs-zoom-btn, .video-wrap.locked .side-toggle-btn, .video-wrap.locked .pause-overlay, .video-wrap.locked .zoom-ctrl { display: none !important; } .video-wrap.locked video { pointer-events: none; } /* .lock-btn ์ž ๊ธˆ opacity๋Š” ์œ„ :fullscreen ๋ธ”๋ก(143~153)์—์„œ show-controls ๊ธฐ๋ฐ˜์œผ๋กœ ๊ด€๋ฆฌ. ์—ฌ๊ธฐ์— ๊ฐ•์ œ 0.25 ๊ทœ์น™์„ ๋‘๋ฉด idle ์‹œ์—๋„ ์‚ฌ๋ผ์ง€์ง€ ์•Š๊ณ , pointer-events:none๊ณผ ๊ฒน์ณ ํ•ด์ œ ํด๋ฆญ๋„ ์•ˆ ๋ฐ›๋Š” ์‚ฌ๊ณ ๊ฐ€ ๋‚œ๋‹ค(2026-05-31 ์‚ฌ๊ณ ). */ .video-wrap:hover .fs-zoom-btn { opacity: 1; } .side-toggle-btn { position: absolute; top: 10px; left: 10px; z-index: 5; background: rgba(0,0,0,0.55); color: #fff; border: 1px solid rgba(255,255,255,0.2); width: 36px; height: 36px; border-radius: 6px; font-size: 14px; cursor: pointer; opacity: 0; transition: opacity 0.15s; } .video-wrap:hover .side-toggle-btn { opacity: 1; } /* ํ’€์Šคํฌ๋ฆฐ์—์„œ๋Š” ์ขŒ์ธก ํŒจ๋„ ์ž์ฒด๊ฐ€ ์—†์œผ๋‹ˆ ํ–„๋ฒ„๊ฑฐ๋„ ์ˆจ๊น€ */ .video-wrap:fullscreen .side-toggle-btn, .video-wrap:-webkit-full-screen .side-toggle-btn { display: none !important; } @media (max-width: 1023.98px) { .side-toggle-btn { display: none; } } .video-wrap:fullscreen { background: #000; width: 100vw; height: 100vh; } .video-wrap:-webkit-full-screen { background: #000; width: 100vw; height: 100vh; } .video-wrap:fullscreen .fs-zoom-btn { opacity: 1; } .video-wrap:fullscreen video { width: 100%; height: 100%; object-fit: contain; position: relative; z-index: 1; } .video-wrap:-webkit-full-screen video { width: 100%; height: 100%; object-fit: contain; position: relative; z-index: 1; } /* ์คŒ ๋ชจ๋“œ ์ „์šฉ ์ปจํŠธ๋กค ์˜ค๋ฒ„๋ ˆ์ด โ€” ๋งˆ์šฐ์Šค ์›€์ง์ผ ๋•Œ๋งŒ ๋ณด์ž„ */ .zoom-ctrl { position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 10px; background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0.4) 80%, transparent); padding: 10px 14px 8px; color: #fff; font-size: 13px; pointer-events: auto; opacity: 0; transition: opacity 0.25s ease; } .zoom-ctrl[hidden] { display: none; } .zoom-ctrl * { pointer-events: auto; } /* ์ผ๋ฐ˜ ๋ชจ๋“œ: ๋งˆ์šฐ์Šค hover ์‹œ ์ปจํŠธ๋กค ํ‘œ์‹œ. show-controls(ํ„ฐ์น˜/ํ’€์Šคํฌ๋ฆฐ) ํด๋ž˜์Šค๋„ ํ‘œ์‹œ. */ .video-wrap:hover .zoom-ctrl, .video-wrap.show-controls .zoom-ctrl { opacity: 1; } /* ํ’€์Šคํฌ๋ฆฐ์ผ ๋• :hover ๊ทœ์น™ ๋ฌดํšจํ™” โ€” show-controls ํด๋ž˜์Šค๋กœ๋งŒ ์ œ์–ด (idle ์‹œ ์ž๋™ ์ˆจ๊น€ ์œ„ํ•ด) */ .video-wrap:fullscreen:hover .zoom-ctrl, .video-wrap:-webkit-full-screen:hover .zoom-ctrl { opacity: 0; } .video-wrap:fullscreen.show-controls .zoom-ctrl, .video-wrap:-webkit-full-screen.show-controls .zoom-ctrl { opacity: 1; } /* ํ’€์Šคํฌ๋ฆฐ์ผ ๋• z-index ์ตœ๋Œ€ (์ž๋ง‰ยท๊ธฐํƒ€ ์œ„) */ .video-wrap:fullscreen .zoom-ctrl, .video-wrap:-webkit-full-screen .zoom-ctrl { z-index: 2147483647; padding: 14px 16px 12px; } /* ํ’€์Šคํฌ๋ฆฐ ์ „์šฉ ๋ฒ„ํŠผ์€ ์ผ๋ฐ˜ ๋ชจ๋“œ์—์„œ ์ˆจ๊น€ */ .zoom-ctrl .zc-fs-only { display: none; } .video-wrap:fullscreen .zoom-ctrl .zc-fs-only, .video-wrap:-webkit-full-screen .zoom-ctrl .zc-fs-only { display: inline-block; } .video-wrap.show-controls { cursor: default; } .video-wrap.hide-cursor { cursor: none; } /* video์— inline cursor: grab์ด ๋ฐ•ํ˜€ ์žˆ์„ ์ˆ˜ ์žˆ์–ด !important๋กœ ๋ฎ์Œ โ€” ํ’€์Šคํฌ๋ฆฐ idle ์‹œ ์†๋ฐ”๋‹ฅ๋„ ์ˆจ๊น€ */ .video-wrap.hide-cursor video { cursor: none !important; } .video-wrap.hide-cursor .fs-zoom-btn { opacity: 0; pointer-events: none; } .zoom-ctrl .zc-btn { background: transparent; border: 0; color: #fff; font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 4px; } .zoom-ctrl .zc-btn:hover { background: rgba(255,255,255,0.15); } .zoom-ctrl .zc-time { font-variant-numeric: tabular-nums; min-width: 100px; font-size: 12px; } .zoom-ctrl .zc-bar { flex: 1; height: 4px; cursor: pointer; accent-color: #e50914; background: rgba(255,255,255,0.3); border-radius: 2px; -webkit-appearance: none; appearance: none; } /* โ‹ฎ ๋”๋ณด๊ธฐ ๋ฉ”๋‰ด โ€” ๋น„๋””์˜ค ์ปจํŠธ๋กค๋ฐ” ์œ„์— ๋–  ์žˆ๋Š” ํŒ์—… */ .more-menu { position: absolute; right: 12px; bottom: 56px; z-index: 11; background: rgba(20,22,28,0.96); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 6px; min-width: 200px; max-width: calc(100vw - 24px); box-sizing: border-box; box-shadow: 0 6px 24px rgba(0,0,0,0.6); } .more-menu *, .more-menu *::before, .more-menu *::after { box-sizing: border-box; } /* PIP + ๋‹ค์šด๋กœ๋“œ ํ•œ ์ค„(2์นธ grid) */ .more-menu .more-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 4px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 4px; } .more-menu .more-actions .more-item { margin-top: 0; border-top: 0; padding: 8px 8px; text-align: center; font-size: 12px; } .more-menu .more-actions .more-item[hidden] { display: none; } /* ๋‹ค์šด๋กœ๋“œ ์ˆจ๊น€ ์ƒํƒœ์ผ ๋•Œ PIP๊ฐ€ ํ•œ ์ค„ ์ „์ฒด ์ฐจ์ง€ */ .more-menu .more-actions:has(> .more-item[hidden]) { grid-template-columns: 1fr; } .more-menu[hidden] { display: none; } .video-wrap:fullscreen .more-menu, .video-wrap:-webkit-full-screen .more-menu { bottom: 60px; z-index: 2147483647; } .more-menu .more-sec { padding: 6px 4px; } .more-menu .more-sec-h { color: #8a93a3; font-size: 11px; padding: 0 6px 4px; } .more-menu .more-rates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; } .more-menu .more-rates button { background: transparent; border: 1px solid rgba(255,255,255,0.1); color: #e3e6eb; font-size: 11px; padding: 4px 0; border-radius: 4px; cursor: pointer; font-variant-numeric: tabular-nums; } .more-menu .more-rates button:hover { background: rgba(255,255,255,0.08); } .more-menu .more-rates button.active { background: #e50914; border-color: #e50914; color: #fff; } .more-menu .more-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: #e3e6eb; font-size: 13px; padding: 8px 10px; border-radius: 4px; cursor: pointer; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 4px; } .more-menu .more-item:hover { background: rgba(255,255,255,0.08); } /* ์Šคํ‚ต ๋งˆํ‚น: ๋ฉ”์ธ ๋ฒ„ํŠผ + ์šฐ์ธก ์ž‘์€ โœ• ์ดˆ๊ธฐํ™” ๋ฒ„ํŠผ ํ•œ ์ค„ */ .more-menu .more-skip-row { display: flex; align-items: stretch; gap: 4px; margin-top: 4px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 4px; } .more-menu .more-skip-row .more-skip-main { flex: 1; border-top: 0; margin-top: 0; display: flex; align-items: center; gap: 8px; } .more-menu .more-skip-row .more-skip-main .lbl { flex: 1; } .more-menu .more-skip-row .more-skip-main .t { color: #ffd54a; font-variant-numeric: tabular-nums; font-size: 12px; } .more-menu .more-skip-row .more-skip-main .t:empty::before { content: 'โ€”'; color: #555; } .more-menu .more-skip-clear { background: transparent; border: 0; color: #ff9090; font-size: 13px; padding: 0 8px; border-radius: 4px; cursor: pointer; } .more-menu .more-skip-clear:hover { background: rgba(255,144,144,0.15); } /* ์Šคํ‚ต ๋งˆํ‚น ์ปจํ…์ŠคํŠธ ๋ฉ”๋‰ด */ .skip-ctx-menu { position: absolute; z-index: 2147483647; background: rgba(20,22,28,0.96); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 4px; box-shadow: 0 4px 20px rgba(0,0,0,0.6); min-width: 180px; } .skip-ctx-menu[hidden] { display: none; } .skip-ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: 0; color: #e3e6eb; font-size: 13px; padding: 8px 12px; border-radius: 4px; cursor: pointer; } .skip-ctx-menu button .lbl { flex: 1; } .skip-ctx-menu button .t { color: #ffd54a; font-variant-numeric: tabular-nums; font-size: 11px; min-width: 44px; text-align: right; } .skip-ctx-menu button .t:empty::before { content: 'โ€”'; color: #555; } .skip-ctx-menu button:hover { background: rgba(255,255,255,0.08); } .skip-ctx-menu button[data-skip="clear"] { color: #ff9090; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 2px; } .zoom-ctrl .zc-bar::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #e50914; cursor: pointer; } .zoom-ctrl .zc-bar::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #e50914; border: 0; cursor: pointer; } .zoom-ctrl .zc-vol { width: 80px; height: 4px; cursor: pointer; accent-color: #fff; background: rgba(255,255,255,0.3); border-radius: 2px; -webkit-appearance: none; appearance: none; } .zoom-ctrl .zc-vol::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; cursor: pointer; } .zoom-ctrl .zc-vol::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0; cursor: pointer; } /* โ”€โ”€โ”€โ”€โ”€ ์ฝ˜ํ…์ธ  ์˜์—ญ โ”€โ”€โ”€โ”€โ”€ */ .content { padding: 12px 12px calc(80px + var(--safe-bot)); } /* ๋นต๋ถ€์Šค๋Ÿฌ๊ธฐ/๋ฉ”ํƒ€ */ .now-meta { margin-bottom: 12px; } .now-meta .title-row { display: flex; align-items: center; gap: 8px; } .now-meta .title { font-size: 16px; font-weight: 700; line-height: 1.35; flex: 1; min-width: 0; } .now-meta .sub { font-size: 12px; color: var(--muted); margin-top: 3px; } .now-meta .dl-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; padding: 0; } .now-meta .dl-btn:hover { background: var(--panel2); color: var(--text); } .now-meta .dl-btn:active { transform: scale(0.95); } .now-meta:empty { display: none; } /* ํšŒ์ฐจ ๊ฐ€๋กœ์Šคํฌ๋กค ์นฉ */ .ep-strip { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 4px 0 10px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; min-width: 0; max-width: 100%; } .ep-strip::-webkit-scrollbar { height: 6px; } .ep-strip::-webkit-scrollbar-track { background: transparent; } .ep-strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 999px; } .ep-strip::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.45); } .ep-chip { flex: 0 0 auto; background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 8px 14px; border-radius: 999px; font-size: 13px; cursor: pointer; min-width: 56px; text-align: center; } .ep-chip:active { background: #2a313d; } .ep-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } .ep-strip.hidden, .ep-empty.hidden { display: none; } /* ํšŒ์ฐจ ๊ทธ๋ฆฌ๋“œ (ํŽผ์นจ) */ .ep-grid-wrap { margin-top: 8px; } .ep-grid-toggle { background: transparent; border: 0; color: var(--muted); font-size: 12px; padding: 4px 0; cursor: pointer; } /* ep-grid๋Š” ๋‹จ์ˆœ ์ปจํ…Œ์ด๋„ˆ (๊ฒ€์ƒ‰ input + ๊ทธ๋ฆฌ๋“œ ๋ณธ์ฒด). ๊ทธ๋ฆฌ๋“œ๋Š” ์•ˆ์ชฝ epGridList์—. */ .ep-grid { margin-top: 6px; } .ep-grid.hidden { display: none; } #epGridList { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 6px; } #epGridList .ep-chip { width: 100%; min-width: 0; padding: 8px; border-radius: 8px; } /* ์„น์…˜ ํ—ค๋” */ .section-h { display: flex; align-items: center; gap: 10px; margin: 20px 0 8px; } .section-h h2 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; } .section-h .spacer { flex: 1; } /* ์ฆ๊ฒจ์ฐพ๊ธฐ ๋ฆฌ์ŠคํŠธ */ .fav-list { display: flex; flex-direction: column; gap: 4px; } .fav-list:empty::before { content: "๏ผ‹ ๋ฒ„ํŠผ์œผ๋กœ ์˜์ƒ์„ ์ถ”๊ฐ€ํ•˜์„ธ์š”. ๊ฒ€์ƒ‰์—์„œ ์ถ”๊ฐ€ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค."; display: block; padding: 18px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; background: var(--panel); border-radius: 10px; } .fav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; } .fav-item:active { background: var(--panel2); } .fav-item.active { background: #1d2c45; border-color: #3a5380; } .fav-item .ftxt { flex: 1; min-width: 0; } .fav-item .ftxt b { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; word-break: break-word; font-size: 14px; line-height: 1.25; } .fav-item .ftxt .meta { font-size: 11px; color: var(--muted); margin-top: 2px; } .fav-item .new-badge { background: var(--new); color: #1a1305; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; letter-spacing: 0.5px; } .fav-item .resume-badge { background: var(--accent2); color: #07111e; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; letter-spacing: 0.3px; } .fav-item .badge-col { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; } /* โ”€โ”€โ”€โ”€โ”€ ๋ธŒ๋žœ๋“œ ๋กœ๊ณ  โ”€โ”€โ”€โ”€โ”€ */ .brand { cursor: pointer; user-select: none; } .brand { font-family: "Bebas Neue", "Arial Black", "Impact", -apple-system, sans-serif; font-weight: 900; letter-spacing: 0.02em; text-transform: uppercase; line-height: 1; display: inline-flex; align-items: center; gap: 0.2em; } .brand .b-ott { color: #e50914; } .brand .b-sep { color: #e6e8ec; opacity: 0.7; font-weight: 400; transform: translateY(-0.05em); } .brand .b-player { color: #fff; } .brand-wrap { padding: 16px 14px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); background: radial-gradient(ellipse at top left, rgba(229,9,20,0.12), transparent 70%), var(--panel); } .brand-wrap .brand { font-size: 30px; } .appbar .brand { font-size: 22px; } /* โ”€โ”€โ”€โ”€โ”€ ์ƒ๋‹จ ๋ชจ๋“œ/๋„๋ฉ”์ธ ๋ฐฐ์ง€ โ”€โ”€โ”€โ”€โ”€ */ .mode-badge, .domain-badge { font-size: 10px; font-weight: 800; letter-spacing: 0.05em; padding: 3px 7px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; text-transform: uppercase; } .mode-badge { background: rgba(110,231,168,0.10); color: #6ee7a8; border-color: rgba(110,231,168,0.30); } .mode-badge.mode-cdp { background: rgba(110,231,168,0.10); color: #6ee7a8; border-color: rgba(110,231,168,0.30); } .mode-badge.mode-local { background: rgba(96,165,250,0.10); color: #93c5fd; border-color: rgba(96,165,250,0.30); } .mode-badge.mode-hf { background: rgba(244,114,182,0.10); color: #f9a8d4; border-color: rgba(244,114,182,0.30); } .domain-badge { color: #e6e8ec; background: rgba(255,255,255,0.04); cursor: pointer; } .domain-badge:hover { border-color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.09); } .domain-badge.bad { color: #fca5a5; border-color: rgba(252,165,165,0.30); background: rgba(252,165,165,0.08); } .domain-badge.ov { color: #fcd34d; border-color: rgba(252,211,77,0.40); background: rgba(252,211,77,0.10); } /* ์ˆ˜๋™ ์˜ค๋ฒ„๋ผ์ด๋“œ ํ‘œ์‹œ */ /* โ”€โ”€โ”€โ”€โ”€ ๋„๋ฉ”์ธ ์„ ํƒ ํŒ์—… โ”€โ”€โ”€โ”€โ”€ */ #domainPop { position: fixed; z-index: 9999; display: none; min-width: 240px; padding: 12px; background: var(--panel, #16181d); border: 1px solid var(--border, #2a2d34); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.55); font-size: 13px; color: #e6e8ec; } #domainPop.show { display: block; } #domainPop .dp-title { font-size: 11px; color: var(--muted, #8b909a); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .05em; } #domainPop .dp-opt { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; } #domainPop .dp-opt:hover { background: rgba(255,255,255,0.06); } #domainPop .dp-opt input[type=radio] { accent-color: #e50914; margin: 0; } #domainPop .dp-opt label { cursor: pointer; flex: 1; display: flex; align-items: center; gap: 6px; } #domainPop .dp-numwrap { display: flex; align-items: center; gap: 4px; font-family: ui-monospace, Consolas, monospace; } #domainPop .dp-numwrap input.dp-num { width: 58px; text-align: center; font-family: inherit; font-size: 13px; padding: 3px 4px; border-radius: 6px; border: 1px solid var(--border, #2a2d34); background: #0e1014; color: #e6e8ec; } #domainPop .dp-sub { font-size: 11px; color: var(--muted, #8b909a); } #domainPop .dp-actions { display: flex; gap: 6px; margin-top: 10px; } #domainPop .dp-actions button { flex: 1; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--border, #2a2d34); background: #1c1f26; color: #e6e8ec; cursor: pointer; font-size: 12px; font-weight: 700; } #domainPop .dp-actions button.primary { background: #e50914; border-color: #e50914; color: #fff; } #domainPop .dp-actions button:hover { filter: brightness(1.15); } #domainPop .dp-msg { font-size: 11px; margin-top: 8px; min-height: 14px; } #domainPop .dp-msg.ok { color: #6ee7a8; } #domainPop .dp-msg.err { color: #fca5a5; } /* ๋ฐฐ์ง€ ๋ฌถ์Œ: ์šฐ์ธก ์ƒ๋‹จ ๊ณ ์ •. ๋ฐ์Šคํฌํƒ‘ยท๋ชจ๋ฐ”์ผ ๋ชจ๋‘ ๊ฐ€๋กœ(์ขŒ:๋ชจ๋“œ, ์šฐ:๋„๋ฉ”์ธ). ๋ฐ์Šคํฌํƒ‘์€ brand-wrap์˜ ๊ฐ€์žฅ ์œ„์ชฝ ์ •๋ ฌ. */ .badge-stack { margin-left: auto; display: flex; flex-direction: row; align-items: center; gap: 6px; align-self: flex-start; } .appbar .mode-badge, .appbar .domain-badge { font-size: 9px; padding: 2px 6px; } /* โ”€โ”€โ”€โ”€โ”€ ํ”„๋กœํ•„ ํƒญ โ”€โ”€โ”€โ”€โ”€ */ .profile-bar { padding: 8px 12px 10px; background: var(--panel); border-bottom: 1px solid var(--border); } .profile-tabs { display: flex; gap: 8px; width: 100%; } .profile-tab { flex: 1; min-width: 0; background: linear-gradient(135deg, var(--panel2) 0%, #1a1f2a 100%); border: 1px solid var(--border); color: var(--muted); height: 32px; border-radius: 8px; font-size: 14px; font-weight: 800; cursor: pointer; padding: 0 6px; font-family: "Bebas Neue", "Arial Black", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; letter-spacing: 0.05em; transition: all 0.18s ease; position: relative; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .profile-tab::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(229,9,20,0.0), rgba(229,9,20,0.0)); transition: background 0.2s; pointer-events: none; } .profile-tab:hover { color: var(--text); border-color: #3a4252; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.3); } .profile-tab:hover::before { background: linear-gradient(135deg, rgba(229,9,20,0.08), rgba(229,9,20,0.0)); } .profile-tab.active { background: linear-gradient(135deg, #ff5b6a 0%, #e50914 55%, #b00710 100%); border-color: #e50914; color: #fff; box-shadow: 0 4px 16px rgba(229,9,20,0.5), inset 0 1px 0 rgba(255,255,255,0.2); transform: translateY(-1px); } .profile-tab.active::before { background: none; } .profile-tab:active { transform: translateY(0); } /* โ”€โ”€โ”€โ”€โ”€ ํ‚ค๋…ธ๋ผ์ด์ธ  ๋žญํ‚น โ”€โ”€โ”€โ”€โ”€ */ .ranking-box { padding: 14px 12px 18px; border-top: 1px solid var(--border); } .ranking-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; } .ranking-head h3 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; flex: 1; } .ranking-tabs { display: flex; gap: 4px; background: var(--panel2); padding: 3px; border-radius: 8px; } .ranking-tabs button { background: transparent; border: 0; color: var(--muted); font-size: 11px; padding: 4px 10px; cursor: pointer; border-radius: 6px; font-weight: 600; } .ranking-tabs button.active { background: var(--accent); color: #fff; } .ranking-list { display: flex; flex-direction: column; gap: 4px; } .rk-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; overflow: hidden; } .rk-item:active, .rk-item:hover { background: #232936; } .rk-item .rk-rank { font-size: 16px; font-weight: 900; color: var(--accent); min-width: 22px; text-align: center; font-family: "Bebas Neue", "Arial Black", sans-serif; } .rk-item .rk-poster { width: 36px; height: 50px; object-fit: cover; border-radius: 4px; background: #2a313d; flex-shrink: 0; } .rk-item .rk-poster.placeholder { display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted); } .rk-item .rk-title { flex: 1; min-width: 0; } .rk-item .rk-title b { display: block; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .rk-item .rk-title .rk-meta { font-size: 10px; color: var(--muted); margin-top: 2px; } .rk-item .rk-more { background: transparent; border: 0; color: var(--accent2); font-size: 11px; cursor: pointer; padding: 4px 6px; flex-shrink: 0; } .rk-item .rk-more:hover { color: var(--accent); } .rk-detail { background: var(--panel); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 10px 10px; padding: 10px 12px; margin-top: -8px; margin-bottom: 4px; font-size: 12px; color: var(--text); line-height: 1.5; display: none; } .rk-detail.open { display: block; } .rk-detail .syn { color: var(--text); margin-bottom: 8px; font-size: 12px; } .rk-detail .meta-row { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 11px; } .rk-detail .meta-row span b { color: var(--text); font-weight: 500; margin-left: 4px; } .rk-detail .cast { margin-top: 6px; color: var(--muted); font-size: 11px; } .rk-detail .cast b { color: var(--text); font-weight: 500; } .rk-detail .loading { color: var(--muted); font-style: italic; } .rk-detail .trailer-wrap { margin-top: 10px; } .rk-detail .trailer-loading { color: var(--muted); font-size: 11px; font-style: italic; } .rk-detail .trailer-label { font-size: 10px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; } .rk-detail .trailer-frame { position: relative; padding-top: 56.25%; /* 16:9 */ background: #000; border-radius: 6px; overflow: hidden; } .rk-detail .trailer-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; } /* ์นด๋“œ ์šฐ์ธก ์•ก์…˜ ์ปฌ๋Ÿผ: โœ• ์œ„ / โœ“ ์•„๋ž˜ */ .fav-item .actcol { display: flex; flex-direction: column; align-items: center; justify-content: space-between; align-self: stretch; gap: 6px; margin-left: 6px; } .fav-item .markdone { background: transparent; border: 0; color: var(--muted); font-size: 16px; padding: 4px 8px; cursor: pointer; line-height: 1; } .fav-item .markdone:hover, .fav-item .markdone:active { color: #6ee7a8; } .fav-item .delbtn { background: transparent; border: 0; color: var(--muted); font-size: 18px; padding: 4px 8px; cursor: pointer; } .fav-item .delbtn:active { color: var(--accent); } /* ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ */ .search-list { display: flex; flex-direction: column; gap: 4px; } .sr-item { padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; } .sr-item:active { background: var(--panel2); } .sr-item b { display: block; font-size: 14px; line-height: 1.35; } .sr-item .meta { font-size: 11px; color: var(--muted); margin-top: 3px; } .sr-item .meta.star { color: var(--new); } /* source ๋ฐฐ์ง€ */ .src-badge { display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 4px; vertical-align: middle; margin-right: 4px; font-weight: 700; letter-spacing: 0.5px; } .src-badge.ani { background: #5b3df5; color: #fff; } .src-badge.tv { background: #16a34a; color: #fff; } /* ๋“œ๋ผ๋งˆ */ .fb-badge { display: inline-block; font-size: 9px; padding: 1px 4px; border-radius: 3px; background: #404555; color: #c5cad6; font-weight: 600; letter-spacing: 0.3px; vertical-align: middle; margin-left: 4px; opacity: 0.8; } .src-badge.tv.ent { background: #d97706; color: #fff; } /* ์˜ˆ๋Šฅ */ .src-badge.tv.mov { background: #1865f2; color: #fff; } /* ์˜ํ™” */ /* ๊ฒ€์ƒ‰๋ฐ” */ .search-bar { display: flex; gap: 6px; margin-bottom: 8px; } .search-bar input { flex: 1; } /* ํ•˜๋‹จ ๊ณ ์ • ์•ก์…˜ */ .fab { position: fixed; right: 16px; bottom: calc(20px + var(--safe-bot)); z-index: 40; background: var(--accent); border: 0; color: #fff; width: 56px; height: 56px; border-radius: 50%; box-shadow: 0 6px 20px rgba(0,0,0,0.5); font-size: 24px; cursor: pointer; } .fab:active { background: #e34758; } /* โ”€โ”€โ”€โ”€โ”€ ๋ชจ๋‹ฌ โ”€โ”€โ”€โ”€โ”€ */ .modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: flex-end; justify-content: center; z-index: 100; padding: 0; } .modal-bg.show { display: flex; } .modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; padding: 20px; padding-bottom: calc(20px + var(--safe-bot)); } .modal h2 { margin: 0 0 12px; font-size: 16px; } .modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; } .modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; } .modal .hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.4; } .modal code { background: var(--panel2); padding: 1px 5px; border-radius: 3px; font-size: 11px; } /* โ”€โ”€โ”€โ”€โ”€ ๋ฐ์Šคํฌํƒ‘ (>= 1024px): 2์ปฌ๋Ÿผ โ”€โ”€โ”€โ”€โ”€ */ @media (min-width: 1024px) { body { display: grid; grid-template-columns: var(--left-w, 340px) 1fr; grid-template-rows: 100dvh; overflow: hidden; } body.with-transition { transition: grid-template-columns 0.2s ease; } body.left-collapsed { grid-template-columns: 0 1fr; } body.left-collapsed .pane.left { visibility: hidden; } /* ๋ฆฌ์‚ฌ์ด์ฆˆ ํ•ธ๋“ค */ .resize-handle { position: absolute; top: 0; right: -3px; width: 6px; height: 100%; cursor: ew-resize; z-index: 20; background: transparent; transition: background 0.15s; } .resize-handle:hover, .resize-handle.dragging { background: var(--accent2); } body.left-collapsed .resize-handle { display: none; } .appbar { display: none; } .pane { background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; position: relative; } .pane.right { border-right: 0; border-left: 1px solid var(--border); } .pane-head { padding: 14px 14px 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 1; } .pane-head h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; } .pane-head .domain { font-size: 11px; color: #6ee7a8; } main.center { display: flex; flex-direction: column; background: #000; min-width: 0; overflow: hidden; } .video-wrap { aspect-ratio: auto; flex: 1; min-height: 0; } .center-bottom { background: var(--bg); padding: 12px 16px; max-height: 38vh; overflow-y: auto; } .fab { display: none; } .show-on-mobile { display: none !important; } .pane-foot { border-top: 1px solid var(--border); padding: 10px; display: flex; gap: 6px; position: sticky; bottom: 0; background: var(--panel); } .pane-foot .btn { flex: 1; } /* ์ฆ๊ฒจ์ฐพ๊ธฐ ์นด๋“œ๋Š” ๋ฐ์Šคํฌํƒ‘์—์„œ๋Š” ์ข๊ฒŒ */ .pane.left .fav-item { padding: 8px 10px; border-radius: 8px; } .pane.left .fav-item .ftxt b { font-size: 13px; } .pane.right .sr-item { padding: 8px 10px; border-radius: 8px; } .pane.right .sr-item b { font-size: 13px; } /* โ”€โ”€โ”€โ”€โ”€ ์ปค์Šคํ…€ ์Šคํฌ๋กค๋ฐ” (๋ฐ์Šคํฌํƒ‘ ์ „์šฉ) โ”€โ”€โ”€โ”€โ”€ */ .pane, .center-bottom { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; scrollbar-gutter: stable; } .pane::-webkit-scrollbar, .center-bottom::-webkit-scrollbar { width: 10px; height: 10px; } .pane::-webkit-scrollbar-track, .center-bottom::-webkit-scrollbar-track { background: transparent; } .pane::-webkit-scrollbar-thumb, .center-bottom::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border: 2px solid transparent; background-clip: padding-box; border-radius: 999px; transition: background 0.18s ease; } .pane:hover::-webkit-scrollbar-thumb, .center-bottom:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); background-clip: padding-box; } .pane::-webkit-scrollbar-thumb:hover, .center-bottom::-webkit-scrollbar-thumb:hover { background: var(--accent2); background-clip: padding-box; } .pane::-webkit-scrollbar-thumb:active, .center-bottom::-webkit-scrollbar-thumb:active { background: var(--accent); background-clip: padding-box; } .pane::-webkit-scrollbar-corner, .center-bottom::-webkit-scrollbar-corner { background: transparent; } } /* โ”€โ”€โ”€โ”€โ”€ ๋ชจ๋ฐ”์ผ (< 1024px) โ”€โ”€โ”€โ”€โ”€ */ @media (max-width: 1023.98px) { .hide-on-mobile { display: none !important; } .pane { display: block; } .pane-head, .pane-foot { display: none; } .pane.right .right-tabs { display: flex; background: var(--panel); border-radius: 10px; padding: 4px; margin-bottom: 10px; } .pane.right .right-tabs button { flex: 1; background: transparent; border: 0; color: var(--muted); padding: 8px; font-size: 13px; cursor: pointer; border-radius: 6px; } .pane.right .right-tabs button.active { background: var(--panel2); color: var(--text); } } /* โ”€โ”€โ”€โ”€โ”€ A2: ํšŒ์ฐจ ์นฉ ์ง„๋„๋ฐ” + finished ์ฒดํฌ โ”€โ”€โ”€โ”€โ”€ */ .ep-chip { position: relative; overflow: hidden; } .ep-chip .ep-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); pointer-events: none; transition: width 0.2s; } .ep-chip.finished .ep-progress { background: #6ee7a8; } .ep-chip .ep-check { position: absolute; top: 2px; right: 4px; color: #6ee7a8; font-size: 10px; font-weight: 900; } /* E-14: ๋ฏธ์‹œ์ฒญ ํšŒ์ฐจ ์  ํ‘œ์‹œ (์ƒ๋‹จ ์šฐ์ธก ์ž‘์€ ํšŒ์ƒ‰ dot) */ .ep-chip.unwatched::after { content: ''; position: absolute; top: 4px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); opacity: 0.55; } .ep-chip.unwatched.active::after { display: none; } /* H-11/H-5: ์˜์ƒ ์šฐ์ƒ๋‹จ ์…€๋ ‰ํŠธ ๋ฐ•์Šค๋“ค (ํ™”์งˆ/์˜ค๋””์˜ค/์ž๋ง‰) */ .hls-quality, .hls-audio, .hls-sub { position: absolute; z-index: 5; background: rgba(0,0,0,0.55); color: #fff; border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; padding: 4px 6px; font-size: 11px; cursor: pointer; opacity: 0; transition: opacity 0.15s; display: none; top: 12px; } .hls-quality { right: 56px; } .hls-audio { right: 120px; } .hls-sub { right: 184px; } .video-wrap:hover .hls-quality.has-levels, .video-wrap:hover .hls-audio.has-levels, .video-wrap:hover .hls-sub.has-levels { opacity: 1; } .hls-quality.has-levels, .hls-audio.has-levels, .hls-sub.has-levels { display: block; } .video-wrap.locked .hls-quality, .video-wrap.locked .hls-audio, .video-wrap.locked .hls-sub { display: none !important; } .video-wrap:fullscreen .hls-quality.has-levels, .video-wrap:fullscreen .hls-audio.has-levels, .video-wrap:fullscreen .hls-sub.has-levels { opacity: 1; } /* F-8: ๋‹ค์Œ ํ™” ๋ฏธ๋ฆฌ๋ณด๊ธฐ (์˜์ƒ ์šฐ์ƒ๋‹จ) */ .next-preview { position: absolute; top: 56px; right: 12px; z-index: 12; background: rgba(0,0,0,0.78); color: #fff; border: 1px solid rgba(255,255,255,0.2); padding: 6px 12px; border-radius: 16px; font-size: 12px; cursor: pointer; opacity: 0; transform: translateY(-4px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; touch-action: manipulation; } .next-preview.show { opacity: 1; transform: translateY(0); pointer-events: auto; } .next-preview:hover { background: var(--accent); border-color: var(--accent); } .video-wrap.locked .next-preview { display: none !important; } /* ํ’€์Šคํฌ๋ฆฐ์—์„œ zoom-ctrl์ด 2147483647๋กœ ์˜ฌ๋ผ๊ฐ€๋‹ˆ ๋‹ค์Œ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋„ ๊ทธ ์œ„๋กœ โ€” ๋ชจ๋ฐ”์ผ ํ’€์Šคํฌ๋ฆฐ์—์„œ ํด๋ฆญ ๊ฐ€๋Šฅ ๋ณด์žฅ. */ .video-wrap:fullscreen .next-preview, .video-wrap:-webkit-full-screen .next-preview { z-index: 2147483647; } /* โ”€โ”€โ”€โ”€โ”€ E-2: ๋ณด๊ด€ํ•จ ์นด๋“œ ํฌ์Šคํ„ฐ โ”€โ”€โ”€โ”€โ”€ */ .fav-item .fav-poster { width: 44px; height: 60px; border-radius: 4px; object-fit: cover; background: var(--panel2); flex-shrink: 0; } .fav-item .fav-poster.placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 10px; } @media (max-width: 1023.98px) { .fav-item .fav-poster { width: 52px; height: 70px; } } /* โ”€โ”€โ”€โ”€โ”€ E-3: ์ƒ๋Œ€์‹œ๊ฐ โ”€โ”€โ”€โ”€โ”€ */ .fav-item .meta .ago { color: var(--accent2); font-size: 10px; margin-left: 4px; } .fav-item.flash { animation: flashHighlight 1.5s ease-out; } @keyframes flashHighlight { 0%, 30% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 rgba(229,9,20,0); } } /* โ”€โ”€โ”€โ”€โ”€ A1: ๊ฒ€์ƒ‰ ์ž๋™์™„์„ฑ ๋“œ๋กญ๋‹ค์šด โ”€โ”€โ”€โ”€โ”€ */ .ac-wrap { position: relative; } .ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 50; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; margin-top: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); max-height: 280px; overflow-y: auto; display: none; } .ac-list.show { display: block; } .ac-item { padding: 8px 12px; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 8px; } .ac-item:hover, .ac-item.focused { background: rgba(78,161,255,0.15); } .ac-item .ac-icon { color: var(--muted); font-size: 12px; width: 14px; flex-shrink: 0; } .ac-item .ac-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ac-item .ac-del { background: transparent; border: 0; color: var(--muted); font-size: 14px; padding: 0 4px; cursor: pointer; opacity: 0; } .ac-item:hover .ac-del { opacity: 0.7; } .ac-item .ac-del:hover { opacity: 1; color: var(--accent); } /* โ”€โ”€โ”€โ”€โ”€ A4: ์„œ๋ฒ„ ์‘๋‹ต ์‹คํŒจ ์ƒ๋‹จ ๋ฐฐ๋„ˆ โ”€โ”€โ”€โ”€โ”€ */ .err-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; background: linear-gradient(90deg, #c92a39, #e0394a); color: #fff; text-align: center; padding: 8px 12px; font-size: 12px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,0.5); transform: translateY(-100%); transition: transform 0.3s; } .err-banner.show { transform: translateY(0); } /* โ”€โ”€โ”€โ”€โ”€ B11: ๋ถ€ํŒ… ์‹œ ์ด์–ด๋ณด๊ธฐ ๋น… ๋ฐฐ๋„ˆ โ”€โ”€โ”€โ”€โ”€ */ .resume-hero { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin: 10px 16px; background: linear-gradient(90deg, rgba(229,9,20,0.18), rgba(229,9,20,0.05)); border: 1px solid rgba(229,9,20,0.4); border-radius: 12px; cursor: pointer; transition: transform 0.15s, background 0.15s; } .resume-hero:hover { transform: translateY(-1px); background: linear-gradient(90deg, rgba(229,9,20,0.28), rgba(229,9,20,0.1)); } .resume-hero .rh-ico { font-size: 24px; color: var(--accent); } .resume-hero .rh-txt { flex: 1; min-width: 0; } .resume-hero .rh-txt b { font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .resume-hero .rh-txt small { font-size: 11px; color: var(--muted); } .resume-hero .rh-close { background: transparent; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; } .resume-hero .rh-close:hover { color: var(--text); } @media (min-width: 1024px) { /* ๋ฐ์Šคํฌํƒ‘์—์„  body๊ฐ€ grid๋ผ resume-hero๊ฐ€ grid item์œผ๋กœ ์ขŒ์ธก ์ปฌ๋Ÿผ์„ ์ฐจ์ง€ํ•ด ๋ ˆ์ด์•„์›ƒ ๊นจ์ง. ๋ฐ์Šคํฌํƒ‘์€ ์‚ฌ์ด๋“œ ํŒจ๋„์— ๋ณด๊ด€ํ•จ ์นด๋“œ๋กœ ๋™์ผ ์ •๋ณด ๋ณด์ด๋ฏ€๋กœ hero ์ž์ฒด ์ˆจ๊น€. */ .resume-hero { display: none !important; } } /* โ”€โ”€โ”€โ”€โ”€ B13: ํšŒ์ฐจ ๋ผ๋ฒจ ๊ฒ€์ƒ‰ โ”€โ”€โ”€โ”€โ”€ */ .ep-search { display: flex; gap: 6px; margin-bottom: 6px; } .ep-search input { flex: 1; padding: 6px 10px; font-size: 12px; background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; outline: none; } .ep-search input:focus { border-color: var(--accent2); } .ep-chip.ep-hidden { display: none; } /* โ”€โ”€โ”€โ”€โ”€ C5: ๋‹ค์Œ ํ™” ์นด์šดํŠธ๋‹ค์šด ์˜ค๋ฒ„๋ ˆ์ด โ”€โ”€โ”€โ”€โ”€ */ /* z-index: zoom-ctrl(10)ยทmore-menu(11)๋ณด๋‹ค ์œ„. ๋ชจ๋ฐ”์ผ์—์„œ zoom-ctrl์ด opacity:0์ด์–ด๋„ pointer-events:auto๋ผ ncCancel/ncGo ํด๋ฆญ์ด ๊ฐ€๋กœ์ฑ„์—ฌ์„œ ์•ˆ ๋จน๋˜ ์‚ฌ๊ณ (2026-06-08) ๋ฐฉ์ง€. */ .next-countdown { position: absolute; right: 16px; bottom: 70px; z-index: 12; background: rgba(0,0,0,0.85); color: #fff; border: 1px solid rgba(255,255,255,0.2); border-radius: 12px; padding: 12px 14px; min-width: 220px; display: none; flex-direction: column; gap: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.6); } .next-countdown.show { display: flex; } /* ํ’€์Šคํฌ๋ฆฐ์—์„  zoom-ctrl์ด 2147483647๋กœ ์˜ฌ๋ผ๊ฐ€๋‹ˆ ์นด์šดํŠธ๋‹ค์šด๋„ ๊ทธ ์œ„์— ๋– ์•ผ ํด๋ฆญ ๊ฐ€๋Šฅ. */ .video-wrap:fullscreen .next-countdown, .video-wrap:-webkit-full-screen .next-countdown { z-index: 2147483647; } /* ๋ชจ๋ฐ”์ผ ํ„ฐ์น˜ ํ™˜๊ฒฝ์—์„œ ์นด์šดํŠธ๋‹ค์šด ๋ฒ„ํŠผ์€ ํ•ญ์ƒ ์ตœ์šฐ์„ ์œผ๋กœ ํด๋ฆญ ๋ฐ›์•„์•ผ ํ•จ */ .next-countdown button { touch-action: manipulation; } .next-countdown .nc-label { font-size: 12px; color: #ccc; } .next-countdown .nc-title { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .next-countdown .nc-bar { height: 3px; background: rgba(255,255,255,0.15); border-radius: 2px; overflow: hidden; } .next-countdown .nc-bar-fill { height: 100%; background: var(--accent); width: 100%; transition: width 0.95s linear; } .next-countdown .nc-actions { display: flex; gap: 6px; margin-top: 4px; } .next-countdown button { flex: 1; padding: 6px 10px; font-size: 12px; background: var(--panel2); border: 1px solid var(--border); color: #fff; border-radius: 6px; cursor: pointer; } .next-countdown .nc-go { background: var(--accent); border-color: var(--accent); } @media (max-width: 1023.98px) { .next-countdown { right: 8px; bottom: 56px; min-width: 200px; padding: 10px 12px; } } /* โ”€โ”€โ”€โ”€โ”€ D2: ๋ณด๊ด€ํ•จ ์ •๋ ฌ ๋“œ๋กญ๋‹ค์šด โ”€โ”€โ”€โ”€โ”€ */ .sort-bar { display: flex; align-items: center; gap: 6px; padding: 4px 10px 6px; font-size: 11px; color: var(--muted); } .sort-bar select { background: var(--panel2); border: 1px solid var(--border); color: var(--text); font-size: 11px; padding: 3px 6px; border-radius: 5px; outline: none; font-family: inherit; } /* โ”€โ”€โ”€โ”€โ”€ D10: ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ โ˜… ์ถ”๊ฐ€ ๋ฒ„ํŠผ โ”€โ”€โ”€โ”€โ”€ */ .sr-item { position: relative; } .sr-item .sr-fav { position: absolute; top: 6px; right: 8px; background: transparent; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 6px; line-height: 1; transition: color 0.15s, transform 0.15s; } .sr-item .sr-fav:hover { transform: scale(1.15); color: var(--new); } .sr-item .sr-fav.added { color: var(--new); } /* โ”€โ”€โ”€โ”€โ”€ D12: ์Œ๋Ÿ‰/์†๋„ ์ธ๋””์ผ€์ดํ„ฐ โ”€โ”€โ”€โ”€โ”€ */ .media-toast { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.78); color: #fff; padding: 8px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 8; } .media-toast.show { opacity: 1; } /* โ”€โ”€โ”€โ”€โ”€ D14: ํ†ต๊ณ„ ๋ชจ๋‹ฌ โ”€โ”€โ”€โ”€โ”€ */ .stats-modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; max-width: 480px; padding: 20px; max-height: 80vh; overflow-y: auto; } .stats-modal .stat-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; } .stats-modal .stat-row:last-of-type { border-bottom: 0; } .stats-modal .stat-row b { color: var(--accent2); } /* โ”€โ”€โ”€โ”€โ”€ ๋ชจ๋ฐ”์ผ: ์žฌ์ƒ๋ฐ” ์ปดํŒฉํŠธ โ”€โ”€โ”€โ”€โ”€ */ @media (max-width: 640px) { /* ํ’€์Šคํฌ๋ฆฐ์ด ์•„๋‹Œ ๋ชจ๋ฐ”์ผ ์ธ๋ผ์ธ ์ปจํŠธ๋กค๋ฐ” */ .video-wrap:not(:fullscreen):not(:-webkit-full-screen) .zoom-ctrl { gap: 6px; padding: 8px 8px 6px; } .video-wrap:not(:fullscreen):not(:-webkit-full-screen) .zoom-ctrl .zc-btn { font-size: 16px; padding: 4px 6px; } .video-wrap:not(:fullscreen):not(:-webkit-full-screen) .zoom-ctrl .zc-time { min-width: 0; font-size: 11px; white-space: nowrap; } /* ๋ณผ๋ฅจ ์Šฌ๋ผ์ด๋” ์ˆจ๊น€ โ€” ์Œ์†Œ๊ฑฐ ์•„์ด์ฝ˜๋งŒ ๋…ธ์ถœ */ .video-wrap:not(:fullscreen):not(:-webkit-full-screen) .zoom-ctrl .zc-vol { display: none; } } </style> </head> <body> <!-- ์ƒ๋‹จ ๋กœ๋”ฉ ๋ฐ” โ€” selectFav ์ง„์ž… ์‹œ ํ‘œ์‹œ, ์™„๋ฃŒ ์‹œ ์ˆจ๊น€ --> <div id="topLoader" aria-hidden="true"></div> <!-- A4: ์„œ๋ฒ„ ์‘๋‹ต ์‹คํŒจ ๋ฐฐ๋„ˆ --> <div class="err-banner" id="errBanner">์„œ๋ฒ„ ์‘๋‹ต ์—†์Œ โ€” ์ž๋™๋ณต๊ตฌ ์ง„ํ–‰ ์ค‘โ€ฆ</div> <!-- B11: ์ด์–ด๋ณด๊ธฐ ๋น… ๋ฐฐ๋„ˆ (์ƒ๋‹จ) --> <div class="resume-hero" id="resumeHero" style="display:none"> <div class="rh-ico">โ–ถ</div> <div class="rh-txt"><b id="rhTitle"></b><small id="rhMeta"></small></div> <button class="rh-close" id="rhClose" aria-label="๋‹ซ๊ธฐ">โœ•</button> </div> <!-- ๋„๋ฉ”์ธ ์„ ํƒ ํŒ์—… (๋ฐฐ์ง€ ํด๋ฆญ ์‹œ ํ‘œ์‹œ, ๋ฐ์Šคํฌํƒ‘ยท๋ชจ๋ฐ”์ผ ๊ณต์šฉ) --> <div id="domainPop"> <div class="dp-title">tvchak ์ฝ˜ํ…์ธ  ๋„๋ฉ”์ธ</div> <div class="dp-opt"> <input type="radio" name="dpMode" id="dpAuto" value="auto"> <label for="dpAuto">์ž๋™ <span class="dp-sub">(announce ์ถ”์ข…)</span></label> </div> <div class="dp-opt"> <input type="radio" name="dpMode" id="dpLive" value="live"> <label for="dpLive">๋ผ์ด๋ธŒ <span class="dp-sub">tvchak.live</span></label> </div> <div class="dp-opt"> <input type="radio" name="dpMode" id="dpNum" value="num"> <label for="dpNum"> <span class="dp-numwrap">tvchak<input class="dp-num" id="dpNumInput" type="number" min="1" max="9999" placeholder="208">.com</span> </label> </div> <div class="dp-actions"> <button type="button" id="dpApply" class="primary">์ ์šฉ</button> <button type="button" id="dpCancel">๋‹ซ๊ธฐ</button> </div> <div class="dp-msg" id="dpMsg"></div> </div> <!-- ๋ชจ๋ฐ”์ผ ์•ฑ๋ฐ” --> <div class="appbar show-on-mobile" style="background: radial-gradient(ellipse at top left, rgba(229,9,20,0.15), transparent 70%), var(--panel);"> <h1 id="appbarTitle" class="brand"> <span class="b-ott">OTT</span> <span class="b-sep">โ”‚</span> <span class="b-player">PLAYER</span> </h1> <div class="badge-stack"> <span class="mode-badge" id="modeBadgeMob" title="์‹คํ–‰ ๋ชจ๋“œ">โ€ฆ</span> <span class="domain-badge" id="domainBadgeMob" title="ํ˜„์žฌ tvchak ๋„๋ฉ”์ธ">โ€ฆ</span> </div> <div class="domain" id="domainStatus" hidden></div> <small id="favCount" style="color:var(--muted);font-size:11px" hidden>0</small> <button class="btn icon ghost" id="btnSearchToggle" title="๊ฒ€์ƒ‰">๐Ÿ”</button> </div> <div class="profile-bar show-on-mobile"> <div class="profile-tabs" id="profileTabsMob"></div> </div> <!-- ์ขŒ (๋ฐ์Šคํฌํƒ‘) --> <aside class="pane left hide-on-mobile" id="paneLeft"> <div class="resize-handle" id="resizeHandle" title="๋„ˆ๋น„ ์กฐ์ ˆ (๋“œ๋ž˜๊ทธ)"></div> <!-- ๋กœ๊ณ  --> <div class="brand-wrap"> <h1 class="brand"> <span class="b-ott">OTT</span> <span class="b-sep">โ”‚</span> <span class="b-player">PLAYER</span> </h1> <div class="badge-stack"> <span class="mode-badge" id="modeBadge" title="์‹คํ–‰ ๋ชจ๋“œ">โ€ฆ</span> <span class="domain-badge" id="domainBadge" title="ํ˜„์žฌ tvchak ๋„๋ฉ”์ธ">โ€ฆ</span> </div> </div> <!-- ํ”„๋กœํ•„ ํƒญ --> <div class="profile-bar"> <div class="profile-tabs" id="profileTabs"></div> </div> <!-- ๊ฒ€์ƒ‰ (๋กœ๊ณ  ๋ฐ‘) --> <div style="padding:0 10px 6px"> <div class="search-bar ac-wrap"> <input class="text" id="searchInput" type="search" placeholder="์ œ๋ชฉ์œผ๋กœ ๊ฒ€์ƒ‰" autocomplete="off" /> <button class="btn primary" id="btnSearch">๐Ÿ”</button> <div class="ac-list" id="acListDt"></div> </div> <div id="searchResultsWrap" style="display:none;margin-top:8px"> <div style="display:flex;align-items:center;gap:8px;margin-bottom:6px"> <small style="color:var(--muted);font-size:11px;flex:1">๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ</small> <button class="btn ghost" id="searchCloseDt" style="padding:2px 8px;font-size:11px">๋‹ซ๊ธฐ</button> </div> <div class="search-list" id="searchResults"></div> </div> </div> <!-- ๋ณด๊ด€ํ•จ --> <div style="padding:10px 12px 4px;border-top:1px solid var(--border);display:flex;align-items:center;gap:6px"> <h2 style="margin:0;font-size:13px;font-weight:600;color:var(--muted);letter-spacing:0.3px;flex:1">๋‚ด ๋ณด๊ด€ํ•จ</h2> <button class="btn ghost" id="btnStatsDt" title="์‹œ์ฒญ ํ†ต๊ณ„" style="padding:2px 6px;font-size:13px">โ“˜</button> </div> <div class="sort-bar"> <span>์ •๋ ฌ</span> <select id="sortSelDt"> <option value="default">์ด์–ด๋ณด๊ธฐ ์šฐ์„  (๊ธฐ๋ณธ)</option> <option value="recent">์ตœ๊ทผ ์‹œ์ฒญ์ˆœ</option> <option value="added">์ตœ๊ทผ ์ถ”๊ฐ€์ˆœ</option> <option value="title">์ œ๋ชฉ์ˆœ</option> </select> </div> <div style="padding:0 10px 0" id="favListDt"></div> <!-- ํ‚ค๋…ธ๋ผ์ด์ธ  ๋žญํ‚น --> <div class="ranking-box hide-on-mobile" id="rankingBoxDt"></div> </aside> <!-- ์ค‘์•™ --> <main class="center"> <div class="video-wrap" id="videoWrap"> <video id="player" preload="metadata" playsinline webkit-playsinline autopictureinpicture></video> <!-- 3๋ฐฐ์† ๊พน๋ˆ„๋ฅด๊ธฐ / ์ผ๋ฐ˜ ์ธํ„ฐ๋ž™์…˜ ์บก์ฒ˜์šฉ ํˆฌ๋ช… ์˜ค๋ฒ„๋ ˆ์ด. ์‚ผ์„ฑ์ธํ„ฐ๋„ทยท์ผ๋ถ€ ์•ˆ๋“œ Chrome์—์„œ <video>๊ฐ€ long-press ์ด๋ฒคํŠธ๋ฅผ ์ž์ฒด์ ์œผ๋กœ ์†Œ๋น„ํ•ด video์— ์ง์ ‘ ๋ถ™์ธ ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ์•ˆ ๋จนํž˜. z-index:2 (video=1 ์œ„) + ์šฐ๋ฆฌ UI(์ปจํŠธ๋กค๋ฐ” ๋“ฑ)๋Š” ๋” ์œ„. --> <div id="holdOverlay" class="hold-overlay"></div> <div class="video-empty" id="videoEmpty">โ–ถ ์ฆ๊ฒจ์ฐพ๊ธฐ๋ฅผ ์„ ํƒํ•˜๊ฑฐ๋‚˜ ๊ฒ€์ƒ‰ํ•ด๋ณด์„ธ์š”.</div> <div class="video-loading" id="videoLoading" style="display:none">๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ</div> <button id="btnSideToggle" class="side-toggle-btn" title="์ขŒ์ธก ํŒจ๋„ ํ† ๊ธ€">โ˜ฐ</button> <button id="btnFsZoom" class="fs-zoom-btn" title="ํ™•๋Œ€ ๊ฐ€๋Šฅํ•œ ์ „์ฒดํ™”๋ฉด">โ›ถ</button> <!-- ๋ชจ๋ฐ”์ผ ํ’€์Šคํฌ๋ฆฐ ์ „์šฉ ํ™”๋ฉด ์ž ๊ธˆ ๋ฒ„ํŠผ (์ขŒ์ธก ์ค‘์•™). ํ‰์†Œ์—” CSS๋กœ ์ˆจ๊น€. ์ดˆ๊ธฐ ์•„์ด์ฝ˜์€ "์—ด๋ฆฐ ์ž๋ฌผ์‡ " โ€” ๋ˆ„๋ฅด๋ฉด ์ž ๊ธด๋‹ค๋Š” ์˜๋ฏธ. --> <button id="btnLock" class="lock-btn" title="ํ™”๋ฉด ์ž ๊ธˆ" aria-label="ํ™”๋ฉด ์ž ๊ธˆ"> <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="4" y="11" width="16" height="10" rx="2"></rect> <path d="M8 11V8a4 4 0 0 1 8 0v3M16 5v3"></path> </svg> </button> <button id="pauseOverlay" class="pause-overlay" hidden>โ–ถ</button> <!-- ์˜คํ”„๋‹/์—”๋”ฉ ์Šคํ‚ต ๋ฒ„ํŠผ (chapter ๋˜๋Š” ์‚ฌ์šฉ์ž ๋งˆํ‚น ๊ตฌ๊ฐ„ ์ง„์ž… ์‹œ ํ‘œ์‹œ) --> <button id="btnSkip" class="skip-btn" hidden>์Šคํ‚ต โญ</button> <!-- (์ œ๊ฑฐ๋จ) โ€” ์ด์ œ zoom-ctrl์ด ์ผ๋ฐ˜/ํ’€์Šคํฌ๋ฆฐ ๊ณต์šฉ์ด๋ผ skipMarkers ํ•˜๋‚˜๋กœ ํ†ต์ผ --> <!-- (์ด์ „ #skipCtxMenu ์šฐํด๋ฆญ ๋ฉ”๋‰ด๋Š” ์ œ๊ฑฐ. ์Šคํ‚ต ๋งˆํ‚น์€ ์ปจํŠธ๋กค๋ฐ” โ‹ฎ '๋”๋ณด๊ธฐ' ๋ฉ”๋‰ด๋กœ ์ด๋™.) --> <!-- H-11: ํ™”์งˆ ์„ ํƒ / H-5: ์˜ค๋””์˜คยท์ž๋ง‰ --> <select id="hlsQuality" class="hls-quality" aria-label="ํ™”์งˆ"></select> <select id="hlsAudio" class="hls-audio" aria-label="์˜ค๋””์˜ค"></select> <select id="hlsSub" class="hls-sub" aria-label="์ž๋ง‰"></select> <!-- F-8: ๋‹ค์Œ ํ™” ๋ฏธ๋ฆฌ๋ณด๊ธฐ --> <button id="nextPreview" class="next-preview">๋‹ค์Œ โ–ถ</button> <!-- C5: ๋‹ค์Œ ํ™” ์นด์šดํŠธ๋‹ค์šด --> <div id="nextCountdown" class="next-countdown"> <div class="nc-label">๋‹ค์Œ ํ™” ์ž๋™์žฌ์ƒ๊นŒ์ง€ <span id="ncSec">5</span>์ดˆ</div> <div class="nc-title" id="ncTitle"></div> <div class="nc-bar"><div class="nc-bar-fill" id="ncBar"></div></div> <div class="nc-actions"> <button id="ncCancel">์ทจ์†Œ</button> <button id="ncGo" class="nc-go">์ง€๊ธˆ ์‹œ์ฒญ</button> </div> </div> <!-- D12: ์Œ๋Ÿ‰/์žฌ์ƒ์†๋„ ์ธ๋””์ผ€์ดํ„ฐ --> <div id="mediaToast" class="media-toast"></div> <!-- ์คŒ ๋ชจ๋“œ ์ „์šฉ ์ปจํŠธ๋กค ์˜ค๋ฒ„๋ ˆ์ด --> <div id="zoomCtrl" class="zoom-ctrl"> <button id="zcPlay" class="zc-btn" title="์žฌ์ƒ/์ผ์‹œ์ •์ง€ (Space/K)">โ–ถ</button> <span id="zcTime" class="zc-time">0:00 / 0:00</span> <input id="zcBar" class="zc-bar" type="range" min="0" max="1000" value="0" style="flex:1;" /> <button id="zcMute" class="zc-btn" title="์Œ์†Œ๊ฑฐ (M)">๐Ÿ”Š</button> <input id="zcVol" class="zc-vol" type="range" min="0" max="100" value="100" title="๋ณผ๋ฅจ" /> <button id="zcMore" class="zc-btn" title="๋”๋ณด๊ธฐ (์žฌ์ƒ์†๋„ยทPIPยท๋‹ค์šด๋กœ๋“œ)" aria-label="๋”๋ณด๊ธฐ">โ‹ฎ</button> <button id="zcReset" class="zc-btn zc-fs-only" title="์คŒ 1๋ฐฐ๋กœ">โ†บ</button> <button id="zcExit" class="zc-btn zc-fs-only" title="์ „์ฒดํ™”๋ฉด ๋‚˜๊ฐ€๊ธฐ">โœ•</button> </div> <!-- โ‹ฎ ๋”๋ณด๊ธฐ ๋ฉ”๋‰ด (PIPยท์žฌ์ƒ์†๋„ยท๋‹ค์šด๋กœ๋“œ) --> <div id="moreMenu" class="more-menu" hidden> <div class="more-sec"> <div class="more-sec-h">์žฌ์ƒ ์†๋„</div> <div class="more-rates"> <button data-rate="0.5">0.5ร—</button> <button data-rate="0.75">0.75ร—</button> <button data-rate="1">1ร—</button> <button data-rate="1.25">1.25ร—</button> <button data-rate="1.5">1.5ร—</button> <button data-rate="1.75">1.75ร—</button> <button data-rate="2">2ร—</button> </div> </div> <div class="more-actions"> <button class="more-item" id="mmPip" title="PIP (D)">๐ŸชŸ PIP</button> <button class="more-item" id="mmDownload" hidden title="๋‹ค์šด๋กœ๋“œ">โฌ‡ ๋‹ค์šด๋กœ๋“œ</button> </div> <div class="more-sec"> <div class="more-skip"> <div class="more-skip-row"> <button class="more-item more-skip-main" data-skip="opEnd" title="์˜คํ”„๋‹ ๋ (์‹œ์ž‘=0:00 ์ž๋™)"><span class="lbl">์˜คํ”„๋‹ ๋</span><span class="t" data-key="opEnd"></span></button> <button class="more-skip-clear" data-skip="clearOp" title="์˜คํ”„๋‹ ์ดˆ๊ธฐํ™”" aria-label="์˜คํ”„๋‹ ์ดˆ๊ธฐํ™”">โœ•</button> </div> <div class="more-skip-row"> <button class="more-item more-skip-main" data-skip="edFromEnd" title="์—”๋”ฉ ์Šคํ‚ต ์‹œ์ž‘์ "><span class="lbl">์—”๋”ฉ ์‹œ์ž‘</span><span class="t" data-key="edFromEnd"></span></button> <button class="more-skip-clear" data-skip="clearEd" title="์—”๋”ฉ ์ดˆ๊ธฐํ™”" aria-label="์—”๋”ฉ ์ดˆ๊ธฐํ™”">โœ•</button> </div> </div> </div> </div> </div> <!-- ๋ชจ๋ฐ”์ผ/๋ฐ์Šคํฌํƒ‘ ๋ชจ๋‘์—์„œ ๋น„๋””์˜ค ์•„๋ž˜์— ๋ฉ”ํƒ€+ํšŒ์ฐจ+(๋ชจ๋ฐ”์ผ์€ ์ฆ๊ฒจ์ฐพ๊ธฐ/๊ฒ€์ƒ‰๊นŒ์ง€) --> <div class="center-bottom content"> <div class="now-meta" id="nowMeta"></div> <!-- ํšŒ์ฐจ ๊ฐ€๋กœ ์Šคํฌ๋กค + ๊ทธ๋ฆฌ๋“œ ํ† ๊ธ€ (๊ธฐ๋ณธ ์ ‘ํž˜ โ€” ์‚ฌ์šฉ์ž๊ฐ€ '์ „์ฒด ๋ณด๊ธฐ' ํด๋ฆญ ์‹œ๋งŒ ํŽผ์นจ) --> <div id="epSection" style="display:none"> <div class="section-h"> <h2>ํšŒ์ฐจ</h2> <button class="ep-grid-toggle" id="epGridToggle">์ „์ฒด ๋ณด๊ธฐ</button> </div> <div class="ep-strip" id="epStrip"></div> <div class="ep-grid hidden" id="epGrid"> <div class="ep-search"><input type="search" id="epSearch" placeholder="ํšŒ์ฐจ ๋ฒˆํ˜ธ ๊ฒ€์ƒ‰ (์˜ˆ: 1162)" autocomplete="off" /></div> <div id="epGridList"></div> </div> </div> <!-- ๋ชจ๋ฐ”์ผ์—์„œ๋งŒ: ๊ฒ€์ƒ‰(์ƒ๋‹จ) / ์ฆ๊ฒจ์ฐพ๊ธฐ / ๋žญํ‚น --> <div class="show-on-mobile"> <!-- ๊ฒ€์ƒ‰ (๋ณด๊ด€ํ•จ ์œ„) --> <div class="section-h" id="searchHead" style="display:none"> <h2>๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ</h2> <button class="btn ghost" id="searchClose" style="padding:4px 8px;font-size:11px">๋‹ซ๊ธฐ</button> </div> <div class="search-bar ac-wrap" id="searchBar" style="display:none"> <input class="text" id="searchInputMob" type="search" placeholder="์ œ๋ชฉ์œผ๋กœ ๊ฒ€์ƒ‰" autocomplete="off" /> <button class="btn primary" id="btnSearchMob">๐Ÿ”</button> <div class="ac-list" id="acListMob"></div> </div> <div class="search-list" id="searchResultsMob" style="margin-bottom:12px"></div> <div class="section-h" style="display:flex;align-items:center;gap:6px"> <h2 style="flex:1">๋‚ด ๋ณด๊ด€ํ•จ</h2> <button class="btn ghost" id="btnStatsMob" title="์‹œ์ฒญ ํ†ต๊ณ„" style="padding:2px 8px;font-size:14px">โ“˜</button> </div> <div class="sort-bar"> <span>์ •๋ ฌ</span> <select id="sortSelMob"> <option value="default">์ด์–ด๋ณด๊ธฐ ์šฐ์„  (๊ธฐ๋ณธ)</option> <option value="recent">์ตœ๊ทผ ์‹œ์ฒญ์ˆœ</option> <option value="added">์ตœ๊ทผ ์ถ”๊ฐ€์ˆœ</option> <option value="title">์ œ๋ชฉ์ˆœ</option> </select> </div> <div class="fav-list" id="favListMob"></div> <!-- ํ‚ค๋…ธ๋ผ์ด์ธ  ๋žญํ‚น (๋ชจ๋ฐ”์ผ ๋ณด๊ด€ํ•จ ๋ฐ‘) --> <div class="ranking-box show-on-mobile" id="rankingBoxMob"></div> </div> </div> </main> <!-- G-10: ๋‹จ์ถ•ํ‚ค ์•ˆ๋‚ด ๋ชจ๋‹ฌ --> <div class="modal-bg" id="shortcutsModal"> <div class="stats-modal"> <h2 style="margin:0 0 12px;font-size:16px">๋‹จ์ถ•ํ‚ค ์•ˆ๋‚ด</h2> <div style="font-size:13px;color:var(--text)"> <div class="stat-row"><span>Space / K</span><b>์žฌ์ƒ / ์ผ์‹œ์ •์ง€</b></div> <div class="stat-row"><span>M</span><b>์Œ์†Œ๊ฑฐ ํ† ๊ธ€</b></div> <div class="stat-row"><span>โ† / โ†’</span><b>5์ดˆ ์ด๋™ (Shift = 10์ดˆ)</b></div> <div class="stat-row"><span>N / P</span><b>๋‹ค์Œ ํ™” / ์ด์ „ ํ™”</b></div> <div class="stat-row"><span>F</span><b>ํ’€์Šคํฌ๋ฆฐ (ํ™•๋Œ€ ๊ฐ€๋Šฅ)</b></div> <div class="stat-row"><span>D</span><b>Picture-in-Picture</b></div> <div class="stat-row"><span>S</span><b>์ขŒ์ธก ํŒจ๋„ ์ ‘๊ธฐ/ํŽผ์น˜๊ธฐ</b></div> <div class="stat-row"><span>+ / โˆ’</span><b>ํ’€์Šคํฌ๋ฆฐ ์˜์ƒ ํ™•๋Œ€/์ถ•์†Œ</b></div> <div class="stat-row"><span>Shift + / โˆ’</span><b>์žฌ์ƒ ์†๋„ 0.25ร— ์กฐ์ •</b></div> <div class="stat-row" style="margin-top:6px;padding-top:6px;border-top:1px solid var(--border)"><span>]</span><b>์˜คํ”„๋‹ ๋ ๋งˆํ‚น (์‹œ์ž‘=0:00 ์ž๋™)</b></div> <div class="stat-row"><span>;</span><b>์—”๋”ฉ ์Šคํ‚ต (ํ˜„์žฌ ์œ„์น˜์˜ ๋‚จ์€ ์‹œ๊ฐ„์œผ๋กœ ์ž๋™ ์ €์žฅ)</b></div> <div class="stat-row"><span>'</span><b>๋งˆํ‚น ์ „์ฒด ์ดˆ๊ธฐํ™”</b></div> <div class="stat-row" style="margin-top:6px;padding-top:6px;border-top:1px solid var(--border)"><span>?</span><b>์ด ์•ˆ๋‚ด ๋ณด๊ธฐ</b></div> <div style="margin-top:14px;font-size:11px;color:var(--muted)"> โ€ข ์˜์ƒ ์šฐํด๋ฆญ / ๊ธธ๊ฒŒ ๋ˆ„๋ฅด๊ธฐ โ†’ ๋งˆํ‚น ๋ฉ”๋‰ด<br> โ€ข โ‹ฎ ๋ฒ„ํŠผ โ†’ ์žฌ์ƒ์†๋„ยทPIPยท๋‹ค์šด๋กœ๋“œ<br> โ€ข ๋‹ค์Œ ํ™” ์นด์šดํŠธ๋‹ค์šด ์ค‘์—๋Š” Enter=์ง€๊ธˆ ์‹œ์ฒญ, Esc=์ทจ์†Œ, Space=์ผ์‹œ์ •์ง€ </div> </div> <div class="actions" style="margin-top:14px;text-align:right"> <button class="btn" id="shortcutsClose">๋‹ซ๊ธฐ</button> </div> </div> </div> <!-- D14: ์‹œ์ฒญ ํ†ต๊ณ„ ๋ชจ๋‹ฌ --> <div class="modal-bg" id="statsModal"> <div class="stats-modal"> <h2 style="margin:0 0 10px;font-size:16px">์‹œ์ฒญ ํ†ต๊ณ„</h2> <div id="statsBody" style="font-size:13px;color:var(--text)"></div> <div class="actions" style="margin-top:14px;text-align:right"> <button class="btn" id="statsClose">๋‹ซ๊ธฐ</button> </div> </div> </div> <!-- ์ถ”๊ฐ€ ๋ชจ๋‹ฌ --> <div class="modal-bg" id="addModal"> <div class="modal"> <h2>์ฆ๊ฒจ์ฐพ๊ธฐ ์ถ”๊ฐ€</h2> <label>ํ‹ฐ๋น„์ฐฉ URL ๋˜๋Š” ์˜์ƒ ID</label> <input class="text" id="addUrl" type="text" placeholder="122838 ๋˜๋Š” https://tvchakโ€ฆ/detail/id/122838.html" /> <div class="hint">์ˆซ์ž ID(์˜ˆ: <code>122838</code>) ๋˜๋Š” detail/play URL์„ ๋ถ™์—ฌ๋„ฃ์–ด๋„ ๋ฉ๋‹ˆ๋‹ค.</div> <div class="actions"> <button class="btn" id="addCancel">์ทจ์†Œ</button> <button class="btn primary" id="addOk">์ถ”๊ฐ€</button> </div> </div> </div> <script> 'use strict'; // โ”€โ”€โ”€ ์˜๊ตฌ ์ธ์ฆ ํ† ํฐ (Basic Auth ํ•œ ๋ฒˆ ํ†ต๊ณผ ํ›„ ์˜๊ตฌ ์œ ์ง€) โ”€โ”€โ”€ // localStorage์— ํ† ํฐ ์ €์žฅ โ†’ fetch ๊ฐ€๋กœ์ฑ„์„œ X-Auth-Token ํ—ค๋” ์ž๋™ ์ฒจ๋ถ€. // ์ฟ ํ‚ค๊ฐ€ ITP/์บ์‹œ ์ฒญ์†Œ๋กœ ๋งŒ๋ฃŒ๋ผ๋„ ํ† ํฐ๋งŒ ์žˆ์œผ๋ฉด ์„œ๋ฒ„๊ฐ€ ์ฆ‰์‹œ ์ฟ ํ‚ค ์žฌ๋ฐœ๊ธ‰. (function setupAuthToken() { const LS_AUTH = 'tvchak.authToken'; const _fetch = window.fetch.bind(window); window.fetch = function(input, init) { init = init || {}; const headers = new Headers(init.headers || (typeof input !== 'string' && input.headers) || {}); const tok = localStorage.getItem(LS_AUTH); if (tok && !headers.has('X-Auth-Token')) headers.set('X-Auth-Token', tok); init.headers = headers; // ์ฟ ํ‚ค ํฌํ•จ ๋ณด์žฅ if (!init.credentials) init.credentials = 'same-origin'; return _fetch(input, init); }; // ํ† ํฐ ์—†์œผ๋ฉด ํ•œ ๋ฒˆ ์š”์ฒญํ•ด์„œ ๋ฐ›์•„ ์ €์žฅ (ํ˜„์žฌ ์š”์ฒญ์€ Basic Auth/์ฟ ํ‚ค๋กœ ์ด๋ฏธ ํ†ต๊ณผํ•œ ์ƒํƒœ์—ฌ์•ผ ํ•จ) if (!localStorage.getItem(LS_AUTH)) { _fetch('/api/auth-token', { credentials: 'same-origin' }) .then(r => r.ok ? r.json() : null) .then(j => { if (j && j.token) localStorage.setItem(LS_AUTH, j.token); }) .catch(() => {}); } })(); // โ”€โ”€โ”€ ์ƒํƒœ/์ €์žฅ โ”€โ”€โ”€ const LS_PROFILE = 'tvchak.profile'; let currentProfile = parseInt(localStorage.getItem(LS_PROFILE) || '1', 10); if (!(currentProfile >= 1 && currentProfile <= 5)) currentProfile = 1; const lsKey = (k) => `tvchak.p${currentProfile}.${k}`; const LS_FAV = () => lsKey('favs'); const LS_LAST = () => lsKey('lastFavId'); const LS_RECENT_SEARCH = 'tvchak.recentSearch'; // ์ „์—ญ (ํ”„๋กœํ•„ ๋ฌด๊ด€) const LS_SORT = () => lsKey('sortMode'); const LS_RESUME_HERO_DISMISS = () => lsKey('resumeHeroDismiss'); // ๋งˆ์ง€๋ง‰ ๋‹ซ์€ favId+label // ์ตœ๊ทผ ๊ฒ€์ƒ‰์–ด (์ „์—ญ, ์ƒ์œ„ 10๊ฐœ) function loadRecentSearches() { try { return JSON.parse(localStorage.getItem(LS_RECENT_SEARCH)) || []; } catch { return []; } } function pushRecentSearch(wd) { wd = (wd || '').trim(); if (!wd) return; let list = loadRecentSearches().filter(w => w !== wd); list.unshift(wd); if (list.length > 10) list = list.slice(0, 10); localStorage.setItem(LS_RECENT_SEARCH, JSON.stringify(list)); } function removeRecentSearch(wd) { const list = loadRecentSearches().filter(w => w !== wd); localStorage.setItem(LS_RECENT_SEARCH, JSON.stringify(list)); } let favs = load(LS_FAV(), []); let lastFavId = localStorage.getItem(LS_LAST()); let domainInfo = null; let currentFavId = null; let currentFavSource = null; // 'tvchak' | 'anilife' โ€” ๊ฐ™์€ id๊ฐ€ ๋‘ ์†Œ์Šค์— ์žˆ์„ ์ˆ˜ ์žˆ์Œ let currentEpList = []; let currentEpIdx = -1; let activeRightTab = 'ep'; // ๋ฐ์Šคํฌํƒ‘ ์šฐ์ธก function load(k, def) { try { return JSON.parse(localStorage.getItem(k)) || def; } catch { return def; } } function save(k, v) { localStorage.setItem(k, JSON.stringify(v)); } // ์‚ฌ์šฉ์ž๊ฐ€ ์–ด๋–ค ํšŒ์ฐจ๋ฅผ ๋ณธ ๊ฒฐ๊ณผ lastSeenLabel/lastSeenCount๊ฐ€ ๊ฐฑ์‹ ๋  ๋•Œ ํ˜ธ์ถœ. // lastSeenLabel === latestLabel์ด๋ฉด "๋‹ค ๋”ฐ๋ผ์žก์€" ์‹œ์  โ†’ caughtUpAtLabel/Count ๋งˆํ‚น. // ์ดํ›„ ์ƒˆ ํšŒ์ฐจ๊ฐ€ ์ถ”๊ฐ€๋˜๋ฉด(=latestLabelยทknownCount ๋ณ€ํ™”) NEW ํŒ์ • ๊ฐ€๋Šฅ. function markCaughtUpIfNeeded(f) { if (!f) return; if (f.lastSeenLabel && f.latestLabel && f.lastSeenLabel === f.latestLabel) { f.caughtUpAtLabel = f.latestLabel; f.caughtUpAtCount = f.knownCount != null ? f.knownCount : (f.lastSeenCount || null); } } // ์„œ๋ฒ„ ๋™๊ธฐํ™”: saveFavs๋Š” ํ•ญ์ƒ ๋กœ์ปฌ+์„œ๋ฒ„ ์–‘์ชฝ์—. ๋นˆ๋ฒˆํ•œ PUT ๋ฐฉ์ง€๋ฅผ ์œ„ํ•ด ๋””๋ฐ”์šด์Šค. let _saveTimer = null; let _pendingPut = false; // ๋””๋ฐ”์šด์Šค ํ์— ๋“ค์–ด๊ฐ€ ์•„์ง ์„œ๋ฒ„๋กœ ์•ˆ ๊ฐ„ ๋ณ€๊ฒฝ ์žˆ์Œ์„ ํ‘œ์‹œ (pull๊ณผ ์ถฉ๋Œ ๋ฐฉ์ง€) function saveFavs() { save(LS_FAV(), favs); // ๋””๋ฐ”์šด์Šค 1์ดˆ clearTimeout(_saveTimer); _pendingPut = true; _saveTimer = setTimeout(() => { fetch('/api/favs?profile=' + currentProfile, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ favs, lastFavId }), }).catch(() => {}).finally(() => { _pendingPut = false; }); }, 1000); } // E1: ํ”„๋กœํ•„ ๋ณ„์นญ (์„œ๋ฒ„์— ์ €์žฅ โ†’ ๋ชจ๋“  ๋””๋ฐ”์ด์Šค ๊ณต์œ ) let _profileLabels = {1:'', 2:'', 3:'', 4:'', 5:''}; async function loadProfileLabels() { try { const r = await api('/api/profile-labels'); if (r && r.labels) { _profileLabels = { ..._profileLabels, ...r.labels }; renderProfileTabs(); } } catch (e) { console.warn('loadProfileLabels:', e.message); } } async function saveProfileLabel(n, name) { name = (name || '').trim().slice(0, 30); _profileLabels[n] = name; renderProfileTabs(); // n๋ฒˆ ํ”„๋กœํ•„์˜ favs payload์— nickname์„ ํ•ฉ์ณ์„œ PUT (์„œ๋ฒ„๊ฐ€ ๋‹ค๋ฅธ ํ•„๋“œ ๋ณด์กด) try { const cur = load(`tvchak.p${n}.favs`, []); const last = localStorage.getItem(`tvchak.p${n}.lastFavId`); await fetch('/api/favs?profile=' + n, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ favs: cur, lastFavId: last, nickname: name }), }); } catch (e) { console.warn('saveProfileLabel:', e.message); } } function promptProfileLabel(n) { // inline input โ€” ํ™œ์„ฑ ํƒญ ๋‚ด๋ถ€์— input ์ƒ์„ฑ for (const host of [$('#profileTabs'), $('#profileTabsMob')]) { if (!host) continue; const btn = host.querySelector(`.profile-tab[data-n="${n}"]`); if (!btn || btn.querySelector('input')) continue; const cur = _profileLabels[n] || ''; btn.textContent = ''; const inp = document.createElement('input'); inp.type = 'text'; inp.value = cur; inp.placeholder = '๋ณ„์นญ (์˜ˆ: ๋™์‹, ๊ฐ€์กฑ)'; inp.maxLength = 30; inp.style.cssText = 'width:100%;background:transparent;border:0;outline:0;color:inherit;font:inherit;text-align:center;padding:0;box-sizing:border-box;display:block;'; inp.addEventListener('click', e => e.stopPropagation()); inp.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); inp.blur(); } if (e.key === 'Escape') { e.preventDefault(); _profileLabels[n] = cur; renderProfileTabs(); } }); inp.addEventListener('blur', () => { const newName = inp.value.trim(); if (newName !== cur) saveProfileLabel(n, newName); else renderProfileTabs(); }); btn.appendChild(inp); setTimeout(() => { inp.focus(); inp.select(); }, 0); } } async function switchProfile(n) { n = parseInt(n, 10); if (!(n >= 1 && n <= 5)) return; // E1: ์ด๋ฏธ ํ™œ์„ฑ ํƒญ์„ ๋‹ค์‹œ ํด๋ฆญํ•˜๋ฉด ๋ณ„์นญ ์ž…๋ ฅ ๋ชจ๋“œ if (n === currentProfile) { promptProfileLabel(n); return; } currentProfile = n; localStorage.setItem(LS_PROFILE, String(n)); // ์ƒˆ ํ”„๋กœํ•„ ๋กœ๋”ฉ favs = load(LS_FAV(), []); lastFavId = localStorage.getItem(LS_LAST()); currentFavId = null; stopPlayer(); renderFavs(); renderProfileTabs(); await pullFavsFromServer(); renderFavs(); if (lastFavId && favs.find(f => f.id == lastFavId)) { await selectFav(+lastFavId, { silent: true }); } } function renderProfileTabs() { for (const host of [$('#profileTabs'), $('#profileTabsMob')]) { if (!host) continue; host.innerHTML = ''; for (let i = 1; i <= 5; i++) { const b = document.createElement('button'); b.className = 'profile-tab' + (i === currentProfile ? ' active' : ''); b.dataset.n = i; const lab = _profileLabels[i]; // ๋ณ„์นญ์ด ์žˆ์œผ๋ฉด ๋ณ„์นญ ํ‘œ์‹œ, ์—†์œผ๋ฉด ์ˆซ์ž. ํ™œ์„ฑ ํƒญ์€ ํด๋ฆญ ์‹œ ๋ณ„์นญ ํŽธ์ง‘. b.textContent = lab || String(i); b.title = lab ? `${lab} (ํ”„๋กœํ•„ ${i}) โ€” ๋‹ค์‹œ ํด๋ฆญํ•˜๋ฉด ์ด๋ฆ„ ์ˆ˜์ •` : `ํ”„๋กœํ•„ ${i} โ€” ๋‹ค์‹œ ํด๋ฆญํ•˜๋ฉด ์ด๋ฆ„ ์ง€์ •`; b.addEventListener('click', () => switchProfile(i)); host.appendChild(b); } } } async function pullFavsFromServer() { // ๋””๋ฐ”์šด์Šค ํ์— push ๋Œ€๊ธฐ ์ค‘์ด๋ฉด pull ๋ณด๋ฅ˜ โ€” ๋‚ด ๋กœ์ปฌ ๋ณ€๊ฒฝ์ด ๋ฎ์–ด์“ฐ์—ฌ์ง€์ง€ ์•Š๊ฒŒ if (_pendingPut) return; try { const r = await fetch('/api/favs?profile=' + currentProfile, { cache: 'no-store' }); if (!r.ok) return; const data = await r.json(); if (!Array.isArray(data.favs)) return; const serverEmpty = data.favs.length === 0; const localHasData = favs && favs.length > 0; if (serverEmpty && localHasData) { await fetch('/api/favs?profile=' + currentProfile, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ favs, lastFavId }), }).catch(() => {}); return; } if (!serverEmpty) { favs = data.favs; // ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜: source ์—†์œผ๋ฉด tvchak์œผ๋กœ ์ฑ„์›€ let migrated = false; for (const f of favs) { if (!f.source) { f.source = 'tvchak'; migrated = true; } } // 1ํšŒ์„ฑ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜: caughtUpAt* ์—†๊ณ  lastSeenLabel === latestLabel์ด๋ฉด ๋”ฐ๋ผ์žก์€ ๊ฒƒ์œผ๋กœ ๊ฐ„์ฃผ for (const f of favs) { if (f.caughtUpAtLabel == null && f.lastSeenLabel && f.latestLabel && f.lastSeenLabel === f.latestLabel) { markCaughtUpIfNeeded(f); migrated = true; } } if (data.lastFavId) { lastFavId = String(data.lastFavId); localStorage.setItem(LS_LAST(), lastFavId); } save(LS_FAV(), favs); if (migrated) saveFavs(); } } catch {} } const $ = s => document.querySelector(s); const $$ = s => [...document.querySelectorAll(s)]; const esc = s => String(s).replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c])); const isMobile = () => matchMedia('(max-width: 1023.98px)').matches; // namu CDN์€ datacenter/์ผ๋ถ€ ์‚ฌ์šฉ์ž IP๋ฅผ 403 ์ฐจ๋‹จ โ€” ์šฐ๋ฆฌ ์„œ๋ฒ„ /img-proxy ๊ฒฝ์œ ๋กœ ์šฐํšŒ. const viaProxy = (u) => /^https:\/\/i\.namu\.wiki\//.test(u || '') ? `/img-proxy?url=${encodeURIComponent(u)}` : u; // E-3: ์ƒ๋Œ€์‹œ๊ฐ ("๋ฐฉ๊ธˆ", "3๋ถ„ ์ „", "์–ด์ œ", "3์ผ ์ „" ๋“ฑ) function timeAgo(ts) { if (!ts) return ''; const sec = Math.max(0, (Date.now() - ts) / 1000); if (sec < 60) return '๋ฐฉ๊ธˆ'; if (sec < 3600) return Math.floor(sec / 60) + '๋ถ„ ์ „'; if (sec < 86400) return Math.floor(sec / 3600) + '์‹œ๊ฐ„ ์ „'; if (sec < 172800) return '์–ด์ œ'; if (sec < 604800) return Math.floor(sec / 86400) + '์ผ ์ „'; if (sec < 2592000) return Math.floor(sec / 604800) + '์ฃผ ์ „'; if (sec < 31536000) return Math.floor(sec / 2592000) + '๊ฐœ์›” ์ „'; return Math.floor(sec / 31536000) + '๋…„ ์ „'; } // H-9: ํ•œ๊ธ€ ์ดˆ์„ฑ ์ถ”์ถœ (์ž๋ชจ ๋ถ„๋ฆฌ). ์˜๋ฌธ/์ˆซ์ž/ํŠน์ˆ˜๋ฌธ์ž๋Š” ๊ทธ๋Œ€๋กœ. function toChosung(str) { const CHO = ['ใ„ฑ','ใ„ฒ','ใ„ด','ใ„ท','ใ„ธ','ใ„น','ใ…','ใ…‚','ใ…ƒ','ใ……','ใ…†','ใ…‡','ใ…ˆ','ใ…‰','ใ…Š','ใ…‹','ใ…Œ','ใ…','ใ…Ž']; let out = ''; for (const c of String(str || '')) { const code = c.charCodeAt(0) - 0xAC00; if (code >= 0 && code <= 11171) out += CHO[Math.floor(code / 588)]; else out += c.toLowerCase(); } return out; } // H-9 ํ—ฌํผ: ์ฟผ๋ฆฌ๊ฐ€ ๋ชจ๋‘ ใ„ฑ-ใ…Ž ์ž์Œ์œผ๋กœ๋งŒ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋Š”์ง€ (์ดˆ์„ฑ ๊ฒ€์ƒ‰ ๋ชจ๋“œ ํŒ์ •) function isChosungQuery(q) { return /^[ใ„ฑ-ใ…Ž\s]+$/.test(q); } // โ”€โ”€โ”€ API โ”€โ”€โ”€ // A4: API ์‹คํŒจ ์—ฐ์† ์นด์šดํŠธ โ†’ ๋ฐฐ๋„ˆ ํ‘œ์‹œ let _apiConsecutiveFail = 0; function _setErrBanner(on) { const el = document.getElementById('errBanner'); if (!el) return; el.classList.toggle('show', !!on); } async function api(path, opts = {}) { // ๊ธฐ๋ณธ 60์ดˆ timeout (HF Spaces ์‘๋‹ต ๋А๋ฆด ๋•Œ ๋Œ€๋น„). hang ๋ฐฉ์ง€. const timeoutMs = opts.timeout || 60000; const ctrl = new AbortController(); const t = setTimeout(() => ctrl.abort(), timeoutMs); try { const r = await fetch(path, { cache: 'no-store', signal: ctrl.signal }); if (!r.ok) throw new Error('HTTP ' + r.status); const j = await r.json(); if (_apiConsecutiveFail > 0) { _apiConsecutiveFail = 0; _setErrBanner(false); } return j; } catch (e) { _apiConsecutiveFail++; if (_apiConsecutiveFail >= 2) _setErrBanner(true); throw e; } finally { clearTimeout(t); } } // โ”€โ”€โ”€ ๋„๋ฉ”์ธ ํ‘œ์‹œ โ”€โ”€โ”€ async function loadDomain() { try { const d = await api('/api/domain'); domainInfo = d; const txt = d.domain ? d.domain : '๋„๋ฉ”์ธ ํƒ์ง€ ์‹คํŒจ'; $('#domainStatus').textContent = txt; if (!d.domain) $('#domainStatus').classList.add('bad'); if ($('#domainStatusDt')) $('#domainStatusDt').textContent = 'ํ˜„์žฌ: ' + txt; // ์ƒ๋‹จ ๋ฐฐ์ง€ (์ขŒ์ธก ๋ชจ๋“œ / ์šฐ์ธก ๋„๋ฉ”์ธ). ๋ฐ์Šคํฌํƒ‘ยท๋ชจ๋ฐ”์ผ ๋‘˜ ๋‹ค. const mode = d.mode || 'local'; const modeLabel = mode === 'cdp' ? 'CDP' : mode === 'hf' ? 'HF' : 'LOCAL'; for (const id of ['modeBadge', 'modeBadgeMob']) { const el = document.getElementById(id); if (!el) continue; el.textContent = modeLabel; el.classList.remove('mode-cdp', 'mode-local', 'mode-hf'); el.classList.add('mode-' + mode); } const domainShort = d.domain ? d.domain.replace(/\.com$/, '') : 'โˆ…'; const isOverride = !!(d.override || d.forced); // ์ˆ˜๋™ ๊ณ ์ • ์ƒํƒœ๋ฉด ๋ฐฐ์ง€๋ฅผ ๋…ธ๋ž—๊ฒŒ for (const id of ['domainBadge', 'domainBadgeMob']) { const el = document.getElementById(id); if (!el) continue; el.textContent = domainShort; el.classList.toggle('bad', !d.domain); el.classList.toggle('ov', isOverride && !!d.domain); el.title = (isOverride ? '์ˆ˜๋™ ๊ณ ์ •' : '์ž๋™(announce)') + ': ' + (d.domain || 'ํƒ์ง€ ์‹คํŒจ') + ' โ€” ํด๋ฆญํ•ด์„œ ๋ณ€๊ฒฝ'; } } catch (e) { $('#domainStatus').textContent = 'API ์˜ค๋ฅ˜'; $('#domainStatus').classList.add('bad'); for (const id of ['modeBadge', 'modeBadgeMob', 'domainBadge', 'domainBadgeMob']) { const el = document.getElementById(id); if (el) { el.textContent = 'ERR'; el.classList.add('bad'); } } } } // โ”€โ”€โ”€ ๋„๋ฉ”์ธ ์„ ํƒ ํŒ์—… โ”€โ”€โ”€ // ๋ฐฐ์ง€ ํด๋ฆญ โ†’ ํŒ์—…. ์ž๋™ / ๋ผ์ด๋ธŒ(tvchak.live) / ๋ฒˆํ˜ธ(tvchakNNN.com, ์ง์ ‘ ์ž…๋ ฅ) ์ค‘ ์„ ํƒ. // POST /api/domain-override ๋กœ ์„œ๋ฒ„์— ์ €์žฅ โ†’ ๋ชจ๋“  ๊ธฐ๊ธฐ ๊ณตํ†ต ๋ฐ˜์˜. '์ž๋™' ์„ ํƒ ์‹œ ์˜ค๋ฒ„๋ผ์ด๋“œ ํ•ด์ œ. function openDomainPop(anchorEl) { const pop = $('#domainPop'); if (!pop) return; const msg = $('#dpMsg'); if (msg) { msg.textContent = ''; msg.className = 'dp-msg'; } // ํ˜„์žฌ ์ƒํƒœ๋กœ ๋ผ๋””์˜ค/์ž…๋ ฅ ํ”„๋ฆฌํ•„ const d = domainInfo || {}; const cur = d.domain || ''; const numM = cur.match(/^tvchak(\d+)\.com$/); if (d.override || d.forced) { if (cur === 'tvchak.live') $('#dpLive').checked = true; else if (numM) { $('#dpNum').checked = true; $('#dpNumInput').value = numM[1]; } else $('#dpAuto').checked = true; } else { $('#dpAuto').checked = true; // ์ž๋™์ด์–ด๋„ ๋ฒˆํ˜ธ ์ž…๋ ฅ์นธ์—” ํ˜„์žฌ ๊ฐ์ง€๋œ ๋ฒˆํ˜ธ๋ฅผ ์ฐธ๊ณ ์šฉ์œผ๋กœ ์ฑ„์›Œ๋‘  if (numM && !$('#dpNumInput').value) $('#dpNumInput').value = numM[1]; } if (d.forced) { if (msg) { msg.textContent = 'โš  ์„œ๋ฒ„๊ฐ€ FORCE_DOMAIN์œผ๋กœ ๊ณ ์ • ์ค‘ โ€” ์ €์žฅํ•ด๋„ ๋ฌด์‹œ๋ฉ๋‹ˆ๋‹ค.'; msg.className = 'dp-msg err'; } } // ์œ„์น˜: ์•ต์ปค ๋ฐฐ์ง€ ์•„๋ž˜. ํ™”๋ฉด ๋ฐ–์œผ๋กœ ์•ˆ ๋‚˜๊ฐ€๊ฒŒ ํด๋žจํ”„. pop.classList.add('show'); const r = anchorEl.getBoundingClientRect(); const pw = pop.offsetWidth, ph = pop.offsetHeight; let left = Math.min(r.left, window.innerWidth - pw - 8); left = Math.max(8, left); let top = r.bottom + 6; if (top + ph > window.innerHeight - 8) top = Math.max(8, r.top - ph - 6); pop.style.left = left + 'px'; pop.style.top = top + 'px'; } function closeDomainPop() { const pop = $('#domainPop'); if (pop) pop.classList.remove('show'); } async function applyDomainOverride() { const msg = $('#dpMsg'); const setMsg = (t, cls) => { if (msg) { msg.textContent = t; msg.className = 'dp-msg ' + (cls || ''); } }; const mode = (document.querySelector('input[name="dpMode"]:checked') || {}).value; let domain = null; // null = ์ž๋™(ํ•ด์ œ) if (mode === 'live') domain = 'tvchak.live'; else if (mode === 'num') { const n = ($('#dpNumInput').value || '').trim(); if (!/^\d+$/.test(n)) { setMsg('๋ฒˆํ˜ธ๋ฅผ ์ˆซ์ž๋กœ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.', 'err'); return; } domain = 'tvchak' + n + '.com'; } setMsg('์ ์šฉ ์ค‘โ€ฆ', ''); try { const r = await fetch('/api/domain-override', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ domain }), }); const j = await r.json().catch(() => ({})); if (!r.ok || j.error) throw new Error(j.error || ('HTTP ' + r.status)); setMsg(domain ? ('๊ณ ์ •: ' + domain) : '์ž๋™(announce)์œผ๋กœ ๋ณต๊ท€', 'ok'); await loadDomain(); // ๋ฐฐ์ง€ ์ฆ‰์‹œ ๊ฐฑ์‹  // ๋„๋ฉ”์ธ์ด ๋ฐ”๋€Œ์—ˆ์œผ๋‹ˆ ํ˜„์žฌ ์—ด๋ฆฐ ํšŒ์ฐจ/๋ชฉ๋ก์€ ๋‹ค์Œ ์•ก์…˜๋ถ€ํ„ฐ ์ƒˆ ๋„๋ฉ”์ธ์œผ๋กœ fetch๋จ. setTimeout(closeDomainPop, 700); } catch (e) { setMsg('์‹คํŒจ: ' + (e.message || e), 'err'); } } // ๋ฐฐ์ง€ ํด๋ฆญ ๋ฐ”์ธ๋”ฉ (๋ฐ์Šคํฌํƒ‘ยท๋ชจ๋ฐ”์ผ) for (const id of ['domainBadge', 'domainBadgeMob']) { const el = document.getElementById(id); if (el) el.addEventListener('click', (ev) => { ev.stopPropagation(); openDomainPop(el); }); } { const applyBtn = $('#dpApply'); if (applyBtn) applyBtn.addEventListener('click', applyDomainOverride); const cancelBtn = $('#dpCancel'); if (cancelBtn) cancelBtn.addEventListener('click', closeDomainPop); // ๋ฐ”๊นฅ ํด๋ฆญ / ESC ๋กœ ๋‹ซ๊ธฐ document.addEventListener('click', (ev) => { const pop = $('#domainPop'); if (pop && pop.classList.contains('show') && !pop.contains(ev.target)) closeDomainPop(); }); document.addEventListener('keydown', (ev) => { if (ev.key === 'Escape') closeDomainPop(); }); // ๋ฒˆํ˜ธ ์ž…๋ ฅ์นธ ํฌ์ปค์Šค ์‹œ ์ž๋™์œผ๋กœ '๋ฒˆํ˜ธ' ๋ผ๋””์˜ค ์„ ํƒ const numInput = $('#dpNumInput'); if (numInput) numInput.addEventListener('focus', () => { $('#dpNum').checked = true; }); } // โ”€โ”€โ”€ ์ž…๋ ฅ ํŒŒ์‹ฑ โ”€โ”€โ”€ function parseInput(input) { input = input.trim(); let m; // anilife URL if ((m = input.match(/anilife\.app\/content\/(\d+)/i))) return { id: +m[1], source: 'anilife' }; // tvchak ํŒจํ„ด๋“ค if ((m = input.match(/\/vod\/play\/id\/(\d+)\/sid\/(\d+)\/nid\/(\d+)/))) return { id: +m[1], sid: +m[2], nid: +m[3], source: 'tvchak' }; if ((m = input.match(/\/vod\/detail\/id\/(\d+)/))) return { id: +m[1], source: 'tvchak' }; if (/^\d+$/.test(input)) return { id: +input, source: 'tvchak' }; return null; } // โ”€โ”€โ”€ ์ฆ๊ฒจ์ฐพ๊ธฐ ๋ Œ๋” โ”€โ”€โ”€ function renderFavs() { const filterMob = ($('#filterMob')?.value || '').trim().toLowerCase(); const filterDt = ($('#filter')?.value || '').trim().toLowerCase(); const activeId = currentFavId || lastFavId; // ์ •๋ ฌ: โ‘  ์ด์–ด๋ณด๊ธฐ ๊ฐ€๋Šฅ โ†’ โ‘ก NEW โ†’ โ‘ข ์ œ๋ชฉ ๊ฐ€๋‚˜๋‹ค // NEW: "๋‹ค ๋”ฐ๋ผ์žก์€ ํ›„ ์ƒˆ ํšŒ์ฐจ๊ฐ€ ์ง„์งœ๋กœ ์ถ”๊ฐ€๋œ" ๊ฒฝ์šฐ์—๋งŒ ํ‘œ์‹œ // - ์ด์–ด๋ณด๊ธฐ ์žˆ์œผ๋ฉด ์ ˆ๋Œ€ NEW ์•ˆ ๋œธ (์ด์–ด๋ณด๊ธฐ ์šฐ์„ ) // - ์‚ฌ์šฉ์ž๊ฐ€ ์ตœ์‹ ํ™” ์‹œ์ฒญ ์‹œ์ ์— caughtUpAtLabel/caughtUpAtCount ๋งˆํ‚น๋จ (markCaughtUp) // - ์ดํ›„ latestLabel์ด ๋งˆํ‚น๊ฐ’๊ณผ ๋‹ค๋ฅด๊ณ  + knownCount๊ฐ€ ์ฆ๊ฐ€ํ–ˆ์œผ๋ฉด โ†’ ์ง„์งœ ์ƒˆ ํšŒ์ฐจ ์ถ”๊ฐ€ โ†’ NEW // - ์ด์ค‘ ๊ฒ€์ฆ์œผ๋กœ ๋ผ๋ฒจ ์žฌ๋ฐฐ์—ดยท7.5ํ™” ๊ฐ™์€ ๋…ธ์ด์ฆˆ์— ๊ฐ•ํ•จ const isNewOf = f => { if (isResumableOf(f)) return false; if (!f.latestLabel || !f.caughtUpAtLabel) return false; if (f.latestLabel === f.caughtUpAtLabel) return false; if (f.knownCount == null || f.caughtUpAtCount == null) return false; return f.knownCount > f.caughtUpAtCount; }; const isResumableOf = f => { if (!f.lastLabel || !f.progress) return false; const p = f.progress[f.lastLabel]; return !!(p && !p.finished && typeof p.time === 'number' && p.time > 5); }; const rank = f => isResumableOf(f) ? 0 : (isNewOf(f) ? 1 : 2); // D2: ์ •๋ ฌ ๋ชจ๋“œ const sortMode = localStorage.getItem(LS_SORT()) || 'default'; let sorted; if (sortMode === 'recent') { sorted = [...favs].sort((a, b) => (b.clickedAt || 0) - (a.clickedAt || 0)); } else if (sortMode === 'added') { sorted = [...favs].sort((a, b) => (b.addedAt || 0) - (a.addedAt || 0)); } else if (sortMode === 'title') { sorted = [...favs].sort((a, b) => (a.title || '').localeCompare(b.title || '', 'ko')); } else { sorted = [...favs].sort((a, b) => { const r = rank(a) - rank(b); if (r !== 0) return r; if (rank(a) <= 1) return (b.clickedAt || 0) - (a.clickedAt || 0); return (a.title || '').localeCompare(b.title || '', 'ko'); }); } // ํ™œ์„ฑ(ํ˜„์žฌ ์‹œ์ฒญ ์ค‘) ์‹œ๋ฆฌ์ฆˆ๋Š” ๋ชจ๋“  ์ •๋ ฌ ๋ชจ๋“œ์—์„œ ๋ฌด์กฐ๊ฑด ๋งจ ์œ„ if (activeId != null) { const activeIdx = sorted.findIndex(f => f.id == activeId); if (activeIdx > 0) { const [active] = sorted.splice(activeIdx, 1); sorted.unshift(active); } } for (const [host, filter] of [[$('#favListMob'), filterMob], [$('#favListDt'), filterDt]]) { if (!host) continue; host.innerHTML = ''; // H-9: ์ดˆ์„ฑ ๊ฒ€์ƒ‰ ์ง€์› โ€” ์ฟผ๋ฆฌ๊ฐ€ ใ„ฑ-ใ…Ž๋งŒ์ด๋ฉด ์ดˆ์„ฑ ๋งค์นญ, ์•„๋‹ˆ๋ฉด ์ผ๋ฐ˜ substring const list = sorted.filter(f => { if (!filter) return true; const title = (f.title || '').toLowerCase(); if (title.includes(filter)) return true; if (isChosungQuery(filter)) return toChosung(f.title).includes(filter.replace(/\s/g, '')); return false; }); for (const f of list) { const isNew = isNewOf(f); const isResumable = isResumableOf(f); // ์ด์–ด๋ณด๊ธฐ + NEW ๋™์‹œ ํ‘œ์‹œ ๊ฐ€๋Šฅ (5/14 ๋‹ค ๋ณด๊ณ  5/21 ์กฐ๊ธˆ ๋ณธ ๊ฒฝ์šฐ ๋“ฑ) const newCount = (isNew && f.knownCount != null && f.lastSeenCount != null) ? Math.max(0, f.knownCount - f.lastSeenCount) : 0; // ์ง„๋„ ์‹œ๊ฐ„ (mm:ss) let resumeTimeText = ''; if (isResumable) { const t = f.progress[f.lastLabel].time; const mm = String(Math.floor(t / 60)).padStart(2, '0'); const ss = String(Math.floor(t % 60)).padStart(2, '0'); resumeTimeText = `${mm}:${ss}`; } const src = f.source || 'tvchak'; // E2: source/์นดํ…Œ๊ณ ๋ฆฌ ๋ฐฐ์ง€ โ€” anilife๋Š” ํ•ญ์ƒ "์• ๋‹ˆ", tvchak์€ fav.category(๋“œ๋ผ๋งˆ/์˜ˆ๋Šฅ ๋“ฑ)๊ฐ€ ์žˆ์œผ๋ฉด ๊ทธ๊ฑธ ์‚ฌ์šฉ let badge = ''; if (src === 'anilife') { badge = '<span class="src-badge ani">์• ๋‹ˆ</span> '; } else if (f.category) { const cls = /์˜ˆ๋Šฅ/.test(f.category) ? 'tv ent' : /์˜ํ™”/.test(f.category) ? 'tv mov' : /์• ๋‹ˆ/.test(f.category) ? 'ani' : 'tv'; badge = `<span class="src-badge ${cls}">${esc(f.category)}</span> `; } else { badge = '<span class="src-badge tv">๋“œ๋ผ๋งˆ</span> '; // tvchak ๊ธฐ๋ณธ๊ฐ’ } const div = document.createElement('div'); div.className = 'fav-item' + (String(f.id) === String(activeId) && (currentFavSource ? currentFavSource === src : true) ? ' active' : ''); if (isNew) div.dataset.new = '1'; // E-4: ์Šคํฌ๋กค ํƒ€๊นƒ if (f.title) div.title = f.title; // H-16: ์ข์€ ํŒจ๋„์—์„œ tooltip // E-2: ํฌ์Šคํ„ฐ ๋…ธ๋“œ โ€” ์œ ํšจ URL ์•„๋‹ˆ๊ฑฐ๋‚˜ placeholder ํŒจํ„ด์ด๋ฉด ๊ธ€์ž placeholder const isValidPoster = f.poster && /^https?:\/\//.test(f.poster) && !/\/template\//.test(f.poster); const initial = esc((f.title || '?').slice(0, 1)); // onerror: posterAlt ์žˆ์œผ๋ฉด ํ•œ ๋ฒˆ ์‹œ๋„, ๊ทธ๋ž˜๋„ ์‹คํŒจํ•˜๋ฉด ๊ธ€์ž placeholder const altUrl = f.posterAlt && /^https?:\/\//.test(f.posterAlt) ? esc(viaProxy(f.posterAlt)) : ''; const onerr = altUrl ? `if(this.dataset.tried){this.outerHTML='<div class=&quot;fav-poster placeholder&quot;>${initial}</div>'}else{this.dataset.tried=1;this.src='${altUrl}'}` : `this.outerHTML='<div class=&quot;fav-poster placeholder&quot;>${initial}</div>'`; const posterHTML = isValidPoster ? `<img class="fav-poster" loading="lazy" src="${esc(viaProxy(f.poster))}" alt="" referrerpolicy="no-referrer" onerror="${onerr}">` : `<div class="fav-poster placeholder">${initial}</div>`; // E-3: ์ƒ๋Œ€์‹œ๊ฐ โ€” clickedAt ์žˆ๊ณ  ์ผ์ฃผ์ผ ์ด๋‚ด์ผ ๋•Œ๋งŒ ํ‘œ์‹œ (์˜ค๋ž˜๋œ ๊ฑด ํ‘œ์‹œ ์•ˆ ํ•จ) const ago = (f.clickedAt && (Date.now() - f.clickedAt) < 7 * 86400000) ? timeAgo(f.clickedAt) : ''; div.innerHTML = ` ${posterHTML} <div class="ftxt"> <b>${badge}${esc(f.title || '(์ œ๋ชฉ ๋กœ๋”ฉโ€ฆ)')}</b> <div class="meta"> ${f.knownCount != null ? f.knownCount + 'ํ™”' : 'ID ' + f.id} ${isResumable ? ` ยท โ–ถ ${esc(f.lastLabel)} ${resumeTimeText}๋ถ€ํ„ฐ` : (f.lastSeenLabel ? ` ยท ๋งˆ์ง€๋ง‰ ${esc(f.lastSeenLabel)}` : '')} ${isNew ? ` ยท ์ตœ์‹  ${esc(f.latestLabel)}` : ''} ${ago ? `<span class="ago">ยท ${esc(ago)}</span>` : ''} </div> </div> ${(isResumable || isNew) ? `<div class="badge-col"> ${isResumable ? `<span class="resume-badge">์ด์–ด๋ณด๊ธฐ</span>` : ''} ${isNew ? `<span class="new-badge">NEW${newCount > 1 ? ' ' + newCount : ''}</span>` : ''} </div>` : ''} <div class="actcol"> <button class="delbtn" data-del="${f.id}" title="์‚ญ์ œ" aria-label="์‚ญ์ œ">โœ•</button> ${isResumable || isNew ? `<button class="markdone" data-done="${f.id}" title="๋‹ค ๋ณธ ๊ฑธ๋กœ ์ฒ˜๋ฆฌ" aria-label="๋‹ค ๋ณธ ๊ฑธ๋กœ ์ฒ˜๋ฆฌ">โœ“</button>` : '<span></span>'} </div> `; div.addEventListener('click', e => { if (e.target.dataset.del !== undefined || e.target.dataset.done !== undefined) return; selectFav(f.id, { source: src }); }); // ์šฐํด๋ฆญ/๊ธธ๊ฒŒ๋ˆ„๋ฅด๊ธฐ โ€” ํฌ์Šคํ„ฐ URL ์ˆ˜๋™ ๋ณ€๊ฒฝ. // namu ์ž๋™ ์ถ”์ถœ์ด ์•ˆ ๋˜๋Š” ์ž‘ํ’ˆ์„ ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ ๋ณด์ •ํ•  ์ˆ˜ ์žˆ๊ฒŒ. div.addEventListener('contextmenu', (e) => { e.preventDefault(); const cur = f.poster || ''; const input = prompt(`'${f.title || f.id}' ํฌ์Šคํ„ฐ URL\n(๋น„์šฐ๋ฉด ์ œ๊ฑฐ โ†’ ๊ธฐ๋ณธ ํšŒ์ƒ‰ ๋ฐ•์Šค)`, cur); if (input == null) return; // ์ทจ์†Œ const trimmed = input.trim(); if (trimmed && !/^https?:\/\//.test(trimmed)) { alert('http:// ๋˜๋Š” https://๋กœ ์‹œ์ž‘ํ•˜๋Š” URL์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.'); return; } f.poster = trimmed || null; saveFavs(); renderFavs(); }); // โœ“ ๋‹ค ๋ณธ ๊ฑธ๋กœ ์ฒ˜๋ฆฌ: ๋ชจ๋“  ํšŒ์ฐจ finished ๋งˆํ‚น + ์ตœ์‹ ๊นŒ์ง€ ๋ณธ ๊ฑธ๋กœ ๊ฐฑ์‹  div.querySelector('.markdone')?.addEventListener('click', e => { e.stopPropagation(); f.progress = f.progress || {}; // ์•Œ๋ ค์ง„ ๋ชจ๋“  ํšŒ์ฐจ์— finished:true ๋งˆํ‚น (currentEpList๊ฐ€ ์ด ์‹œ๋ฆฌ์ฆˆ์™€ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์–ด latestLabel ๊ธฐ์ค€์œผ๋กœ๋งŒ ์•ˆ์ „ํ•˜๊ฒŒ ์ฒ˜๋ฆฌ) // ์ผ๋ฐ˜ ์ผ€์ด์Šค: ํšŒ์ฐจ ๋ผ๋ฒจ์ด "Nํ™”" ํ˜•ํƒœ๋ผ 1~knownCount๊นŒ์ง€ finished ๋งˆํ‚น if (f.knownCount && f.latestLabel) { // ๋ผ๋ฒจ ํŒจํ„ด: "Nํ™”"๊ฐ€ ๊ฐ€์žฅ ํ”ํ•จ. "์ œNํšŒ"ยท"์ œNํ™”"๋„ ์žˆ์„ ์ˆ˜ ์žˆ์–ด latestLabel ์ž์ฒด๋„ finished๋กœ ๋ฐ•์Œ. for (let i = 1; i <= f.knownCount; i++) { const lab = `${i}ํ™”`; f.progress[lab] = f.progress[lab] || { time: 0 }; f.progress[lab].finished = true; f.progress[lab].time = 0; // ์ด์–ด๋ณด๊ธฐ ์•ˆ ๋œจ๋„๋ก time ์ดˆ๊ธฐํ™” } // latestLabel(์˜ˆ๋Šฅ์€ "์ œNํšŒ"์ผ ์ˆ˜ ์žˆ์Œ) ๋„ ์ง์ ‘ ๋งˆํ‚น f.progress[f.latestLabel] = f.progress[f.latestLabel] || { time: 0 }; f.progress[f.latestLabel].finished = true; f.progress[f.latestLabel].time = 0; } f.lastFinishedLabel = f.latestLabel || f.lastLabel || null; f.lastSeenLabel = f.latestLabel || null; if (f.knownCount != null) f.lastSeenCount = f.knownCount; markCaughtUpIfNeeded(f); // lastLabel/lastSid/lastNid๋Š” ๊ทธ๋Œ€๋กœ ๋‘๋˜, ์ด์–ด๋ณด๊ธฐ ํŒ์ •์—์„œ ๋น ์ง€๋„๋ก progress.time์„ 0์œผ๋กœ ๋งŒ๋“  ์ƒํƒœ๊ฐ€ ํ•ต์‹ฌ. saveFavs(); renderFavs(); if (typeof renderEpisodes === 'function' && currentFavId === f.id) renderEpisodes(); showMediaToast?.(`'${f.title || ''}' ๋‹ค ๋ณธ ๊ฑธ๋กœ ์ฒ˜๋ฆฌ๋จ`); }); div.querySelector('.delbtn').addEventListener('click', e => { e.stopPropagation(); if (confirm(`'${f.title || f.id}' ์‚ญ์ œํ• ๊นŒ์š”?`)) { favs = favs.filter(x => !(x.id === f.id && (x.source || 'tvchak') === src)); saveFavs(); if (currentFavId === f.id && currentFavSource === src) { currentFavId = null; currentFavSource = null; stopPlayer(); } renderFavs(); } }); host.appendChild(div); } } const n = favs.length; $('#favCount').textContent = n; if ($('#favCountDt')) $('#favCountDt').textContent = n; } // ์ƒ๋‹จ ๋นจ๊ฐ„ ๋กœ๋”ฉ ๋ฐ” โ€” ๋ณด๊ด€ํ•จ ํด๋ฆญ ํ›„ episodes/play ๋กœ๋“œ ํ…€์— ํ‘œ์‹œ let _topLoaderCount = 0; function showTopLoader() { _topLoaderCount++; document.getElementById('topLoader')?.classList.add('show'); } function hideTopLoader() { _topLoaderCount = Math.max(0, _topLoaderCount - 1); if (_topLoaderCount === 0) document.getElementById('topLoader')?.classList.remove('show'); } // โ”€โ”€โ”€ ์ฆ๊ฒจ์ฐพ๊ธฐ ์„ ํƒ โ”€โ”€โ”€ async function selectFav(id, opts = {}) { // source ์ง€์ •๋˜๋ฉด ๊ทธ ์†Œ์Šค์˜ favorite, ์•„๋‹ˆ๋ฉด ๊ฐ™์€ id ์ค‘ ์•„๋ฌด๊ฑฐ๋‚˜(๋ ˆ๊ฑฐ์‹œ ํ˜ธํ™˜) const f = opts.source ? favs.find(x => x.id === id && (x.source || 'tvchak') === opts.source) : favs.find(x => x.id === id); if (!f) return; if (!f.source) f.source = 'tvchak'; // ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ currentFavSource = f.source; currentFavId = id; lastFavId = String(id); localStorage.setItem(LS_LAST(), lastFavId); // ์นด๋“œ ํด๋ฆญ(=ํ˜„์žฌ ๋ณด๊ณ  ์žˆ๋Š” ์‹œ๋ฆฌ์ฆˆ)์„ ๋ชจ๋“  ๋””๋ฐ”์ด์Šค์— ์ฆ‰์‹œ ์•Œ๋ฆผ. // - clickedAt ๊ฐฑ์‹ : ์ •๋ ฌ์—์„œ "์ตœ๊ทผ ๋ณธ ๊ฒƒ" ์œ„๋กœ ์˜ฌ๋ผ์˜ด // - saveFavs: ๋””๋ฐ”์šด์Šค ํ์— ๋“ค์–ด๊ฐ€ 1์ดˆ ๋’ค ์„œ๋ฒ„ PUT (lastFavId ํฌํ•จ) โ†’ ๋‹ค๋ฅธ ๋””๋ฐ”์ด์Šค๊ฐ€ ๋‹ค์Œ pull/๋ถ€ํŒ… ๋•Œ ๋™๊ธฐํ™” // silent ๋ชจ๋“œ(๋ถ€ํŒ… ์‹œ ์ž๋™ ์„ ํƒ)์—์„  ๊ฐฑ์‹ ํ•˜์ง€ ์•Š์Œ โ€” ์‹ค์ œ ์‚ฌ์šฉ์ž ์•ก์…˜๋งŒ ๊ธฐ๋ก if (!opts.silent) { f.clickedAt = Date.now(); saveFavs(); } renderFavs(); showTopLoader(); try { await loadEpisodes(f); let { sid, nid } = opts; if (sid == null || nid == null) { // ์šฐ์„ ์ˆœ์œ„: โ‘  ๋งˆ์ง€๋ง‰ ๋ณธ ํšŒ์ฐจ์— ์ด์–ด๋ณด๊ธฐ ์ง„ํ–‰๋ฅ  ์žˆ์œผ๋ฉด ๊ทธ๊ฒƒ๋ถ€ํ„ฐ (์‚ฌ์šฉ์ž๊ฐ€ ๊ฑฐ๊ธฐ๋กœ ๋Œ์•„๊ฐ„ ์ƒํƒœ) > โ‘ก ๊ทธ ์™ธ ์ด์–ด๋ณด๊ธฐ ํ›„๋ณด ์ค‘ ์ตœ์‹  > โ‘ข lastLabel > โ‘ฃ ์ตœ์‹ ํ™” if (f.progress) { // โ‘  lastLabel์ด ์ด์–ด๋ณด๊ธฐ ๊ฐ€๋Šฅ ์ƒํƒœ๋ฉด ๋ฌด์กฐ๊ฑด ๊ทธ๊ฒƒ๋ถ€ํ„ฐ // (์‚ฌ์šฉ์ž๊ฐ€ ์˜› ํšŒ์ฐจ๋กœ ๋Œ์•„๊ฐ€ ๋ณด๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ, ์ƒˆ๋กœ๊ณ ์นจํ•ด๋„ ๊ฑฐ๊ธฐ์„œ ์žฌ๊ฐœ) if (f.lastLabel) { const lastEp = currentEpList.find(e => e.label === f.lastLabel); const lastProg = f.progress[f.lastLabel]; if (lastEp && lastProg?.time > 5 && !lastProg.finished) { sid = lastEp.sid; nid = lastEp.nid; } } // โ‘ก lastLabel์ด finished๊ฑฐ๋‚˜ ์ง„ํ–‰๋ฅ  ์—†์œผ๋ฉด โ€” ๋‹ค๋ฅธ ์ด์–ด๋ณด๊ธฐ ํ›„๋ณด ์ค‘ nid ์ž‘์€ ๊ฒƒ(=์ตœ์‹ ) if (sid == null) { const resumeCandidates = currentEpList .filter(e => f.progress[e.label]?.time > 5 && !f.progress[e.label]?.finished) .sort((a, b) => a.sid - b.sid || a.nid - b.nid); if (resumeCandidates.length) { sid = resumeCandidates[0].sid; nid = resumeCandidates[0].nid; } } } if (sid == null && f.lastSid != null && f.lastNid != null) { sid = f.lastSid; nid = f.lastNid; // ์‚ฌ์šฉ์ž๊ฐ€ ๋ช…์‹œ์ ์œผ๋กœ ํด๋ฆญํ•œ ๊ฒฝ์šฐ์—๋งŒ "๋๊นŒ์ง€ ๋ณธ ํšŒ์ฐจ โ†’ ๋‹ค์Œ ํ™”" ์ž๋™ ์ง„ํ–‰ const lastLabel = f.lastLabel || (currentEpList.find(e => e.sid === sid && e.nid === nid)?.label); if (!opts.silent && lastLabel && f.progress && f.progress[lastLabel]?.finished) { const sortedAsc = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid); const idx = sortedAsc.findIndex(e => e.label === lastLabel); if (idx > 0) { const nextNewer = sortedAsc[idx - 1]; sid = nextNewer.sid; nid = nextNewer.nid; } } } if (sid == null && currentEpList.length) { // ์‹œ์ฒญ๊ธฐ๋ก ์—†์œผ๋ฉด ์‹œ๋ฆฌ์ฆˆ 1ํ™”๋ถ€ํ„ฐ (์Šคํ† ๋ฆฌ์ƒ ์ฒซ ํšŒ). ์‚ฌ์ดํŠธ์˜ nid๊ฐ€ ๊ฐ€์žฅ ํฐ ๊ฒƒ์ด 1ํ™”. const ep1 = [...currentEpList].sort((a, b) => b.sid - a.sid || b.nid - a.nid)[0]; sid = ep1.sid; nid = ep1.nid; console.log('[selectFav] ์‹œ์ฒญ๊ธฐ๋ก ์—†์Œ โ†’ 1ํ™” ์ž๋™์„ ํƒ', ep1); } if (sid == null) return; console.log('[selectFav] ์ตœ์ข… ์„ ํƒ:', { sid, nid, fromFav: { lastSid: f.lastSid, lastNid: f.lastNid }, opts }); } await playEpisode(id, sid, nid, { userInitiated: !opts.silent }); } finally { hideTopLoader(); } } // โ”€โ”€โ”€ ํšŒ์ฐจ ๋ชฉ๋ก โ”€โ”€โ”€ async function loadEpisodes(fav) { $('#epSection').style.display = 'none'; try { const src = fav.source || 'tvchak'; const titleQ = fav.title ? `&title=${encodeURIComponent(fav.title)}` : ''; // ํด๋ฐฑ ๋งคํ•‘ ํžŒํŠธ: ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์•Œ๊ณ  ์žˆ๋Š” linkkf id + anilife ํšŒ์ฐจ ์ˆ˜ โ†’ ์„œ๋ฒ„๊ฐ€ ๊ฒ€์ƒ‰ ๋‹จ๊ณ„ ์Šคํ‚ต ๊ฐ€๋Šฅ const fbQ = (src === 'anilife' && fav.fallbackLinkkfId) ? `&fallbackId=${fav.fallbackLinkkfId}` : ''; const countQ = (src === 'anilife' && fav.knownCount) ? `&count=${fav.knownCount}` : ''; const ep = await api(`/api/episodes?id=${fav.id}&source=${src}${titleQ}${fbQ}${countQ}`); if (ep.error) { console.warn('episodes', ep.error); return; } if (ep.title && !fav.title) fav.title = ep.title; if (ep.category && !fav.category) fav.category = ep.category; // E2: tvchak ์นดํ…Œ๊ณ ๋ฆฌ (๋“œ๋ผ๋งˆ/์˜ˆ๋Šฅ/์˜ํ™” ๋“ฑ) // linkkf ํด๋ฐฑ ์‚ฌ์šฉ ์‚ฌ์‹ค ์ €์žฅ โ€” ๋‹ค์Œ ํ˜ธ์ถœ์— fallbackId ์ง์ ‘ ์ „๋‹ฌ if (ep._fallbackLinkkfId) fav.fallbackLinkkfId = ep._fallbackLinkkfId; fav.usingFallback = ep._fallbackSource || null; // UI ๋ฐฐ์ง€์šฉ // E-2: ์˜› placeholder URL ์ •๋ฆฌ + ep ์‘๋‹ต์˜ poster ํ™œ์šฉ + posterAlt (anilife์šฉ fallback) if (fav.poster && /\/template\//.test(fav.poster)) fav.poster = null; if (ep.poster) fav.poster = ep.poster; // ํ•ญ์ƒ ์ตœ์‹ ๊ฐ’์œผ๋กœ ๊ฐฑ์‹  (์„œ๋ฒ„๊ฐ€ namu fallback ๊ฑฐ์นœ ๊ฒฐ๊ณผ) if (ep.posterAlt) fav.posterAlt = ep.posterAlt; fav.knownCount = ep.count; // ์‚ฌ์ดํŠธ์˜ ์ตœ์‹  ํšŒ์ฐจ ๋ผ๋ฒจ (nid=1) const latest = (ep.episodes || []).find(e => e.sid === 1 && e.nid === 1) || (ep.episodes || [])[0]; // ๋ผ๋ฒจ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜: ๊ธฐ์กด progress/lastLabel ์ด dateLabel(์˜ˆ: "26/05/19") ์ด์—ˆ์œผ๋ฉด ์ƒˆ label("1ํ™”") ๋กœ ๊ต์ฒด. // ์„œ๋ฒ„๊ฐ€ ์ •๊ทœํ™”๋œ label + ์›๋ณธ dateLabel์„ ๊ฐ™์ด ์คŒ. ๋‘˜ ๋‹ค ํ™•์ธํ•ด์„œ ๋งคํ•‘. if (Array.isArray(ep.episodes)) { const oldToNew = {}; for (const e of ep.episodes) { if (e.dateLabel && e.dateLabel !== e.label) oldToNew[e.dateLabel] = e.label; } // progress ํ‚ค ๊ต์ฒด if (fav.progress && Object.keys(oldToNew).length) { const newProg = {}; for (const k of Object.keys(fav.progress)) { const newK = oldToNew[k] || k; newProg[newK] = fav.progress[k]; } fav.progress = newProg; } // lastLabel / lastSeenLabel / lastFinishedLabel ๋งคํ•‘ for (const key of ['lastLabel', 'lastSeenLabel', 'lastFinishedLabel']) { if (fav[key] && oldToNew[fav[key]]) fav[key] = oldToNew[fav[key]]; } } fav.latestLabel = latest?.label || null; // ์ฒ˜์Œ ๋“ฑ๋กํ•œ ๊ฒฝ์šฐ์—” "์ด๋ฏธ ๋ณธ ์‹œ์ "์„ ํ˜„์žฌ ์ตœ์‹ ํ™”๋กœ ๊ฐ„์ฃผ (๊ทธ๋Ÿฌ๋ฉด NEW๊ฐ€ ๋– ๋ฒ„๋ฆฌ๋Š” ๊ฑธ ๋ง‰์Œ) if (fav.lastSeenLabel == null) { fav.lastSeenLabel = fav.latestLabel; fav.lastSeenCount = ep.count; } markCaughtUpIfNeeded(fav); saveFavs(); currentEpList = ep.episodes || []; renderEpisodes(); $('#epSection').style.display = currentEpList.length ? '' : 'none'; } catch (e) { console.warn('loadEpisodes', e); } } function renderEpisodes() { const strip = $('#epStrip'); const gridList = $('#epGridList'); strip.innerHTML = ''; if (gridList) gridList.innerHTML = ''; if (!currentEpList.length) return; const fav = favs.find(f => f.id === currentFavId); // ์‚ฌ์ดํŠธ๊ฐ€ ๋ณด๋‚ด๋Š” ์ˆœ์„œ ๊ทธ๋Œ€๋กœ (nid=1์ด ์ด๋ฏธ ์ตœ์‹ ). ๊ทธ๋ž˜๋„ ์•ˆ์ „ํ•˜๊ฒŒ nid ์˜ค๋ฆ„์ฐจ์ˆœ ๋ณด์žฅ. const ordered = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid); // ํšŒ์ฐจ ๊ทธ๋ฃนํ™” ๋น„ํ™œ์„ฑ โ€” ๋ชจ๋“  ์นฉ์„ ๋‹จ์ˆœ grid์— ํ‰ํƒ„ํ•˜๊ฒŒ ํ‘œ์‹œ const epGridEl = document.getElementById('epGrid'); if (epGridEl) epGridEl.classList.remove('grouped'); for (const ep of ordered) { const isCur = currentEpIdx >= 0 && currentEpList[currentEpIdx] && currentEpList[currentEpIdx].sid === ep.sid && currentEpList[currentEpIdx].nid === ep.nid; const label = ep.label || `${ep.nid}ํ™”`; // A2: ์ง„๋„ ๊ณ„์‚ฐ + E-14: ๋ฏธ์‹œ์ฒญ ์  const prog = fav?.progress?.[label]; const finished = !!prog?.finished; const hasProgress = !!(prog && (prog.time > 5 || finished)); const dur = (prog?.time && prog?.duration && prog.duration > 0) ? (prog.time / prog.duration) : 0; const widthPct = finished ? 100 : Math.min(95, Math.max(0, Math.round(dur * 100))); const make = (fromGrid) => { const b = document.createElement('button'); b.className = 'ep-chip' + (isCur ? ' active' : '') + (finished ? ' finished' : '') + (!hasProgress ? ' unwatched' : ''); b.dataset.label = label; b.innerHTML = esc(label) + (finished ? '<span class="ep-check">โœ“</span>' : '') + (widthPct > 0 ? `<span class="ep-progress" style="width:${widthPct}%"></span>` : ''); b.addEventListener('click', () => { playEpisode(currentFavId, ep.sid, ep.nid); if (fromGrid) { const v = $('#videoWrap') || $('#player'); v?.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); return b; }; strip.appendChild(make(false)); if (gridList) gridList.appendChild(make(true)); } requestAnimationFrame(() => { const active = strip.querySelector('.ep-chip.active'); if (active) active.scrollIntoView({ behavior: 'auto', inline: 'center', block: 'nearest' }); }); updateEpNavButtons(); // F-13 } // B13: ํšŒ์ฐจ ๊ฒ€์ƒ‰ ํ•„ํ„ฐ (function setupEpSearch() { const inp = document.getElementById('epSearch'); if (!inp) return; inp.addEventListener('input', () => { const q = inp.value.trim().toLowerCase(); const items = document.querySelectorAll('#epGridList .ep-chip'); items.forEach(el => { const lab = (el.dataset.label || el.textContent || '').toLowerCase(); el.classList.toggle('ep-hidden', !!q && !lab.includes(q)); }); }); })(); $('#epGridToggle')?.addEventListener('click', () => { const grid = $('#epGrid'); const isHidden = grid.classList.toggle('hidden'); $('#epGridToggle').textContent = isHidden ? '์ „์ฒด ๋ณด๊ธฐ' : '์ ‘๊ธฐ'; }); // ์ „์—ญ hls ์ธ์Šคํ„ด์Šค (anilife ์žฌ์ƒ ์‹œ ์‚ฌ์šฉ) let _currentHls = null; // ํ˜„์žฌ ์˜์ƒ์˜ chapter (anilife) - { op:{start,end}, ed:{start,end} } ๋˜๋Š” null let _currentSkips = null; // ์Šคํ‚ต ๋งˆํ‚น ์‹œ๊ฐ ํ‘œ์‹œ๋Š” ์šฐํด๋ฆญ ๋ฉ”๋‰ด ์•ˆ์—์„œ๋งŒ (progressbar ๋งˆ์ปค๋Š” ์ œ๊ฑฐ๋จ). // ๋ฉ”๋‰ด ์—ด ๋•Œ๋งˆ๋‹ค fav.skip ์ฝ์–ด ๊ฐ ๋ฒ„ํŠผ์˜ .t์— ์‹œ๊ฐ„ ํ…์ŠคํŠธ ์ฑ„์›€. const DEFAULT_ED_FROM_END_MIN = 2.0; // fav.skip ๊ฐ์ฒด์™€ ํ˜„์žฌ ์˜์ƒ์˜ duration์„ ๋ณด๊ณ  _currentSkips๋ฅผ ์žฌ๊ณ„์‚ฐ. // ์šฐ์„ ์ˆœ์œ„: โ‘  edFromEnd(์ž๋™, ๊ถŒ์žฅ) โ‘ก edStart/edEnd(๊ตฌ๋ฒ„์ „ ๋ช…์‹œ ๋งˆํ‚น). duration ๋ฏธ์ •์ด๋ฉด timeupdate์—์„œ ๋Šฆ๊ฒŒ ์ฑ„์›€. function rebuildCurrentSkips(fav) { if (!fav?.skip) { _currentSkips = null; return; } const s = fav.skip; const skips = {}; if (typeof s.opStart === 'number' && typeof s.opEnd === 'number' && s.opEnd > s.opStart) { skips.op = { start: s.opStart, end: s.opEnd }; } // ์—”๋”ฉ: edFromEnd๊ฐ€ ์žˆ์œผ๋ฉด ์ž๋™ ๋ชจ๋“œ (duration ์•Œ ๋•Œ๋งŒ ํ™œ์„ฑ) const v = document.getElementById('player'); const dur = v && isFinite(v.duration) ? v.duration : 0; if (typeof s.edFromEnd === 'number' && s.edFromEnd > 0) { if (dur > 0) { const edStart = Math.max(0, dur - s.edFromEnd * 60); skips.ed = { start: edStart, end: dur }; } // dur ์•„์ง ๋ชจ๋ฅด๋ฉด ed ๋ฏธ์„ค์ • โ€” duration ๋„์ฐฉ ํ›„ timeupdate ์ธก์—์„œ ๋‹ค์‹œ ๋นŒ๋“œ๋จ } else if (typeof s.edStart === 'number') { skips.ed = { start: s.edStart, end: (typeof s.edEnd === 'number' && s.edEnd > s.edStart) ? s.edEnd : Infinity }; } _currentSkips = (skips.op || skips.ed) ? skips : null; } function updateSkipMenuLabels() { const menu = document.getElementById('skipCtxMenu'); const moreMenu = document.getElementById('moreMenu'); if (!menu && !moreMenu) return; const fav = currentFavId ? favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === (currentFavSource || 'tvchak')) : null; const s = fav?.skip || {}; const fmt = (n) => (typeof n === 'number') ? `${Math.floor(n/60)}:${String(Math.floor(n%60)).padStart(2,'0')}` : ''; // edFromEnd ๋ผ๋ฒจ: ํ˜„์žฌ ์˜์ƒ์˜ ๋‚จ์€ ์‹œ๊ฐ„(๋ถ„)์„ ๋ณด์—ฌ์ค˜ ์‚ฌ์šฉ์ž๊ฐ€ "์ง€๊ธˆ ํด๋ฆญํ•˜๋ฉด ์ด ๊ฐ’์œผ๋กœ ์ €์žฅ๋œ๋‹ค"๋Š” ๊ฑธ ์ง๊ด€์ ์œผ๋กœ ์•Œ๊ฒŒ ํ•จ. // ์˜์ƒ ๋ฏธ๋กœ๋”ฉ์ด๊ฑฐ๋‚˜ currentTime์ด ๋ ๊ทผ์ฒ˜ ์•„๋‹ˆ๋ฉด ๊ธฐ์กด ์ €์žฅ๊ฐ’ ํ‘œ์‹œ. const v = document.getElementById('player'); const dur = v && isFinite(v.duration) ? v.duration : 0; const remainMin = dur > 0 ? Math.max(0, (dur - v.currentTime) / 60) : 0; const targets = []; if (menu) targets.push(...menu.querySelectorAll('.t')); if (moreMenu) targets.push(...moreMenu.querySelectorAll('.t')); for (const el of targets) { const key = el.dataset.key; if (key === 'edFromEnd') { if (remainMin > 0 && remainMin < 30) { // ํ˜„์žฌ ์œ„์น˜ ๊ธฐ์ค€ โ€” ํด๋ฆญ ์‹œ ์ด ๊ฐ’์ด ์ €์žฅ๋จ el.textContent = `โ†’ ${remainMin.toFixed(1)}๋ถ„`; } else if (typeof s.edFromEnd === 'number') { el.textContent = `${s.edFromEnd}๋ถ„`; } else { el.textContent = '์—”๋”ฉ์—์„œ ํด๋ฆญ'; } } else { el.textContent = fmt(s[key]); } } } // ์Šคํ‚ต ๋งˆํ‚น ๊ณตํ†ต ์ ์šฉ ํ•จ์ˆ˜ โ€” ํ‚ค๋ณด๋“œยท์šฐํด๋ฆญ ๋ฉ”๋‰ด ๊ณตํ†ต ์ง„์ž…์ . // kind: 'opStart' | 'opEnd' | 'edStart' | 'edEnd' | 'clear' function applySkipMark(kind) { const v = document.getElementById('player'); if (!v || !currentFavId) return; const fav = favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === (currentFavSource || 'tvchak')); if (!fav) return; const t = Math.floor(v.currentTime); const fmt = (s) => `${Math.floor(s/60)}:${String(s%60).padStart(2,'0')}`; let msg = ''; if (kind === 'clear') { delete fav.skip; msg = '์Šคํ‚ต ๋งˆํ‚น ์ดˆ๊ธฐํ™”'; } else if (kind === 'clearOp') { if (fav.skip) { delete fav.skip.opStart; delete fav.skip.opEnd; if (Object.keys(fav.skip).length === 0) delete fav.skip; } msg = '์˜คํ”„๋‹ ๋งˆํ‚น ์ดˆ๊ธฐํ™”'; } else if (kind === 'clearEd') { if (fav.skip) { delete fav.skip.edStart; delete fav.skip.edEnd; delete fav.skip.edFromEnd; if (Object.keys(fav.skip).length === 0) delete fav.skip; } msg = '์—”๋”ฉ ๋งˆํ‚น ์ดˆ๊ธฐํ™”'; } else { fav.skip = fav.skip || {}; if (kind === 'opStart') { fav.skip.opStart = t; msg = `์˜คํ”„๋‹ ์‹œ์ž‘: ${fmt(t)}`; } else if (kind === 'opEnd') { // ์˜คํ”„๋‹ ๋ ๋งˆํ‚น: ์‹œ์ž‘์ด ๋ฏธ์„ค์ •์ด๋ฉด ์ž๋™์œผ๋กœ 0์ดˆ (์‚ฌ์šฉ์ž๊ฐ€ ํ•œ ๋ฒˆ ํด๋ฆญ์œผ๋กœ ์™„๋ฃŒ) fav.skip.opEnd = t; if (typeof fav.skip.opStart !== 'number') fav.skip.opStart = 0; msg = `์˜คํ”„๋‹ ์Šคํ‚ต: ${fmt(fav.skip.opStart)} ~ ${fmt(t)}`; } else if (kind === 'edFromEnd') { // ์—”๋”ฉ: ํด๋ฆญ ์‹œ์ ์˜ ๋‚จ์€ ์‹œ๊ฐ„์„ ์ž๋™์œผ๋กœ edFromEnd๋กœ ์ €์žฅ. ์‚ฌ์šฉ์ž๊ฐ€ ์—”๋”ฉ ์‹œ์ž‘์ ์— ์œ„์น˜ํ•œ ํ›„ ํด๋ฆญํ•˜๋Š” ๊ฒŒ ์ž์—ฐ์Šค๋Ÿฌ์›€. // duration ๋ชจ๋ฅด๊ฑฐ๋‚˜ ๋‚จ์€ ์‹œ๊ฐ„์ด ๋„ˆ๋ฌด ๊ธธ๊ฑฐ๋‚˜(์—”๋”ฉ ์•„๋‹˜) ๋„ˆ๋ฌด ์งง์œผ๋ฉด ๊ฑฐ๋ถ€. if (!isFinite(v.duration) || v.duration <= 0) { if (typeof showToast === 'function') showToast('์˜์ƒ ๊ธธ์ด๋ฅผ ์•Œ ์ˆ˜ ์—†์Œ โ€” ์ž ์‹œ ํ›„ ๋‹ค์‹œ'); return; } const remain = v.duration - v.currentTime; const remainMin = remain / 60; if (remainMin <= 0 || remainMin >= 30) { if (typeof showToast === 'function') showToast('์—”๋”ฉ ์‹œ์ž‘ ์ง€์ (๋ 30๋ถ„ ์ด๋‚ด)์œผ๋กœ ์ด๋™ ํ›„ ๋‹ค์‹œ'); return; } const m = Math.round(remainMin * 10) / 10; // ์†Œ์ˆ˜ 1์ž๋ฆฌ fav.skip.edFromEnd = m; delete fav.skip.edStart; delete fav.skip.edEnd; msg = `์—”๋”ฉ ์Šคํ‚ต: ๋๋‚˜๊ธฐ ${m}๋ถ„ ์ „๋ถ€ํ„ฐ`; } else return; // ์ •๊ทœํ™”: ์‹œ์ž‘ยท๋์ด ๋’ค์ง‘ํžŒ ๊ฒฝ์šฐ ์ž๋™ swap (์‚ฌ์šฉ์ž๊ฐ€ ํ‚ค ์ˆœ์„œ ํ—ท๊ฐˆ๋ ธ์„ ๋•Œ ์ž๋™ ๋ณด์ •) if (fav.skip.opStart != null && fav.skip.opEnd != null && fav.skip.opStart > fav.skip.opEnd) { [fav.skip.opStart, fav.skip.opEnd] = [fav.skip.opEnd, fav.skip.opStart]; msg += ' (์ž๋™ ์ •๋ ฌ)'; } if (fav.skip.edStart != null && fav.skip.edEnd != null && fav.skip.edStart > fav.skip.edEnd) { [fav.skip.edStart, fav.skip.edEnd] = [fav.skip.edEnd, fav.skip.edStart]; msg += ' (์ž๋™ ์ •๋ ฌ)'; } } saveFavs(); // ํ˜„์žฌ ์˜์ƒ์—๋„ ์ฆ‰์‹œ ๋ฐ˜์˜ rebuildCurrentSkips(fav); updateSkipMenuLabels(); if (typeof showToast === 'function') showToast(msg); } // (์ด์ „: ์šฐํด๋ฆญ/๊ธธ๊ฒŒ๋ˆ„๋ฅด๊ธฐ โ†’ ์Šคํ‚ต ๋งˆํ‚น ์ปจํ…์ŠคํŠธ ๋ฉ”๋‰ด. ์ œ๊ฑฐ๋จ. // ์Šคํ‚ต ๋งˆํ‚น์€ ์ปจํŠธ๋กค๋ฐ” โ‹ฎ '๋”๋ณด๊ธฐ' ๋ฉ”๋‰ด์—์„œ๋งŒ ์ ‘๊ทผ.) // โ”€โ”€โ”€ ์žฌ์ƒ โ”€โ”€โ”€ async function playEpisode(id, sid, nid, opts = {}) { const userInitiated = opts.userInitiated !== false; // ๊ธฐ๋ณธ true $('#videoLoading').style.display = 'block'; $('#videoEmpty').classList.add('hide'); // ์ด์ „ ํšŒ์ฐจ์—์„œ ๋„์›Œ๋‘” ์นด์šดํŠธ๋‹ค์šด์ด ์žˆ์œผ๋ฉด ์ฆ‰์‹œ ์ •๋ฆฌ (์ž๋™ ๋‹ค์Œํ™” ์ง„์ž… ์‹œ ์ž”์กด ๋ฐฉ์ง€) try { cancelNextCountdown(); } catch {} // ์ž๋™ ์Šคํ‚ต ํ”Œ๋ž˜๊ทธ ํšŒ์ฐจ๋งˆ๋‹ค ๋ฆฌ์…‹ (op ์ž๋™์ ํ”„ / ed ์ž๋™ ์นด์šดํŠธ๋‹ค์šด ๊ฐ 1ํšŒ์”ฉ) playEpisode._opAutoSkipped = false; playEpisode._edAutoTriggered = false; playEpisode._clickedAtBumpedForCurrent = false; // src ๊ต์ฒด ์งํ›„, ์ƒˆ ์˜์ƒ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋„์ฐฉ(loadeddata) ์ „๊นŒ์ง€๋Š” // ์ด์ „ ์˜์ƒ์˜ currentTime์œผ๋กœ timeupdate๊ฐ€ ํ•œ๋‘ ๋ฒˆ ๋” ๋ฐœํ™”ํ•  ์ˆ˜ ์žˆ๋‹ค. // ๊ทธ ๋™์•ˆ ์—”๋”ฉ ์ž๋™ ํŠธ๋ฆฌ๊ฑฐ๊ฐ€ ๋‘ ๋ฒˆ ๋ฐœ์‚ฌ๋˜๋Š” ์‚ฌ๊ณ  ์ฐจ๋‹จ. playEpisode._skipsLoading = true; try { const fav = favs.find(f => f.id === id); const src = (fav?.source) || 'tvchak'; const v = $('#player'); // ์ด์ „ HLS ์ •๋ฆฌ if (_currentHls) { try { _currentHls.destroy(); } catch {} _currentHls = null; } // ์‚ฌ์šฉ์ž๊ฐ€ ๋งˆํ‚นํ•œ ์˜คํ”„๋‹/์—”๋”ฉ ๊ตฌ๊ฐ„ ์ ์šฉ (๊ฐ™์€ ์‹œ๋ฆฌ์ฆˆ = ๊ฐ™์€ fav ์•ˆ์—์„œ ๋ชจ๋“  ํšŒ์ฐจ ๊ณตํ†ต). // ์—”๋”ฉ์€ fav.skip.edFromEnd(๋๋‚˜๊ธฐ N๋ถ„ ์ „, ์ž๋™)์„ ์šฐ์„  ์‚ฌ์šฉ. duration ๋ฏธ์ •์ด๋ฉด loadedmetadata ํ›„ ์žฌ๋นŒ๋“œ๋จ. // tvchakยทanilife ๋‘˜ ๋‹ค ๋™์ผํ•˜๊ฒŒ ๋™์ž‘. ์‚ฌ์šฉ์ž ๋งˆํ‚น์€ anilife ์ž๋™ chapter๋ณด๋‹ค ์šฐ์„ . rebuildCurrentSkips(fav); let proxyUrl, isHls = false, p; if (src === 'anilife') { // anilife: nid๊ฐ€ episode_num, uniqueId๋Š” currentEpList์—์„œ ์กฐํšŒ let ep = currentEpList.find(e => e.nid === nid) || currentEpList.find(e => e.sid === sid && e.nid === nid); // currentEpList๊ฐ€ ๋น„์–ด์žˆ๊ฑฐ๋‚˜ ๋งค์นญ ์‹คํŒจ๋ฉด fav.id์˜ episodes๋ฅผ ์ฆ‰์‹œ ๋‹ค์‹œ ๋กœ๋“œ (race ๋ณต๊ตฌ) if (!ep?.uniqueId && fav) { console.warn('[play] currentEpList ๋งค์นญ ์‹คํŒจ, episodes ๋‹ค์‹œ ๋กœ๋“œ'); try { await loadEpisodes(fav); ep = currentEpList.find(e => e.nid === nid) || currentEpList.find(e => e.sid === sid && e.nid === nid); } catch {} } const uniqueId = ep?.uniqueId; if (!uniqueId) throw new Error('uniqueId not found for nid=' + nid); p = await api(`/api/play?source=anilife&uniqueId=${encodeURIComponent(uniqueId)}`); if (p.error || !p.manifest) throw new Error(p.error || 'no manifest'); const b64 = btoa(p.manifest); proxyUrl = '/cdn?b64=1&u=' + encodeURIComponent(b64) + '&r=' + encodeURIComponent(p.referer || 'https://anilife.app/'); isHls = true; // chapter โ†’ ์˜คํ”„๋‹/์—”๋”ฉ ์ถ”์ •. ํœด๋ฆฌ์Šคํ‹ฑ: // - ์ฒซ chapter (5๋ถ„ ์ดํ•˜)๋ฉด ์˜คํ”„๋‹ // - ๋งˆ์ง€๋ง‰ chapter (๋˜๋Š” ๋์—์„œ ๋‘๋ฒˆ์งธ, 5๋ถ„ ์ดํ•˜)๋ฉด ์—”๋”ฉ // - "ํŠธ๋ ˆ์ผ๋Ÿฌ/๋‹ค์Œํ™” ์˜ˆ๊ณ "์šฉ ๋ฏธ์„ธ chapter๋Š” ๋ฌด์‹œ // ์‚ฌ์šฉ์ž ๋งˆํ‚น(_currentSkips ์ด๋ฏธ ์„ค์ •๋จ)์ด ์žˆ์œผ๋ฉด ์ž๋™ chapter๋Š” ๋ฌด์‹œ if (!_currentSkips && Array.isArray(p.chapters) && p.chapters.length >= 2) { const chs = p.chapters; const skips = {}; // ์˜คํ”„๋‹: ์ฒซ chapter, ์‹œ์ž‘ 0 ๊ทผ์ฒ˜ + ๊ธธ์ด 10~300์ดˆ if (chs[0] && chs[0].start <= 5 && (chs[0].end - chs[0].start) <= 300 && (chs[0].end - chs[0].start) >= 10) { skips.op = { start: chs[0].start, end: chs[0].end }; } // ์—”๋”ฉ: ๋์—์„œ๋ถ€ํ„ฐ ์—ญ์ˆœ์œผ๋กœ, ๊ธธ์ด 10~300์ดˆ์ด๋ฉด์„œ ์˜์ƒ ๋๊นŒ์ง€ ๊ฐ€๊นŒ์šด ๊ฒƒ for (let i = chs.length - 1; i >= 0; i--) { const len = chs[i].end - chs[i].start; if (len >= 10 && len <= 300) { skips.ed = { start: chs[i].start, end: chs[i].end }; break; } } if (skips.op || skips.ed) _currentSkips = skips; } } else { p = await api(`/api/play?id=${id}&sid=${sid}&nid=${nid}`); if (p.error || !p.url) { const err = new Error(p.error || 'no url'); err.code = p.code; throw err; } proxyUrl = '/cdn?u=' + encodeURIComponent(p.url) + '&r=' + encodeURIComponent(p.referer || ''); } // H-11/H-5: HLS selectors ์ดˆ๊ธฐํ™” const qSel = document.getElementById('hlsQuality'); const aSel = document.getElementById('hlsAudio'); const sSel = document.getElementById('hlsSub'); for (const s of [qSel, aSel, sSel]) if (s) { s.innerHTML = ''; s.classList.remove('has-levels'); } if (isHls) { const ua = navigator.userAgent; const isSafari = /^((?!chrome|android).)*safari/i.test(ua); // hls.js๋Š” defer ๋กœ๋“œ๋ผ m3u8 ์˜์ƒ์„ ๋น ๋ฅด๊ฒŒ ํด๋ฆญํ•œ ๊ฒฝ์šฐ ์•„์ง ๋„์ฐฉ ์ „์ผ ์ˆ˜ ์žˆ์Œ โ€” ์ตœ๋Œ€ 2์ดˆ ์งง๊ฒŒ ๋Œ€๊ธฐ if (!window.Hls && !isSafari) { const t0 = Date.now(); while (!window.Hls && Date.now() - t0 < 2000) { await new Promise(r => setTimeout(r, 50)); } } if (window.Hls && Hls.isSupported() && !isSafari) { const hls = new Hls({ xhrSetup: (xhr) => { xhr.withCredentials = false; } }); _currentHls = hls; hls.loadSource(proxyUrl); hls.attachMedia(v); // ๋ณ€์ข… ํŠธ๋ž™ ๋„์ฐฉ ์‹œ ์…€๋ ‰ํŠธ ์ฑ„์šฐ๊ธฐ hls.on(Hls.Events.MANIFEST_PARSED, () => { // ํ™”์งˆ const levels = hls.levels || []; if (qSel && levels.length > 1) { qSel.innerHTML = '<option value="-1">์ž๋™</option>' + levels .map((lv, i) => `<option value="${i}">${lv.height ? lv.height + 'p' : Math.round((lv.bitrate || 0) / 1000) + 'kbps'}</option>`) .join(''); qSel.value = '-1'; qSel.classList.add('has-levels'); qSel.onchange = () => { const v = parseInt(qSel.value, 10); hls.currentLevel = v; showMediaToast(v < 0 ? 'ํ™”์งˆ: ์ž๋™' : (levels[v].height ? levels[v].height + 'p' : 'ํ™”์งˆ ๋ณ€๊ฒฝ')); }; } }); // H-5: audio tracks hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, () => { const tracks = hls.audioTracks || []; if (aSel && tracks.length > 1) { aSel.innerHTML = tracks.map((t, i) => `<option value="${i}">๐ŸŽต ${esc(t.name || t.lang || '#' + i)}</option>`).join(''); aSel.value = String(hls.audioTrack); aSel.classList.add('has-levels'); aSel.onchange = () => { hls.audioTrack = parseInt(aSel.value, 10); const tr = tracks[hls.audioTrack]; showMediaToast('์˜ค๋””์˜ค: ' + (tr?.name || tr?.lang || '')); }; } }); // H-5: subtitle tracks hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, () => { const subs = hls.subtitleTracks || []; if (sSel && subs.length >= 1) { sSel.innerHTML = '<option value="-1">์ž๋ง‰ ๊บผ์ง</option>' + subs.map((t, i) => `<option value="${i}">๐Ÿ’ฌ ${esc(t.name || t.lang || '#' + i)}</option>`).join(''); sSel.value = String(hls.subtitleTrack); sSel.classList.add('has-levels'); sSel.onchange = () => { hls.subtitleTrack = parseInt(sSel.value, 10); showMediaToast(hls.subtitleTrack < 0 ? '์ž๋ง‰ ๋”' : '์ž๋ง‰ ์ผฌ'); }; } }); } else if (v.canPlayType('application/vnd.apple.mpegurl')) { v.src = proxyUrl; v.load(); } else { throw new Error('์ด ๋ธŒ๋ผ์šฐ์ €๋Š” HLS๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค'); } } else { v.src = proxyUrl; v.load(); } // ์ž๋™์žฌ์ƒ ์•ˆ ํ•จ โ€” ์‚ฌ์šฉ์ž๊ฐ€ โ–ถ ๋ˆŒ๋Ÿฌ์•ผ ์‹œ์ž‘ // ์ด์–ด๋ณด๊ธฐ: ํšŒ์ฐจ๋ณ„ progress.time์„ ๋ณต์› (-3์ดˆ ๋ฐฑ์˜คํ”„๋กœ ๋งฅ๋ฝ ์‚ด์ง๋งŒ ๋ณด๊ฐ•) // ์ €์žฅ throttle์„ 10์ดˆ๋กœ ์ค„์˜€๊ณ  pause/hidden/unload flush๊ฐ€ ์žˆ์–ด -10์ดˆ๊นŒ์ง€ ๊ฐˆ ํ•„์š” ์—†์Œ. const epForRestore = currentEpList.find(e => e.sid === sid && e.nid === nid) || currentEpList.find(e => e.nid === nid); const labelForRestore = epForRestore?.label || `${nid}ํ™”`; const prog = fav?.progress?.[labelForRestore]; if (prog && typeof prog.time === 'number' && prog.time > 5 && !prog.finished) { const restore = () => { try { v.currentTime = Math.max(0, prog.time - 3); } catch {} v.removeEventListener('loadedmetadata', restore); }; v.addEventListener('loadedmetadata', restore); } // E2: ์นดํ…Œ๊ณ ๋ฆฌ ๋ฐฑ์—… ์บ์‹ฑ (fetchEpisodes์—์„œ ๋ชป ๊ฐ€์ ธ์™”์œผ๋ฉด play ์‘๋‹ต์—์„œ ์ฑ„์›€) // ๊ฐ€๋“œ: tvchak vod_class๋Š” ์ข…์ข… "๊ธˆ์š”์ผ" ๊ฐ™์€ ๋ฐฉ์†ก์š”์ผ์„ ๋ฐ˜ํ™˜ํ•จ โ†’ ํ™”์ดํŠธ๋ฆฌ์ŠคํŠธ ํ†ต๊ณผ๋งŒ ์ €์žฅ. if (fav && src === 'tvchak' && !fav.category && p.vod_data?.vod_class) { const vc = String(p.vod_data.vod_class); const m = vc.match(/(๋“œ๋ผ๋งˆ|์˜ˆ๋Šฅ|์˜ํ™”|์• ๋‹ˆ|์‹œ์‚ฌ๊ต์–‘|๋‹คํ|ํ‚ค์ฆˆ|์Šคํฌ์ธ )/); if (m) { fav.category = m[1]; saveFavs(); renderFavs(); } } const title = (p.vod_data && p.vod_data.vod_name) || (fav && fav.title) || ''; const ep = currentEpList.find(e => e.sid === sid && e.nid === nid) || currentEpList.find(e => e.nid === nid); const epLabel = (ep && ep.label) || `${nid}ํ™”`; const sourceLabel = src === 'anilife' ? '<span class="src-badge ani">์• ๋‹ˆ</span> ' : ''; // ํด๋ฐฑ ์‚ฌ์šฉ ์‹œ ์ž‘์€ ๋ฐฐ์ง€ โ€” play ์‘๋‹ต์˜ _fallbackSource(์„œ๋ฒ„) ๋˜๋Š” fav.usingFallback(loadEpisodes์—์„œ ์ €์žฅํ•œ ๊ฐ’) const fbSrc = p._fallbackSource || fav?.usingFallback; const fallbackBadge = fbSrc ? `<span class="fb-badge" title="์›๋ณธ(${src}) ์ฐจ๋‹จยท์žฅ์• ๋กœ ${fbSrc}์—์„œ ์žฌ์ƒ ์ค‘">${esc(fbSrc)}</span> ` : ''; // ๋‹ค์šด๋กœ๋“œ: tvchak์€ ์ง์ ‘ mp4 ๋‹ค์šด๋กœ๋“œ, anilife๋Š” HLS๋ผ ์•„์ง ๋ฏธ์ง€์› const canDownload = src === 'tvchak' && p.url; const dlBtn = canDownload ? `<button class="dl-btn" id="btnDownload" title="๋‹ค์šด๋กœ๋“œ"><svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v12"></path><path d="M7 10l5 5 5-5"></path><path d="M5 21h14"></path></svg></button>` : ''; $('#nowMeta').innerHTML = ` <div class="title-row"> <div class="title">${sourceLabel}${esc(title)}${fallbackBadge}</div> ${dlBtn} </div> <div class="sub">${esc(epLabel)}${ep?.subject ? ' ยท ' + esc(ep.subject) : ''} ${p.vod_data?.vod_class ? 'ยท ' + esc(p.vod_data.vod_class) : ''} ${p.vod_data?.vod_actor ? 'ยท ' + esc(p.vod_data.vod_actor) : ''}</div> `; // ๋‹ค์šด๋กœ๋“œ ๋™์ž‘์€ ํ•จ์ˆ˜๋กœ ์ถ”์ถœ โ€” nowMeta ๋ฒ„ํŠผ๊ณผ moreMenu์—์„œ ๊ณตํ†ต ์‚ฌ์šฉ if (canDownload) { const safeName = `${title}_${epLabel}`.replace(/[\\/:*?"<>|]/g, '_').slice(0, 80) + '.mp4'; const dlUrl = '/cdn?u=' + encodeURIComponent(p.url) + '&r=' + encodeURIComponent(p.referer || '') + '&dl=' + encodeURIComponent(safeName); window._currentDownload = { url: dlUrl, name: safeName }; const triggerDownload = () => { const a = document.createElement('a'); a.href = dlUrl; a.download = safeName; a.rel = 'noopener'; document.body.appendChild(a); a.click(); a.remove(); }; $('#btnDownload')?.addEventListener('click', triggerDownload); } else { window._currentDownload = null; } // ์•ฑ๋ฐ” ๋กœ๊ณ ๋Š” ๊ทธ๋Œ€๋กœ ์œ ์ง€ โ€” ์˜์ƒ ์ •๋ณด๋Š” nowMeta์— ํ‘œ์‹œ if (fav && userInitiated && !playEpisode._fallback) { // ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ ์„ ํƒํ•œ ๊ฒฝ์šฐ์—๋งŒ last* ๊ฐฑ์‹  fav.lastSid = sid; fav.lastNid = nid; fav.lastLabel = epLabel; fav.lastSeenLabel = epLabel; fav.clickedAt = Date.now(); if (fav.knownCount != null) fav.lastSeenCount = fav.knownCount; markCaughtUpIfNeeded(fav); saveFavs(); renderFavs(); } currentEpIdx = currentEpList.findIndex(e => e.sid === sid && e.nid === nid); renderEpisodes(); // ๋ชจ๋ฐ”์ผ์—์„œ ๋น„๋””์˜ค๋กœ ์Šคํฌ๋กค if (isMobile()) window.scrollTo({ top: 0, behavior: 'smooth' }); } catch (e) { console.warn('play fail', e); // CF_PASS_NEEDED = CDP ํ†ต๊ณผ ํƒญ ํ† ํฐ ๋งŒ๋ฃŒ(์ž๋™ ์žฌํ†ต๊ณผ๋„ ์‹คํŒจ). ์‚ฌ์šฉ์ž๊ฐ€ CDP Chrome์—์„œ ์ƒˆ๋กœ๊ณ ์นจ ํ•„์š”. if (e && e.code === 'CF_PASS_NEEDED') { $('#videoEmpty').textContent = '์—ฐ๊ฒฐ์ด ๋งŒ๋ฃŒ๋์–ด์š”. ์ž ์‹œ ํ›„ ๋‹ค์‹œ ์‹œ๋„ํ•˜๊ฑฐ๋‚˜, CDP ์ฐฝ์„ ์ƒˆ๋กœ๊ณ ์นจํ•ด ์ฃผ์„ธ์š”.'; } else { $('#videoEmpty').textContent = '์žฌ์ƒ ์‹คํŒจ: ' + e.message + ' โ€” ๋‹ค๋ฅธ ํšŒ์ฐจ๋ฅผ ์„ ํƒํ•ด๋ณด์„ธ์š”.'; } $('#videoEmpty').classList.remove('hide'); // ์‚ฌ์šฉ์ž๊ฐ€ ๋ช…์‹œ์ ์œผ๋กœ ๋ˆ„๋ฅธ ๊ฒŒ ์•„๋‹ˆ๋ผ ์ž๋™ fallback์ผ ๋•Œ๋งŒ ์ตœ์‹ ํ™”๋กœ ์‹œ๋„ if (!playEpisode._fallback && currentEpList.length) { const latest = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid)[0]; if (latest.sid !== sid || latest.nid !== nid) { playEpisode._fallback = true; try { await playEpisode(id, latest.sid, latest.nid); } finally { playEpisode._fallback = false; } } } } finally { $('#videoLoading').style.display = 'none'; } } function stopPlayer() { const v = $('#player'); if (_currentHls) { try { _currentHls.destroy(); } catch {} _currentHls = null; } v.pause(); v.removeAttribute('src'); v.load(); $('#videoEmpty').classList.remove('hide'); $('#nowMeta').innerHTML = ''; currentEpList = []; currentEpIdx = -1; $('#epSection').style.display = 'none'; } // โ”€โ”€โ”€ ์ฆ๊ฒจ์ฐพ๊ธฐ ์ถ”๊ฐ€ โ”€โ”€โ”€ async function addFav(input, extra = {}) { // input์ด ๊ฐ์ฒด๋ฉด ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ์—์„œ ์ง์ ‘ ํ˜ธ์ถœ. ๋ฌธ์ž์—ด์ด๋ฉด parseInput. let parsed; if (typeof input === 'object' && input !== null) { parsed = { id: +input.id, source: input.source || 'tvchak', title: input.title || null, category: input.category || null, poster: input.poster || null }; } else { parsed = parseInput(input); } if (!parsed) { alert('ํ‹ฐ๋น„์ฐฉ/์• ๋‹ˆ๋ผ์ดํ”„ URL์ด๋‚˜ ID(์ˆซ์ž)๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.'); return; } // ๋ณด๊ด€ํ•จ ํ‚ค๋Š” (source, id) ์Œ โ€” ๊ฐ™์€ id๊ฐ€ ๋‘ ์†Œ์Šค์— ์žˆ์„ ์ˆ˜ ์žˆ์Œ const source = parsed.source || 'tvchak'; let fav = favs.find(f => f.id === parsed.id && (f.source || 'tvchak') === source); if (!fav) { fav = { id: parsed.id, source, title: parsed.title || null, category: parsed.category || null, poster: parsed.poster || null, addedAt: Date.now() }; if (parsed.sid != null) { fav.lastSid = parsed.sid; fav.lastNid = parsed.nid; } favs.unshift(fav); saveFavs(); } renderFavs(); await selectFav(parsed.id, { ...(parsed.sid != null ? { sid: parsed.sid, nid: parsed.nid } : {}), source }); } // โ”€โ”€โ”€ ๊ฒ€์ƒ‰ โ”€โ”€โ”€ async function doSearch(wd, hostId) { if (!wd.trim()) return; pushRecentSearch(wd); // A1: ์ตœ๊ทผ ๊ฒ€์ƒ‰์–ด์— ์ €์žฅ const host = $('#' + hostId); if (hostId === 'searchResults') $('#searchResultsWrap').style.display = ''; host.innerHTML = '<div style="padding:12px;color:var(--muted);font-size:12px">๊ฒ€์ƒ‰ ์ค‘โ€ฆ</div>'; try { // source=all ์ด๋ฉด ์–‘์ชฝ ํ•ฉ์ณ์„œ ์˜ด const r = await api(`/api/search?source=all&wd=${encodeURIComponent(wd)}`); const tv = r.tvchak || { items: [] }; const ani = r.anilife || { items: [] }; const allItems = [ ...(tv.items || []).map(it => ({ ...it, source: 'tvchak' })), ...(ani.items || []).map(it => ({ ...it, source: 'anilife' })), ]; if (!allItems.length) { host.innerHTML = '<div style="padding:12px;color:var(--muted);font-size:12px">๊ฒฐ๊ณผ ์—†์Œ</div>'; return; } host.innerHTML = ''; for (const it of allItems) { const already = favs.find(f => f.id === it.id && (f.source || 'tvchak') === it.source); // E2: tvchak ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ meta("์˜ˆ๋Šฅ / 2026 / ...")์—์„œ ์ฒซ ํ† ํฐ์„ ์นดํ…Œ๊ณ ๋ฆฌ๋กœ let tvCat = null; if (it.source === 'tvchak' && typeof it.meta === 'string') { const m = it.meta.match(/(๋“œ๋ผ๋งˆ|์˜ˆ๋Šฅ|์˜ํ™”|์• ๋‹ˆ|์‹œ์‚ฌ๊ต์–‘|๋‹คํ|ํ‚ค์ฆˆ|์Šคํฌ์ธ )/); if (m) tvCat = m[1]; } const badge = it.source === 'anilife' ? '<span class="src-badge ani">์• ๋‹ˆ</span> ' : tvCat ? `<span class="src-badge tv ${/์˜ˆ๋Šฅ/.test(tvCat)?'ent':/์˜ํ™”/.test(tvCat)?'mov':''}">${esc(tvCat)}</span> ` : '<span class="src-badge tv">๋“œ๋ผ๋งˆ</span> '; const div = document.createElement('div'); div.className = 'sr-item'; div.innerHTML = `<b>${badge}${esc(it.title)}</b><div class="meta${already ? ' star' : ''}">${esc(it.meta || '')}${already ? ' ยท โ˜… ์ฆ๊ฒจ์ฐพ๊ธฐ' : ''}</div>` + `<button class="sr-fav${already ? ' added' : ''}" data-favbtn aria-label="๋ณด๊ด€ํ•จ ์ถ”๊ฐ€">${already ? 'โ˜…' : 'โ˜†'}</button>`; // D10: โ˜… ๋ฒ„ํŠผ (์ด๋ฒคํŠธ stop) div.querySelector('[data-favbtn]').addEventListener('click', async (e) => { e.stopPropagation(); if (already) { showMediaToast('์ด๋ฏธ ๋ณด๊ด€ํ•จ์— ์žˆ์–ด์š”'); return; } await addFav({ id: it.id, source: it.source, title: it.title, category: tvCat, poster: it.poster || null }); const b = div.querySelector('[data-favbtn]'); b.classList.add('added'); b.textContent = 'โ˜…'; showMediaToast('๋ณด๊ด€ํ•จ์— ์ถ”๊ฐ€๋จ โ˜…'); }); // ์นด๋“œ ๋ณธ๋ฌธ ํด๋ฆญ์€ ๊ธฐ์กด์ฒ˜๋Ÿผ ์ฆ๊ฒจ์ฐพ๊ธฐ ์ถ”๊ฐ€ div.addEventListener('click', async (e) => { if (e.target.closest('[data-favbtn]')) return; await addFav({ id: it.id, source: it.source, title: it.title, category: tvCat, poster: it.poster || null }); if (isMobile()) closeMobileSearch(); }); host.appendChild(div); } } catch (e) { host.innerHTML = `<div style="padding:12px;color:#ff7b7b">${esc(e.message)}</div>`; } } // โ”€โ”€โ”€ ๋ชจ๋ฐ”์ผ ๊ฒ€์ƒ‰ ํŒจ๋„ โ”€โ”€โ”€ function openMobileSearch() { $('#searchHead').style.display = ''; $('#searchBar').style.display = ''; $('#searchInputMob').focus(); } function closeMobileSearch() { $('#searchHead').style.display = 'none'; $('#searchBar').style.display = 'none'; $('#searchResultsMob').innerHTML = ''; $('#searchInputMob').value = ''; } // โ”€โ”€โ”€ ๋ชจ๋‹ฌ โ”€โ”€โ”€ function openAddModal() { $('#addUrl').value = ''; $('#addModal').classList.add('show'); setTimeout(() => $('#addUrl').focus(), 50); } function closeAddModal() { $('#addModal').classList.remove('show'); } // โ”€โ”€โ”€ ์˜์ƒ ํ™•๋Œ€/์ถ•์†Œ: ๋ชจ๋ฐ”์ผ(๋”๋ธ”ํƒญ/ํ•€์น˜) + ๋ฐ์Šคํฌํƒ‘(ํœ /๋“œ๋ž˜๊ทธ/๋”๋ธ”ํด๋ฆญ) โ”€โ”€โ”€ (function setupVideoZoom() { const v = $('#player'); const wrap = $('#videoWrap'); let zoom = 1; let tx = 0, ty = 0; // ํŒจ๋‹ ์˜คํ”„์…‹ let lastTap = 0; let pinchStart = null; let dragStart = null; // โ›ถ ๋ฒ„ํŠผ โ€” wrapper๋ฅผ ํ’€์Šคํฌ๋ฆฐ์œผ๋กœ (์ด๋Ÿฌ๋ฉด video ์•ˆ์—์„œ transform ์คŒ์ด ํ†ตํ•จ) $('#btnFsZoom')?.addEventListener('click', async (e) => { e.stopPropagation(); try { if (!isFullscreen()) { await (wrap.requestFullscreen || wrap.webkitRequestFullscreen).call(wrap); } else { await (document.exitFullscreen || document.webkitExitFullscreen).call(document); } } catch {} }); function apply() { if (zoom === 1) { v.style.transform = ''; v.style.cursor = ''; tx = 0; ty = 0; } else { v.style.transform = `translate(${tx}px, ${ty}px) scale(${zoom})`; v.style.cursor = dragStart ? 'grabbing' : 'grab'; } v.style.transformOrigin = 'center center'; } function setZoom(z, cx, cy, opts = {}) { const newZoom = Math.max(1, Math.min(4, z)); if (newZoom === 1) { tx = 0; ty = 0; } zoom = newZoom; clampPan(); apply(); // ํ’€์Šคํฌ๋ฆฐ ์•ˆ์—์„œ ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ ์คŒ ์กฐ์ž‘ํ•œ ๊ฒฝ์šฐ๋งŒ fav์— ์ €์žฅ (์ž๋™ ๋ณต์› ์‹œ๋Š” ์ €์žฅ ์•ˆ ํ•จ) if (!opts.silent && isFullscreen() && currentFavId) { const fav = favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === (currentFavSource || 'tvchak')); if (fav) { fav.zoom = fav.zoom || {}; const key = isMobile() ? 'mobile' : 'desktop'; // 1์ด๋ฉด ์ €์žฅ ํ‚ค ์‚ญ์ œ (๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ๋ณต๊ท€) if (newZoom === 1) { delete fav.zoom[key]; if (!fav.zoom.mobile && !fav.zoom.desktop) delete fav.zoom; } else { fav.zoom[key] = +newZoom.toFixed(3); } if (typeof saveFavs === 'function') saveFavs(); } } } // ํ’€์Šคํฌ๋ฆฐ ์ง„์ž… ์‹œ ์ €์žฅ๋œ ์คŒ ์ž๋™ ๋ณต์› function restoreSavedZoom() { if (!currentFavId) return; const fav = favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === (currentFavSource || 'tvchak')); const key = isMobile() ? 'mobile' : 'desktop'; const saved = fav?.zoom?.[key]; if (typeof saved === 'number' && saved > 1) { setZoom(saved, null, null, { silent: true }); } } function clampPan() { // ๋น„๋””์˜ค๊ฐ€ ํ™”๋ฉด ๋ฐ–์œผ๋กœ ๋„ˆ๋ฌด ๋ฒ—์–ด๋‚˜์ง€ ์•Š๊ฒŒ const rect = v.getBoundingClientRect(); const maxX = rect.width * (zoom - 1) / 2; const maxY = rect.height * (zoom - 1) / 2; tx = Math.max(-maxX, Math.min(maxX, tx)); ty = Math.max(-maxY, Math.min(maxY, ty)); } // ๋”๋ธ”ํด๋ฆญ โ€” ์ขŒ์ธก 1/3์€ -5์ดˆ, ์šฐ์ธก 1/3์€ +5์ดˆ, ์ค‘์•™์€ ํ’€์Šคํฌ๋ฆฐ ํ† ๊ธ€ v.addEventListener('dblclick', (e) => { e.preventDefault(); const rect = v.getBoundingClientRect(); const x = e.clientX - rect.left; const w = rect.width; if (!isFinite(v.duration)) return; if (x < w / 3) { v.currentTime = Math.max(0, v.currentTime - 5); showToast('โช -5์ดˆ'); } else if (x > w * 2 / 3) { v.currentTime = Math.min(v.duration, v.currentTime + 5); showToast('+5์ดˆ โฉ'); } else { $('#btnFsZoom')?.click(); } }); v.addEventListener('click', (e) => { // ๋ชจ๋ฐ”์ผ ๋”๋ธ”ํƒญ์œผ๋กœ ์คŒ ํ† ๊ธ€ โ€” ๋‹จ, ๋งˆ์šฐ์Šค(pointerType์ด mouse)๋Š” ์ œ์™ธ. // pointerType ํ™•์ธ ์•ˆ ๋˜๋ฉด ์ขŒํ‘œ ๊ธฐ๋ฐ˜: ๋”๋ธ”ํด๋ฆญ๊ณผ ๋™์ผํ•˜๊ฒŒ ์ค‘์•™ 1/3๋งŒ ์คŒ (์ขŒ/์šฐ๋Š” ์ ํ”„์™€ ์ถฉ๋Œ) if (!('ontouchstart' in window)) return; const now = Date.now(); if (now - lastTap < 350) { // ์ค‘์•™ ์˜์—ญ์—์„œ๋งŒ ์คŒ (์ขŒ/์šฐ๋Š” click ํ•ธ๋“ค๋Ÿฌ ๋˜๋ž˜์˜ ยฑ5์ดˆ ๋ถ€์‚ฐ๋ฌผ ๋ฐฉ์ง€) const rect = v.getBoundingClientRect(); const x = e.clientX - rect.left; const w = rect.width; if (x >= w / 3 && x <= w * 2 / 3) { setZoom(zoom > 1 ? 1 : 1.75); } } lastTap = now; }); // ํ’€์Šคํฌ๋ฆฐ ์—ฌ๋ถ€ โ€” wrapper๊ฐ€ ํ’€์Šคํฌ๋ฆฐ์ผ ๋•Œ๋งŒ (video ์ž์ฒด ํ’€์Šคํฌ๋ฆฐ์€ transform ์•ˆ ๋จน์–ด์„œ ์ œ์™ธ) function isFullscreen() { const fs = document.fullscreenElement || document.webkitFullscreenElement; return fs === wrap; } // ๋งˆ์šฐ์Šคํœ  ์คŒ โ€” ํ’€์Šคํฌ๋ฆฐ์ผ ๋•Œ๋งŒ. document ๋ ˆ๋ฒจ์—์„œ ์žก์•„์•ผ ํ’€์Šคํฌ๋ฆฐ ๋น„๋””์˜ค์—๋„ ๋„๋‹ฌํ•จ. document.addEventListener('wheel', (e) => { if (!isFullscreen()) return; if (e.ctrlKey) return; // ํ’€์Šคํฌ๋ฆฐ ๋Œ€์ƒ์ด ์šฐ๋ฆฌ video์ธ์ง€ ํ™•์ธ const fsEl = document.fullscreenElement || document.webkitFullscreenElement; if (fsEl !== wrap) return; e.preventDefault(); const delta = e.deltaY > 0 ? -0.15 : 0.15; setZoom(zoom + delta); }, { passive: false }); // ๋“œ๋ž˜๊ทธ ํŒจ๋‹ โ€” document ๋ ˆ๋ฒจ (ํ’€์Šคํฌ๋ฆฐ + ์คŒ 1 ์ด์ƒ์ผ ๋•Œ๋งŒ) document.addEventListener('mousedown', (e) => { const fsEl = document.fullscreenElement || document.webkitFullscreenElement; if (fsEl !== wrap || zoom <= 1) return; // ์˜ค๋ฒ„๋ ˆ์ด ์ปจํŠธ๋กค ํด๋ฆญ์€ ๋ฌด์‹œ (๋“œ๋ž˜๊ทธ ํŒจ๋‹๊ณผ ์ถฉ๋Œ ๋ฐฉ์ง€) if (e.target.closest('#zoomCtrl, #btnFsZoom')) return; e.preventDefault(); dragStart = { x: e.clientX - tx, y: e.clientY - ty }; v.style.cursor = 'grabbing'; }); // (์˜์ƒ ํด๋ฆญ โ†’ ์žฌ์ƒ/์ •์ง€ ํ† ๊ธ€์€ ์ œ๊ฑฐ. ์˜๋„์น˜ ์•Š์€ ์ผ์‹œ์ •์ง€ ๋นˆ๋ฐœ + ๋ˆ„๋ฅด๊ณ ์žˆ๊ธฐ ๋ฐฐ์†๊ณผ ์ธ์ง€ ์ถฉ๋Œ. // ์žฌ์ƒ/์ •์ง€๋Š” ์ปจํŠธ๋กค๋ฐ” โ–ถ ๋ฒ„ํŠผ ๋˜๋Š” Space/K ํ‚ค๋กœ๋งŒ.) // โ”€โ”€โ”€ ๋ˆ„๋ฅด๊ณ  ์žˆ์œผ๋ฉด 3๋ฐฐ์† (press-and-hold) โ”€โ”€โ”€ // 500ms ์ด์ƒ ๊พน ๋ˆ„๋ฅด๊ณ  ์žˆ์œผ๋ฉด playbackRate = 3, ์†์„ ๋–ผ๋ฉด ์›๋ž˜ ์†๋„ ๋ณต๊ท€. // ์‚ผ์„ฑ์ธํ„ฐ๋„ทยท์ผ๋ถ€ ์•ˆ๋“œ Chrome์—์„œ <video>๊ฐ€ long-press ์ด๋ฒคํŠธ๋ฅผ ์ž์ฒด ์†Œ๋น„ํ•˜๋ฏ€๋กœ // video ์œ„์— ํˆฌ๋ช… ์˜ค๋ฒ„๋ ˆ์ด(#holdOverlay)๋ฅผ ๊น”๊ณ  ๊ฑฐ๊ธฐ์„œ ์ด๋ฒคํŠธ ์บก์ฒ˜. // pointer ์ด๋ฒคํŠธ + touchstart/touchend ๋‘˜ ๋‹ค ๋“ฑ๋ก(๋ธŒ๋ผ์šฐ์ €๋ณ„ ์•ˆ ๋จน๋Š” ๊ฒฝ์šฐ backup). const holdOv = document.getElementById('holdOverlay'); let _holdTimer = null; let _holdActive = false; let _holdPrevRate = 1; let _holdStartX = 0, _holdStartY = 0; const HOLD_MS = 500; const HOLD_MOVE_TOLERANCE = 12; function _cancelHoldTimer() { if (_holdTimer) { clearTimeout(_holdTimer); _holdTimer = null; } } function _exitHoldFast() { if (!_holdActive) return; _holdActive = false; try { v.playbackRate = _holdPrevRate; } catch {} } function _holdStart(x, y) { if (!currentFavId) return; if (v.paused || v.ended) return; _cancelHoldTimer(); _holdStartX = x; _holdStartY = y; _holdTimer = setTimeout(() => { _holdTimer = null; _holdPrevRate = v.playbackRate || 1; _holdActive = true; try { v.playbackRate = 3; } catch {} }, HOLD_MS); } function _holdMove(x, y) { // hold ์ง„์ž… ํ›„์—” ์†๊ฐ€๋ฝ ๋ฏธ์„ธ ๋–จ๋ฆผ ๋ฌด์‹œ. ์ง„์ž… ์ „(timer ๋Œ€๊ธฐ)์ผ ๋•Œ๋งŒ 40px+ ์ด๋™์—์„œ ์ทจ์†Œ. if (!_holdTimer) return; if (Math.abs(x - _holdStartX) > 40 || Math.abs(y - _holdStartY) > 40) { _cancelHoldTimer(); } } function _holdEnd() { _cancelHoldTimer(); _exitHoldFast(); } // wrap์— ์บก์ฒ˜ ๋‹จ๊ณ„๋กœ ํ•œ ๋ฒˆ๋งŒ ๋“ฑ๋ก (์˜ค๋ฒ„๋ ˆ์ด๋„ wrap ์ž์‹์ด๋ผ ์บก์ฒ˜๋ฉด ํ•จ๊ป˜ ์žกํž˜). // touch ์ด๋ฒคํŠธ๋งŒ ์‚ฌ์šฉ โ€” pointer๋Š” ์ผ๋ถ€ ๋ชจ๋ฐ”์ผ ๋ธŒ๋ผ์šฐ์ €์—์„œ video native ๋ ˆ์ด์–ด๊ฐ€ ํก์ˆ˜. // pointerleave ๊ฐ™์€ ์ž๋™๋ฐœํ™” ์ข…๋ฃŒ ์ด๋ฒคํŠธ๋Š” ๋“ฑ๋ก ์•ˆ ํ•จ (touchstart ์งํ›„ leave๊ฐ€ ์ฆ‰์‹œ ๋ฐœํ™”ํ•˜๋Š” ๊ฒฝ์šฐ ์žˆ์Œ). // ratechange ํ† ์ŠคํŠธ๊ฐ€ ๋ณ„๋„๋กœ ๋– ์„œ ์ง„์ž…/ํ•ด์ œ๋Š” ๊ทธ์ชฝ์œผ๋กœ ์ฒ˜๋ฆฌ๋จ โ€” ์—ฌ๊ธฐ์„  ํ† ์ŠคํŠธ ํ˜ธ์ถœ ์•ˆ ํ•จ. // ๋”๋ธ”ํƒญ(ยฑ5์ดˆ/์คŒ) ์ง์ ‘ ๊ฐ์ง€ โ€” touchstart์—์„œ preventDefaultํ•˜๋ฉด ๋ธŒ๋ผ์šฐ์ €์˜ // click/dblclick ํ•ฉ์„ฑ์ด ๋ง‰ํ˜€ video์˜ ๊ธฐ์กด dblclick ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ์•ˆ ๋™์ž‘ํ•˜๋ฏ€๋กœ // wrap์—์„œ ์šฐ๋ฆฌ๊ฐ€ ์ง์ ‘ ์ฒ˜๋ฆฌํ•œ๋‹ค. let _lastTapAt = 0, _lastTapX = 0, _lastTapY = 0; const DBL_TAP_MS = 350; const DBL_TAP_TOL = 30; function _handleDoubleTap(x, y) { const rect = v.getBoundingClientRect(); const lx = x - rect.left; const w = rect.width; if (!isFinite(v.duration)) return; if (lx < w / 3) { v.currentTime = Math.max(0, v.currentTime - 5); if (typeof showToast === 'function') showToast('โช -5์ดˆ'); } else if (lx > w * 2 / 3) { v.currentTime = Math.min(v.duration, v.currentTime + 5); if (typeof showToast === 'function') showToast('+5์ดˆ โฉ'); } // ์ค‘์•™: ์•„๋ฌด ์ผ๋„ ์•ˆ ํ•จ (ํ™•๋Œ€๋Š” ํ•€์น˜์คŒ์œผ๋กœ๋งŒ) } wrap.addEventListener('touchstart', (e) => { const t = e.touches[0]; if (!t) return; // ์šฐ๋ฆฌ UI ์œ„์—์„œ ์‹œ์ž‘๋œ ํ„ฐ์น˜๋Š” ์ œ์™ธ // #nextCountdown ๋ˆ„๋ฝ ์‹œ: wrap touchstart์˜ preventDefault๊ฐ€ click ํ•ฉ์„ฑ์„ ๋ง‰๊ณ  โ†’ ๋‘ ๋ฒˆ์งธ ํƒญ์ด // ๋”๋ธ”ํƒญ(+5์ดˆ)์œผ๋กœ ์žกํ˜€ ์นด์šดํŠธ๋‹ค์šด ๋ฒ„ํŠผ ํด๋ฆญ์ด ์˜์˜ ์•ˆ ๋จน๋Š” ์‚ฌ๊ณ (2026-06-08). ๋ฐ˜๋“œ์‹œ ํฌํ•จ. // #nextPreview(F-8 ์šฐ์ƒ๋‹จ "๋‹ค์Œ โ–ถ")๋„ ๋™์ผ ํŒจํ„ด โ€” ๋ชจ๋ฐ”์ผ์—์„œ ์•ˆ ๋ˆŒ๋ฆฌ๋˜ ์‚ฌ๊ณ (2026-06-14). if (e.target.closest('#zoomCtrl, #moreMenu, #btnFsZoom, #btnSideToggle, #pauseOverlay, .skip-btn, .lock-btn, .hls-quality, .hls-audio, .hls-sub, #nextCountdown, #nextPreview')) return; // ๋‘ ๋ฒˆ์งธ ์†๊ฐ€๋ฝ์ด ๋‹ฟ๋Š” ์ˆœ๊ฐ„ โ€” ํ•€์น˜ ์‹œ์ž‘. hold/๋”๋ธ”ํƒญ ์ƒํƒœ ์ •๋ฆฌํ•˜๊ณ  ์šฐ๋ฆฌ๊ฐ€ ์ง์ ‘ ์ฒ˜๋ฆฌ. // (์˜ค๋ฒ„๋ ˆ์ด๊ฐ€ video๋ฅผ ๋ฎ๊ณ  ์žˆ์–ด video์˜ native ํ•€์น˜ ํ•ธ๋“ค๋Ÿฌ๊นŒ์ง€ ์ด๋ฒคํŠธ๊ฐ€ ์•ˆ ๊ฐ) if (e.touches.length >= 2) { _cancelHoldTimer(); _exitHoldFast(); _lastTapAt = 0; pinchStart = { dist: tdist(e.touches[0], e.touches[1]), zoom }; return; } // ๋‹จ์ผ ํ„ฐ์น˜: ์‚ผ์„ฑ์ธํ„ฐ๋„ทยท์ผ๋ถ€ ์•ˆ๋“œ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ touchstart ์งํ›„ long-press gesture๋กœ // ๊ฐ€๋กœ์ฑ„๋ฉฐ ์ฆ‰์‹œ touchend๋ฅผ ๋ฐœํ™” โ†’ preventDefault๋กœ ์ฐจ๋‹จ. try { e.preventDefault(); } catch {} // ๋”๋ธ”ํƒญ ๊ฐ์ง€ โ€” preventDefault๋กœ ์ธํ•ด native dblclick์ด ์•ˆ ์˜ค๋ฏ€๋กœ ์—ฌ๊ธฐ์„œ ์ง์ ‘. const now = Date.now(); if (now - _lastTapAt < DBL_TAP_MS && Math.abs(t.clientX - _lastTapX) < DBL_TAP_TOL && Math.abs(t.clientY - _lastTapY) < DBL_TAP_TOL) { _handleDoubleTap(t.clientX, t.clientY); _lastTapAt = 0; // ํŠธ๋ฆฌํ”Œํƒญ ๋ฐฉ์ง€ return; // hold ํƒ€์ด๋จธ ์‹œ์ž‘ ์•ˆ ํ•จ } _lastTapAt = now; _lastTapX = t.clientX; _lastTapY = t.clientY; _holdStart(t.clientX, t.clientY); }, { passive: false, capture: true }); wrap.addEventListener('touchmove', (e) => { // ํ•€์น˜ โ€” ๋‘ ์†๊ฐ€๋ฝ ๊ฑฐ๋ฆฌ ๋ณ€ํ™”๋กœ ์คŒ ์กฐ์ ˆ if (e.touches.length >= 2 && pinchStart) { const d = tdist(e.touches[0], e.touches[1]); setZoom(pinchStart.zoom * (d / pinchStart.dist)); return; } const t = e.touches[0]; if (!t) return; _holdMove(t.clientX, t.clientY); }, { passive: true, capture: true }); wrap.addEventListener('touchend', (e) => { if (e.touches.length < 2) pinchStart = null; _holdEnd(); }, true); wrap.addEventListener('touchcancel', () => { pinchStart = null; _holdEnd(); }, true); // ๋งˆ์šฐ์Šค(๋ฐ์Šคํฌํƒ‘)์šฉ โ€” pointerdown๋งŒ, leave๋Š” ๋“ฑ๋ก ์•ˆ ํ•จ wrap.addEventListener('pointerdown', (e) => { if (e.pointerType !== 'mouse') return; // ํ„ฐ์น˜๋Š” ์œ„์—์„œ ์ฒ˜๋ฆฌ if (e.button !== 0) return; if (e.target.closest('#zoomCtrl, #moreMenu, #btnFsZoom, #btnSideToggle, #pauseOverlay, .skip-btn, .lock-btn, .hls-quality, .hls-audio, .hls-sub, #nextCountdown, #nextPreview')) return; _holdStart(e.clientX, e.clientY); }, true); wrap.addEventListener('pointermove', (e) => { if (e.pointerType !== 'mouse') return; _holdMove(e.clientX, e.clientY); }, true); wrap.addEventListener('pointerup', (e) => { if (e.pointerType !== 'mouse') return; _holdEnd(); }, true); // ๋ฐ์Šคํฌํƒ‘ ๋”๋ธ”ํด๋ฆญ โ€” ์ขŒ/์šฐ 1/3 ยฑ5์ดˆ, ์ค‘์•™ ํ’€์Šคํฌ๋ฆฐ ํ† ๊ธ€. // #holdOverlay(z-index:2)๊ฐ€ video๋ฅผ ๋ฎ์–ด video์˜ dblclick ํ•ธ๋“ค๋Ÿฌ์—” ์ด๋ฒคํŠธ๊ฐ€ ์•ˆ ๋‹ฟ์œผ๋ฏ€๋กœ // wrap ์บก์ฒ˜ ๋‹จ๊ณ„์—์„œ ์ง์ ‘ ์ฒ˜๋ฆฌ(๋ชจ๋ฐ”์ผ _handleDoubleTap๊ณผ ๋™์ผ ๋กœ์ง + ์ค‘์•™ ํ’€์Šคํฌ๋ฆฐ). wrap.addEventListener('dblclick', (e) => { if (e.pointerType === 'touch') return; // ํ„ฐ์น˜ ๋”๋ธ”ํƒญ์€ touchstart์—์„œ ์ฒ˜๋ฆฌ if (e.target.closest('#zoomCtrl, #moreMenu, #btnFsZoom, #btnSideToggle, #pauseOverlay, .skip-btn, .lock-btn, .hls-quality, .hls-audio, .hls-sub, #nextCountdown, #nextPreview')) return; if (!isFinite(v.duration)) return; const rect = v.getBoundingClientRect(); const lx = e.clientX - rect.left; const w = rect.width; if (lx < w / 3) { v.currentTime = Math.max(0, v.currentTime - 5); if (typeof showToast === 'function') showToast('โช -5์ดˆ'); } else if (lx > w * 2 / 3) { v.currentTime = Math.min(v.duration, v.currentTime + 5); if (typeof showToast === 'function') showToast('+5์ดˆ โฉ'); } else { $('#btnFsZoom')?.click(); } }, true); wrap.addEventListener('contextmenu', (e) => { e.preventDefault(); _holdEnd(); }, true); // ํ’€์Šคํฌ๋ฆฐ ์ง„์ž…/ํƒˆ์ถœ ์‹œ โ€” ์คŒ ์˜ค๋ฒ„๋ ˆ์ด ์ปจํŠธ๋กค ํ† ๊ธ€ const zoomCtrl = $('#zoomCtrl'); let hideTimer = null; function showControls() { // ์ž ๊ธˆ ์ƒํƒœ์—์„œ๋Š” ์ผ๋ฐ˜ ์ปจํŠธ๋กค(zoomCtrl ๋“ฑ)์„ ๋„์šฐ๋ฉด ์•ˆ ๋จ โ€” ๋‹จ์ˆœ skip. // ์ž๋ฌผ์‡  ํžŒํŠธ๋Š” ์ž ๊ธˆ ์ฐจ๋‹จ ํ•ธ๋“ค๋Ÿฌ(touchstart/click/pointerdown)์—์„œ๋งŒ pingLockHint๋กœ ํŠธ๋ฆฌ๊ฑฐ. if (wrap.classList.contains('locked')) return; wrap.classList.add('show-controls'); wrap.classList.remove('hide-cursor'); clearTimeout(hideTimer); if (isFullscreen()) { hideTimer = setTimeout(hideControls, 3000); } } function hideControls() { if (!isFullscreen()) return; // ๋งˆ์šฐ์Šค ํฌ์ธํ„ฐ๊ฐ€ zoom-ctrl ์œ„์— ์žˆ์œผ๋ฉด ์•ˆ ์ˆจ๊น€ if (zoomCtrl.matches(':hover')) { hideTimer = setTimeout(hideControls, 2000); return; } wrap.classList.remove('show-controls'); wrap.classList.add('hide-cursor'); } function onFsChange() { if (isFullscreen()) { // zoomCtrl์€ ํ•ญ์ƒ ํ‘œ์‹œ๋จ (์ผ๋ฐ˜ยทํ’€์Šคํฌ๋ฆฐ ๊ณต์šฉ). ํ’€์Šคํฌ๋ฆฐ๋งŒ ์ถ”๊ฐ€ ์ฒ˜๋ฆฌ. showControls(); // ์ €์žฅ๋œ ์คŒ์ด ์žˆ์œผ๋ฉด ์ž๋™ ๋ณต์› restoreSavedZoom(); // ๋ชจ๋ฐ”์ผ: ํ’€์Šคํฌ๋ฆฐ ์ง„์ž… ์‹œ ๊ฐ€๋กœ ์ž ๊ธˆ (์˜์ƒ ์‹œ์ฒญ์— ์ตœ์ ํ™”) // Chrome Android ์ง€์›, iOS Safari ๋ฏธ์ง€์›(๊ถŒํ•œ ์—†์Œ) โ€” ์‹คํŒจํ•ด๋„ ๋ฌด์‹œ if (isMobile() && screen.orientation && typeof screen.orientation.lock === 'function') { screen.orientation.lock('landscape').catch(() => {}); } } else { wrap.classList.remove('show-controls', 'hide-cursor'); clearTimeout(hideTimer); zoom = 1; tx = 0; ty = 0; apply(); // ํ’€์Šคํฌ๋ฆฐ ์ข…๋ฃŒ ์‹œ ํšŒ์ „ ์ž ๊ธˆ ํ•ด์ œ if (screen.orientation && typeof screen.orientation.unlock === 'function') { try { screen.orientation.unlock(); } catch {} } } } document.addEventListener('fullscreenchange', onFsChange); document.addEventListener('webkitfullscreenchange', onFsChange); // ํ’€์Šคํฌ๋ฆฐ์ผ ๋•Œ ๋งˆ์šฐ์Šค ์›€์ง์ž„/ํ„ฐ์น˜๋กœ ์ปจํŠธ๋กค ์ž๋™ ํ‘œ์‹œ wrap.addEventListener('mousemove', () => { if (isFullscreen()) showControls(); }); // ๋ชจ๋ฐ”์ผ/ํ„ฐ์น˜: ์ผ๋ฐ˜ ๋ชจ๋“œ์—์„œ๋„ ์˜์ƒ ์˜์—ญ ํƒญํ•˜๋ฉด ์ปจํŠธ๋กค 4์ดˆ๊ฐ„ ํ‘œ์‹œ (PC๋Š” CSS :hover๋กœ ์ž๋™) let _inlineHideTimer = null; wrap.addEventListener('touchstart', () => { if (isFullscreen()) { showControls(); return; } wrap.classList.add('show-controls'); clearTimeout(_inlineHideTimer); _inlineHideTimer = setTimeout(() => wrap.classList.remove('show-controls'), 4000); }, { passive: true }); // ์ปจํŠธ๋กค๋ฐ”์— ๋งˆ์šฐ์Šค ์˜ฌ๋ผ๊ฐ€์žˆ์œผ๋ฉด ํ•ญ์ƒ ๋ณด์ด๊ฒŒ zoomCtrl.addEventListener('mouseenter', () => { clearTimeout(hideTimer); }); zoomCtrl.addEventListener('mouseleave', () => { if (isFullscreen()) hideTimer = setTimeout(hideControls, 1500); }); // ์˜ค๋ฒ„๋ ˆ์ด ์ปจํŠธ๋กค ํ•ธ๋“ค๋Ÿฌ $('#zcPlay')?.addEventListener('click', () => { if (v.paused) v.play(); else v.pause(); }); $('#zcReset')?.addEventListener('click', () => { setZoom(1); }); $('#zcExit')?.addEventListener('click', () => { (document.exitFullscreen || document.webkitExitFullscreen).call(document); }); // ์ง„ํ–‰๋ฐ” โ€” ์‚ฌ์šฉ์ž๊ฐ€ ๋“œ๋ž˜๊ทธ ์ค‘์—๋Š” ์ž๋™ ๊ฐฑ์‹  ๋ฉˆ์ถค let seeking = false; $('#zcBar')?.addEventListener('input', () => { seeking = true; }); $('#zcBar')?.addEventListener('change', () => { if (!v.duration) return; v.currentTime = (parseFloat($('#zcBar').value) / 1000) * v.duration; seeking = false; }); v.addEventListener('timeupdate', () => { if (!zoomCtrl.hidden && v.duration) { if (!seeking) $('#zcBar').value = (v.currentTime / v.duration) * 1000; const fmt = (s) => `${Math.floor(s/60)}:${String(Math.floor(s%60)).padStart(2,'0')}`; $('#zcTime').textContent = `${fmt(v.currentTime)} / ${fmt(v.duration)}`; } }); v.addEventListener('play', () => { $('#zcPlay').textContent = 'โšโš'; }); v.addEventListener('pause', () => { $('#zcPlay').textContent = 'โ–ถ'; }); // ๋ณผ๋ฅจ ์ปจํŠธ๋กค + ๋กœ์ปฌ(๋””๋ฐ”์ด์Šค)๋ณ„ ๋ณผ๋ฅจ ์ €์žฅ/๋ณต์›. // ํ”„๋กœํ•„ ๋ฌด๊ด€ ์ „์—ญ ํ‚ค(tvchak.volume/tvchak.muted) โ€” ์ด ๋ธŒ๋ผ์šฐ์ €์—์„œ๋งŒ ์œ ์ง€๋˜๋ฉด ๋˜๋ฏ€๋กœ. // ์ƒˆ๋กœ๊ณ ์นจ ์‹œ <video>๋Š” ๊ธฐ๋ณธ๊ฐ’ volume=1๋กœ ์ดˆ๊ธฐํ™”๋˜๋Š”๋ฐ, ์ €์žฅ๊ฐ’์ด ์žˆ์œผ๋ฉด ๊ทธ๊ฑธ๋กœ ๋ณต์›. const LS_VOLUME = 'tvchak.volume'; const LS_MUTED = 'tvchak.muted'; function saveVol() { try { localStorage.setItem(LS_VOLUME, String(v.volume)); localStorage.setItem(LS_MUTED, v.muted ? '1' : '0'); } catch {} } function restoreVol() { try { const sv = localStorage.getItem(LS_VOLUME); if (sv !== null) { const n = parseFloat(sv); if (!isNaN(n) && n >= 0 && n <= 1) v.volume = n; } // muted๋Š” ์ €์žฅ๊ฐ’ ์šฐ์„ . ๋‹จ, ๋ธŒ๋ผ์šฐ์ € ์ž๋™์žฌ์ƒ ์ •์ฑ…์œผ๋กœ muted๊ฐ€ ๊ฐ•์ œ๋  ์ˆ˜ ์žˆ์œผ๋‹ˆ ๊ฐ’๋งŒ ๋ฐ˜์˜. const sm = localStorage.getItem(LS_MUTED); if (sm !== null) v.muted = sm === '1'; } catch {} } function syncVolUI() { const vol = v.muted ? 0 : v.volume; $('#zcVol').value = Math.round(vol * 100); $('#zcMute').textContent = (v.muted || v.volume === 0) ? '๐Ÿ”‡' : (v.volume < 0.5 ? '๐Ÿ”‰' : '๐Ÿ”Š'); } $('#zcVol')?.addEventListener('input', (e) => { const v2 = parseInt(e.target.value, 10) / 100; v.volume = v2; v.muted = v2 === 0; syncVolUI(); }); $('#zcMute')?.addEventListener('click', () => { v.muted = !v.muted; syncVolUI(); }); v.addEventListener('volumechange', () => { syncVolUI(); saveVol(); }); // ์ €์žฅ๋œ ๋ณผ๋ฅจ ๋ณต์› ํ›„ ์ดˆ๊ธฐ ๋™๊ธฐํ™”. (์ƒˆ <video> src ๋กœ๋“œ ์‹œ์—๋„ volume์€ ์œ ์ง€๋˜์ง€๋งŒ, // ์ „์ฒด ์ƒˆ๋กœ๊ณ ์นจ์—์„  ์ดˆ๊ธฐํ™”๋˜๋ฏ€๋กœ loadstart์—์„œ๋„ ํ•œ ๋ฒˆ ๋” ๋ณต์›.) restoreVol(); v.addEventListener('loadstart', restoreVol); syncVolUI(); window.addEventListener('mousemove', (e) => { if (!dragStart) return; tx = e.clientX - dragStart.x; ty = e.clientY - dragStart.y; clampPan(); apply(); }); window.addEventListener('mouseup', () => { if (dragStart) { dragStart = null; apply(); } }); // ํ•€์น˜ ์คŒ (๋ชจ๋ฐ”์ผ) v.addEventListener('touchstart', (e) => { if (e.touches.length === 2) { pinchStart = { dist: tdist(e.touches[0], e.touches[1]), zoom }; } else if (e.touches.length === 1 && zoom > 1) { dragStart = { x: e.touches[0].clientX - tx, y: e.touches[0].clientY - ty }; } }, { passive: true }); v.addEventListener('touchmove', (e) => { if (e.touches.length === 2 && pinchStart) { const d = tdist(e.touches[0], e.touches[1]); setZoom(pinchStart.zoom * (d / pinchStart.dist)); } else if (e.touches.length === 1 && dragStart && zoom > 1) { tx = e.touches[0].clientX - dragStart.x; ty = e.touches[0].clientY - dragStart.y; clampPan(); apply(); } }, { passive: true }); v.addEventListener('touchend', (e) => { if (e.touches.length < 2) pinchStart = null; if (e.touches.length === 0) dragStart = null; }); function tdist(a, b) { const dx = a.clientX - b.clientX, dy = a.clientY - b.clientY; return Math.sqrt(dx * dx + dy * dy); } // src ๋ฐ”๋€Œ๋ฉด ๋ฆฌ์…‹ โ€” ๋‹จ, ํ’€์Šคํฌ๋ฆฐ ์œ ์ง€ ์ค‘์ด๋ฉด ์ €์žฅ๋œ zoom์„ ๋‹ค์‹œ ๋ณต์› (HLS ๋ฆฌ๋กœ๋“œ/์—๋Ÿฌ ๋ณต๊ตฌ/์ž๋™ ๋‹ค์Œํ™” ๋“ฑ) const obs = new MutationObserver(() => { zoom = 1; tx = 0; ty = 0; apply(); if (isFullscreen()) restoreSavedZoom(); }); obs.observe(v, { attributes: true, attributeFilter: ['src'] }); // HLS๋Š” src ์†์„ฑ์ด ์•ˆ ๋ฐ”๋€Œ๊ณ  MediaSource๋กœ attach๋˜๋ฏ€๋กœ, loadedmetadata์—์„œ๋„ ํ•œ ๋ฒˆ ๋” ๋ณต์› ์‹œ๋„ v.addEventListener('loadedmetadata', () => { if (isFullscreen() && zoom === 1) restoreSavedZoom(); }); // ๋‹จ์ถ•ํ‚ค ํ•ธ๋“ค๋Ÿฌ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋„๋ก ์ „์—ญ ๋…ธ์ถœ window._videoZoom = { getZoom: () => zoom, setZoom, isFullscreen, }; })(); // โ”€โ”€โ”€ ์ž๋™ ๋‹ค์Œ ํ™” โ”€โ”€โ”€ $('#player').addEventListener('error', async () => { const v = $('#player'); // src ๋น„์—ˆ๊ฑฐ๋‚˜(stop ๋“ฑ) ์˜๋„๋œ ์ƒํƒœ๋ฉด ๋ฌด์‹œ if (!v.src || v.src === location.href) return; console.warn('video error', v.error); $('#videoEmpty').textContent = '์ด ํšŒ์ฐจ์˜ ์˜์ƒ์ด ์—†์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํšŒ์ฐจ๋ฅผ ์„ ํƒํ•ด๋ณด์„ธ์š”.'; $('#videoEmpty').classList.remove('hide'); $('#videoLoading').style.display = 'none'; // ํ•œ ๋ฒˆ๋งŒ ์ตœ์‹ ํ™”๋กœ ์ž๋™ ๋ณต๊ตฌ if (!playEpisode._fallback && currentEpList.length && currentEpIdx >= 0) { const latest = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid)[0]; const cur = currentEpList[currentEpIdx]; if (latest && (latest.sid !== cur.sid || latest.nid !== cur.nid)) { playEpisode._fallback = true; try { await playEpisode(currentFavId, latest.sid, latest.nid); } finally { playEpisode._fallback = false; } } } }); // โ”€โ”€โ”€ ์‹œ์ฒญ ์ง„๋„ ์ž๋™ ์ €์žฅ โ”€โ”€โ”€ // src ๊ต์ฒด ํ›„ ์ƒˆ ์˜์ƒ ๋ฐ์ดํ„ฐ๊ฐ€ ๋„์ฐฉํ•˜๋ฉด ์Šคํ‚ต ์ž๋™ ์ฒ˜๋ฆฌ ์žฌ๊ฐœ $('#player').addEventListener('loadeddata', () => { playEpisode._skipsLoading = false; }); $('#player').addEventListener('emptied', () => { playEpisode._skipsLoading = true; }); $('#player').addEventListener('timeupdate', () => { const v = $('#player'); if (!v.duration || isNaN(v.duration)) return; // src ๊ต์ฒด ์งํ›„ ์ž”์กด timeupdate์—์„œ ์—”๋”ฉ ์ž๋™ ํŠธ๋ฆฌ๊ฑฐ๊ฐ€ ์žฌ๋ฐœ์‚ฌ๋˜๋Š” ์‚ฌ๊ณ  ์ฐจ๋‹จ if (playEpisode._skipsLoading) return; // edFromEnd ์ž๋™ ๋ชจ๋“œ: ์˜์ƒ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋„์ฐฉ ํ›„(_currentSkips.ed ๋ฏธ์„ค์ • ์ƒํƒœ) 1ํšŒ ๋นŒ๋“œ if (currentFavId && !_currentSkips?.ed) { const fav = favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === (currentFavSource || 'tvchak')); if (fav?.skip?.edFromEnd) rebuildCurrentSkips(fav); } // ์Šคํ‚ต ์ž๋™ ์ฒ˜๋ฆฌ: // - ์˜คํ”„๋‹: ๊ตฌ๊ฐ„ ์ง„์ž… ์ฆ‰์‹œ ์ž๋™ ์ ํ”„ (ํšŒ์ฐจ๋‹น 1ํšŒ). ์‚ฌ์šฉ์ž๊ฐ€ ๋“œ๋ž˜๊ทธ๋กœ ๋‹ค์‹œ ๋“ค์–ด๊ฐ€๋„ ์žฌ์‹คํ–‰ ์•ˆ ํ•จ. // - ์—”๋”ฉ: ๋‹ค์Œ ํ™” ์žˆ์œผ๋ฉด 5์ดˆ ์นด์šดํŠธ๋‹ค์šด ํ›„ ์ž๋™ ๋‹ค์Œ ํ™” (์ด๋ฏธ ํ‘œ์‹œ ์ค‘์ด๋ฉด ์žฌํŠธ๋ฆฌ๊ฑฐ X). ๋‹ค์Œ ํ™” ์—†์œผ๋ฉด ๋ฒ„ํŠผ ํ‘œ์‹œ. const skipBtn = $('#btnSkip'); const cur = v.currentTime; let skipLabel = null, jumpTo = null, action = 'seek'; if (_currentSkips?.op && cur >= _currentSkips.op.start && cur < _currentSkips.op.end - 1) { // ์˜คํ”„๋‹: ํšŒ์ฐจ๋‹น 1๋ฒˆ๋งŒ ์ž๋™ ์Šคํ‚ต (์ด์ค‘ ์‹คํ–‰ ๋ฐฉ์ง€) if (!playEpisode._opAutoSkipped) { playEpisode._opAutoSkipped = true; try { v.currentTime = _currentSkips.op.end; } catch {} if (typeof showMediaToast === 'function') showMediaToast('์˜คํ”„๋‹ ์Šคํ‚ต โญ', 1200); } else { // ์ด๋ฏธ ์ž๋™ ์ฒ˜๋ฆฌ๋๋Š”๋ฐ๋„ ์‚ฌ์šฉ์ž๊ฐ€ ๋‹ค์‹œ ๊ทธ ๊ตฌ๊ฐ„์— ์žˆ๋‹ค = ์‚ฌ์šฉ์ž ์˜๋„. ์ˆ˜๋™ ๋ฒ„ํŠผ๋งŒ ํ‘œ์‹œ skipLabel = '์˜คํ”„๋‹ ์Šคํ‚ต โญ'; jumpTo = _currentSkips.op.end; } } else if (_currentSkips?.ed) { const edEnd = isFinite(_currentSkips.ed.end) ? _currentSkips.ed.end : v.duration; if (cur >= _currentSkips.ed.start && cur < edEnd - 1) { // ๋‹ค์Œ ํ™” = ๋” ์ตœ์‹  (์‚ฌ์ดํŠธ nid๋Š” 1์ด ์ตœ์‹ , ํฐ nid๊ฐ€ ์˜›๋‚ ). sortedAsc๋Š” nid asc ์ •๋ ฌ์ด๋ผ idx-1์ด ๋” ์ตœ์‹ . const sortedAsc = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid); const idx = sortedAsc.findIndex(e => e.sid === currentEpList[currentEpIdx]?.sid && e.nid === currentEpList[currentEpIdx]?.nid); const hasNext = idx > 0; if (hasNext) { // ์—”๋”ฉ: ๋‹ค์Œ ํ™”๋กœ 5์ดˆ ์นด์šดํŠธ๋‹ค์šด ์ž๋™ ์‹œ์ž‘ (ํšŒ์ฐจ๋‹น 1ํšŒ) if (!playEpisode._edAutoTriggered) { playEpisode._edAutoTriggered = true; const nextEp = sortedAsc[idx - 1]; startNextCountdown(nextEp); } // ์นด์šดํŠธ๋‹ค์šด ๋„์›Œ๋‘” ์ƒํƒœ์—์„œ๋Š” btnSkip ๋”ฐ๋กœ ์•ˆ ๋„์›€ (UI ์ค‘๋ณต ๋ฐฉ์ง€) } else { // ๋‹ค์Œ ํ™” ์—†์œผ๋ฉด ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ ํด๋ฆญ (์˜์ƒ ๋์œผ๋กœ ์ ํ”„๋งŒ) skipLabel = '์—”๋”ฉ ์Šคํ‚ต โญ'; jumpTo = edEnd; } } } if (skipBtn) { if (skipLabel) { const stamp = action + '|' + (jumpTo || ''); if (skipBtn.dataset.stamp !== stamp) { skipBtn.textContent = skipLabel; skipBtn.dataset.stamp = stamp; skipBtn.dataset.action = action; skipBtn.dataset.jump = jumpTo || ''; } skipBtn.hidden = false; skipBtn.classList.add('show'); } else { skipBtn.classList.remove('show'); } } if (!currentFavId || currentEpIdx < 0) return; // throttle: 10์ดˆ (์ด์–ด๋ณด๊ธฐ ์ •ํ™•๋„ vs NAS ํ‘ธ์‹œ ๋ถ€ํ•˜ ๊ท ํ˜•). // - 5์ดˆ๋Š” autossh tunnel polluting โ†’ SOCKS5 stall ์žฌ๋ฐœ ์œ„ํ—˜. // - 30์ดˆ๋Š” ๋งˆ์ง€๋ง‰ ๋ณธ ์‹œ์ ์ด ์ตœ๋Œ€ 30์ดˆ ์ „์œผ๋กœ ์ €์žฅ โ†’ ๋ณต์› ๋ฐฑ์˜คํ”„์™€ ๊ณฑํ•ด์ ธ ์ด์–ด๋ณด๊ธฐ๊ฐ€ ํ•œ์ฐธ ๋’ค๋กœ ๊ฐ. // - 10์ดˆ + pause/hidden/beforeunload ์ฆ‰์‹œ flush ์กฐํ•ฉ์œผ๋กœ ์–‘์ชฝ ๊ท ํ˜•. const now = Date.now(); if ((playEpisode._lastSave || 0) + 10000 > now) return; saveProgressNow(); }); // pause/ํƒญ ์ดํƒˆ/ํŽ˜์ด์ง€ ์ข…๋ฃŒ ์‹œ ์ฆ‰์‹œ ์ €์žฅ (throttle ๋ฌด์‹œ). // timeupdate ๋งˆ์ง€๋ง‰ ๋ฐœํ™” ์ดํ›„ ~10์ดˆ ์†์‹ค์„ ๋ฐฉ์ง€. function saveProgressNow() { const v = $('#player'); if (!v || !v.duration || isNaN(v.duration)) return; if (!currentFavId || currentEpIdx < 0) return; const fav = favs.find(f => f.id === currentFavId); if (!fav) return; const ep = currentEpList[currentEpIdx]; if (!ep) return; const label = ep.label || `${ep.nid}ํ™”`; playEpisode._lastSave = Date.now(); fav.progress = fav.progress || {}; fav.progress[label] = fav.progress[label] || {}; fav.progress[label].time = v.currentTime; if (isFinite(v.duration) && v.duration > 0) fav.progress[label].duration = v.duration; if (!fav.progress[label].finished && v.duration - v.currentTime < 180) { fav.progress[label].finished = true; fav.lastFinishedLabel = label; fav.lastSeenLabel = label; if (fav.knownCount != null) fav.lastSeenCount = fav.knownCount; markCaughtUpIfNeeded(fav); renderFavs(); renderEpisodes(); } saveFavs(); } // ์‹ค์ œ ์žฌ์ƒ ์‹œ์ž‘ โ†’ clickedAt ๊ฐฑ์‹ . ๋‹ค๋ฅธ ๋””๋ฐ”์ด์Šค๊ฐ€ ์ฐ์€ ์˜› clickedAt์ด // pull๋กœ ๋‚ด๋ ค์™€์„œ "10์‹œ๊ฐ„ ์ „"์ฒ˜๋Ÿผ ๋ณด์ด๋Š” ๋ฌธ์ œ ๋ฐฉ์ง€. ํ•œ ๋ฒˆ ์ฐ์œผ๋ฉด ๊ทธ ์„ธ์…˜ ๋™์•ˆ ์žฌ๋ฐœํ™” ๋ฌด์‹œ. $('#player').addEventListener('play', () => { if (!currentFavId) return; if (playEpisode._clickedAtBumpedForCurrent) return; const fav = favs.find(f => f.id === currentFavId); if (!fav) return; fav.clickedAt = Date.now(); playEpisode._clickedAtBumpedForCurrent = true; saveFavs(); renderFavs(); }); $('#player').addEventListener('pause', () => { saveProgressNow(); }); document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden') { saveProgressNow(); // ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ง„์ž… ์‹œ ์žฌ์ƒ ์ค‘์ธ ์˜์ƒ์€ PIP๋กœ (Chrome/TWA. autopictureinpicture ์†์„ฑ ๋ณด๊ฐ•). const v = $('#player'); if (v && !v.paused && !v.ended && v.readyState >= 2 && document.pictureInPictureEnabled && !document.pictureInPictureElement) { v.requestPictureInPicture().catch(() => { /* ๊ถŒํ•œยท์‚ฌ์šฉ์ž ์ œ์Šค์ฒ˜ ์—†์œผ๋ฉด ๋ฌด์‹œ */ }); } } }); window.addEventListener('beforeunload', () => { saveProgressNow(); }); window.addEventListener('pagehide', () => { saveProgressNow(); }); $('#player').addEventListener('ended', () => { if (!currentFavId || currentEpIdx < 0 || !currentEpList.length) return; // ๋น„์ •์ƒ ์ข…๋ฃŒ(๋„คํŠธ์›Œํฌ ๋Š๊น€์œผ๋กœ video๊ฐ€ ended ๋ฐœํ™”ํ•˜๋Š” ์ผ€์ด์Šค) ๊ฐ€๋“œ: // - duration์ด ์œ ํšจํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ // - ๋๊นŒ์ง€ ๊ฐ€์ง€ ์•Š๊ณ  ended๊ฐ€ ๋ฐœํ™”ํ•œ ๊ฒฝ์šฐ (2์ดˆ ์ด์ƒ ๋‚จ์•˜๋Š”๋ฐ ended) // - ๋˜๋Š” navigator.onLine === false // ์ธ ๊ฒฝ์šฐ ๋‹ค์Œ ํ™” ์ž๋™ ์นด์šดํŠธ๋‹ค์šด์„ ์‹œ์ž‘ํ•˜์ง€ ์•Š์Œ. stall ๋ณต๊ตฌ ๋กœ์ง์— ๋งก๊น€. const vEl = document.getElementById('player'); const dur = vEl?.duration; if (!isFinite(dur) || dur <= 0) return; if (vEl && (dur - vEl.currentTime) > 2) return; if (typeof navigator !== 'undefined' && navigator.onLine === false) return; const fav = currentFavSource ? favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === currentFavSource) : favs.find(f => f.id === currentFavId); const ep = currentEpList[currentEpIdx]; if (!fav || !ep) return; const label = ep.label || `${ep.nid}ํ™”`; fav.progress = fav.progress || {}; fav.progress[label] = { time: 0, finished: true }; fav.lastFinishedLabel = label; fav.lastSeenLabel = label; if (fav.knownCount != null) fav.lastSeenCount = fav.knownCount; markCaughtUpIfNeeded(fav); saveFavs(); renderFavs(); renderEpisodes(); // ๋‹ค์Œ ํ™” = ๋” ์ตœ์‹  (nid ๋” ์ž‘์€ ๊ฒƒ) const sortedAsc = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid); const idx = sortedAsc.findIndex(e => e.sid === ep.sid && e.nid === ep.nid); if (idx > 0) { const next = sortedAsc[idx - 1]; // C5: 5์ดˆ ์นด์šดํŠธ๋‹ค์šด ํ›„ ์ž๋™์žฌ์ƒ (์‚ฌ์šฉ์ž๊ฐ€ ์ทจ์†Œ/์ฆ‰์‹œ ์‹œ์ฒญ ๊ฐ€๋Šฅ) startNextCountdown(next); } }); // C5: ๋‹ค์Œ ํ™” ์นด์šดํŠธ๋‹ค์šด let _ncTimer = null; function cancelNextCountdown() { if (_ncTimer) { clearInterval(_ncTimer); _ncTimer = null; } const el = document.getElementById('nextCountdown'); if (el) el.classList.remove('show'); } function startNextCountdown(nextEp) { cancelNextCountdown(); _ncPaused = false; const el = document.getElementById('nextCountdown'); const secEl = document.getElementById('ncSec'); const barEl = document.getElementById('ncBar'); const titleEl = document.getElementById('ncTitle'); if (!el || !nextEp) return; let secLeft = 5; const label = nextEp.label || `${nextEp.nid}ํ™”`; if (titleEl) titleEl.textContent = label; if (secEl) secEl.textContent = secLeft; if (barEl) { barEl.style.width = '100%'; } el.classList.add('show'); requestAnimationFrame(() => { if (barEl) barEl.style.width = '0%'; }); _ncTimer = setInterval(() => { if (_ncPaused) return; secLeft--; if (secEl) secEl.textContent = Math.max(0, secLeft); if (secLeft <= 0) { cancelNextCountdown(); playEpisode(currentFavId, nextEp.sid, nextEp.nid, { userInitiated: true }).then(() => { $('#player').play().catch(() => {}); }); } }, 1000); } // โ”€โ”€โ”€ ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ โ”€โ”€โ”€ $('#btnAdd')?.addEventListener('click', openAddModal); $('#btnAddDt')?.addEventListener('click', openAddModal); $('#addCancel').addEventListener('click', closeAddModal); $('#addOk').addEventListener('click', async () => { const v = $('#addUrl').value; if (!v.trim()) return; closeAddModal(); await addFav(v); }); $('#addUrl').addEventListener('keydown', e => { if (e.key === 'Enter') $('#addOk').click(); }); $('#addModal').addEventListener('click', e => { if (e.target.id === 'addModal') closeAddModal(); }); async function refreshAll() { for (const f of favs) { try { const src = f.source || 'tvchak'; const titleQ = f.title ? `&title=${encodeURIComponent(f.title)}` : ''; const ep = await api(`/api/episodes?id=${f.id}&nocache=1&source=${src}${titleQ}`); if (ep.error || !ep.episodes) continue; if (!f.title) f.title = ep.title; f.knownCount = ep.count; // ์‚ฌ์ดํŠธ ์ตœ์‹  ํšŒ์ฐจ ๋ผ๋ฒจ (NEW ํŒ์ •์šฉ) const latest = ep.episodes.find(e => e.sid === 1 && e.nid === 1) || ep.episodes[0]; f.latestLabel = latest?.label || null; // ์ƒˆ ํšŒ์ฐจ ์˜ฌ๋ผ์˜ค๋ฉด์„œ nid๊ฐ€ ๋ฐ€๋ฆฐ ๊ฒฝ์šฐ, ์‚ฌ์šฉ์ž๊ฐ€ ๋ณธ ํšŒ์ฐจ(lastLabel)์˜ nid ์žฌ๋ฐฐ์น˜ if (f.lastLabel) { const m = ep.episodes.find(e => e.label === f.lastLabel); if (m && (m.sid !== f.lastSid || m.nid !== f.lastNid)) { f.lastSid = m.sid; f.lastNid = m.nid; } } // ์ฒ˜์Œ ์ฆ๊ฒจ์ฐพ๊ธฐ ๋งŒ๋“ค๊ณ  ํ•œ ๋ฒˆ๋„ ๋ณธ ์  ์—†์œผ๋ฉด ๊ทธ ์‹œ์  ์ตœ์‹ ํ™” ๊ธฐ์ค€์œผ๋กœ (NEW ์•ˆ ๋œจ๋„๋ก) if (f.lastSeenLabel == null) { f.lastSeenLabel = f.latestLabel; f.lastSeenCount = ep.count; } markCaughtUpIfNeeded(f); } catch {} } saveFavs(); renderFavs(); // ํ˜„์žฌ ๋ณด๊ณ  ์žˆ๋Š” ์ฆ๊ฒจ์ฐพ๊ธฐ๋Š” ํšŒ์ฐจ ๋ชฉ๋ก๋„ ๋‹ค์‹œ ๋กœ๋“œ if (currentFavId) { const fav = currentFavSource ? favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === currentFavSource) : favs.find(f => f.id === currentFavId); if (fav) { const src = fav.source || 'tvchak'; const titleQ = fav.title ? `&title=${encodeURIComponent(fav.title)}` : ''; const ep = await api(`/api/episodes?id=${fav.id}&nocache=1&source=${src}${titleQ}`); if (!ep.error) { currentEpList = ep.episodes || []; if (fav.lastSid != null) { currentEpIdx = currentEpList.findIndex(e => e.sid === fav.lastSid && e.nid === fav.lastNid); } renderEpisodes(); } } } } // ๋ณด๊ด€ํ•จ NEW ์ž๋™ ๊ฐ์ง€ โ€” ๋ถ€ํŒ… + ์ฃผ๊ธฐ ํด๋ง + ํƒญ visibility ๋ณต๊ท€ ์‹œ ํ˜ธ์ถœ. // /api/latest-labels๋Š” ์บ์‹œ๋œ episodes์—์„œ ์ตœ์‹  ๋ผ๋ฒจ๋งŒ ๋ฝ‘์•„ ์ฆ‰์‹œ ๋ฐ˜ํ™˜. // ์บ์‹œ miss์ธ ํ•ญ๋ชฉ์€ ์„œ๋ฒ„๊ฐ€ ๋ฐฑ๊ทธ๋ผ์šด๋“œ๋กœ fetchEpisodes ํŠธ๋ฆฌ๊ฑฐ โ†’ ๋‹ค์Œ ํ˜ธ์ถœ ๋•Œ hit. let _lastLatestLabelsAt = 0; const LATEST_LABELS_MIN_INTERVAL = 2 * 60 * 1000; // visibility ํŠธ๋ฆฌ๊ฑฐ ์ตœ์†Œ 2๋ถ„ ๊ฐ„๊ฒฉ (ํƒญ ์ „ํ™˜ ํญ์ฃผ ๋ฐฉ์ง€) const LATEST_LABELS_POLL_INTERVAL = 5 * 60 * 1000; // ์ฃผ๊ธฐ ํด๋ง 5๋ถ„ // pending ์žฌํ˜ธ์ถœ ์ง€์ˆ˜ ๋ฐฑ์˜คํ”„ โ€” 20โ†’40โ†’80โ†’160์ดˆ, ์ตœ๋Œ€ 3ํšŒ. // Why: ํ saturated๋กœ ์„œ๋ฒ„ fetch๊ฐ€ ๊ณ„์† ์‹คํŒจํ•˜๋ฉด ๊ฐ™์€ 20์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ ๋ฌดํ•œ ์žฌํ˜ธ์ถœ๋˜์–ด // ๋ฐฑ๊ทธ๋ผ์šด๋“œ task๊ฐ€ ๋ˆ„์  ํญ์ฃผ(2026-05-25 ์‚ฌ๊ณ ). ์ง€์ˆ˜ ๋ฐฑ์˜คํ”„ + ์ตœ๋Œ€ ํšŸ์ˆ˜๋กœ ์ฐจ๋‹จ. const LATEST_LABELS_RETRY_MAX = 3; const LATEST_LABELS_RETRY_BASE_MS = 20000; async function refreshLatestLabels(retryCount = 0) { if (!favs.length) return; const ids = favs.map(f => f.id).join(','); const sources = favs.map(f => f.source || 'tvchak').join(','); try { const r = await api(`/api/latest-labels?ids=${ids}&sources=${sources}`, { timeout: 15000 }); if (!r || !r.items) return; let changed = false; for (const it of r.items) { const f = favs.find(x => x.id === it.id && (x.source || 'tvchak') === it.source); if (!f) continue; if (it.latestLabel && f.latestLabel !== it.latestLabel) { f.latestLabel = it.latestLabel; changed = true; } if (it.count && f.knownCount !== it.count) { f.knownCount = it.count; changed = true; } } if (changed) { saveFavs(); renderFavs(); } _lastLatestLabelsAt = Date.now(); // pending์ด ์žˆ์œผ๋ฉด ์„œ๋ฒ„๊ฐ€ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ๊ฐฑ์‹  ์ค‘ โ€” ์ง€์ˆ˜ ๋ฐฑ์˜คํ”„๋กœ ์žฌํ˜ธ์ถœ. // ๋‹ค์Œ ์ฃผ๊ธฐ ํด๋ง(5๋ถ„)์ด ์žˆ์œผ๋ฏ€๋กœ ๋ฌดํ•œ ์žฌ์‹œ๋„๋Š” ๋ถˆํ•„์š”. if (r.pending && r.pending.length && retryCount < LATEST_LABELS_RETRY_MAX) { const delay = LATEST_LABELS_RETRY_BASE_MS * Math.pow(2, retryCount); setTimeout(() => refreshLatestLabels(retryCount + 1).catch(() => {}), delay); } } catch (e) { console.warn('refreshLatestLabels:', e.message); } } // ๋‹ค๋ฅธ ๋””๋ฐ”์ด์Šค์˜ ๋ณ€๊ฒฝ(clickedAt, lastFavId ๋“ฑ)์„ ๋ฐ›์•„ ์ •๋ ฌยทํ™œ์„ฑํ‘œ์‹œ ๋™๊ธฐํ™”. // pull ํ›„ lastFavId๊ฐ€ ๋ฐ”๋€Œ์—ˆ์œผ๋ฉด ํ™œ์„ฑ ์‹œ๋ฆฌ์ฆˆ๋กœ ์ž๋™ ์„ ํƒ(์‹œ์ฒญ ํ™”๋ฉด์€ ์œ ์ง€ํ•˜์ง€ ์•Š๊ณ  ๋ชฉ๋ก ๊ฐ•์กฐ๋งŒ). async function syncFavsFromOtherDevices() { const prevLast = lastFavId; await pullFavsFromServer(); renderFavs(); // ๋‹ค๋ฅธ ๋””๋ฐ”์ด์Šค๊ฐ€ ํ™œ์„ฑ ์‹œ๋ฆฌ์ฆˆ๋ฅผ ๋ฐ”๊ฟจ์„ ๋•Œ โ€” ํ˜„์žฌ ์‹œ์ฒญ ์ค‘์ธ ์‹œ๋ฆฌ์ฆˆ๊ฐ€ ๋”ฐ๋กœ ์—†์„ ๋•Œ๋งŒ ์ž๋™ ๋”ฐ๋ผ๊ฐ // (์ด๋ฏธ ๋‹ค๋ฅธ ๊ฑธ ๋ณด๊ณ  ์žˆ๋Š”๋ฐ ๊ฐ•์ œ๋กœ ํ™”๋ฉด ๊ฐˆ์•„์น˜์šฐ๋Š” ๊ฒƒ ๋ฐฉ์ง€) if (lastFavId && lastFavId !== prevLast && !currentFavId && favs.find(f => f.id == lastFavId)) { selectFav(+lastFavId, { silent: true }).catch(() => {}); } } // 15๋ถ„๋งˆ๋‹ค ์ฃผ๊ธฐ ํด๋ง โ€” ํŽ˜์ด์ง€๊ฐ€ visible์ผ ๋•Œ๋งŒ (hidden ํƒญ์—์„  ๋ถˆํ•„์š”ํ•œ ํ˜ธ์ถœ ์ ˆ์•ฝ) setInterval(() => { if (document.visibilityState !== 'visible') return; refreshLatestLabels().catch(() => {}); syncFavsFromOtherDevices().catch(() => {}); }, LATEST_LABELS_POLL_INTERVAL); // ํƒญ ์ „ํ™˜ยท์•ฑ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ๋ณต๊ท€ ์‹œ ์ฆ‰์‹œ ๊ฒ€์‚ฌ (๋‹จ ๋งˆ์ง€๋ง‰ ํ˜ธ์ถœ ํ›„ 5๋ถ„ ์ด์ƒ ์ง€๋‚ฌ์„ ๋•Œ๋งŒ) document.addEventListener('visibilitychange', () => { if (document.visibilityState !== 'visible') return; if (Date.now() - _lastLatestLabelsAt < LATEST_LABELS_MIN_INTERVAL) return; refreshLatestLabels().catch(() => {}); syncFavsFromOtherDevices().catch(() => {}); }); // ๋กœ๊ณ ("OTT โ”‚ PLAYER") ํด๋ฆญ โ†’ ํŽ˜์ด์ง€ ์ƒˆ๋กœ๊ณ ์นจ document.querySelectorAll('.brand').forEach(el => { el.addEventListener('click', () => location.reload()); }); // ์˜คํ”„๋‹/์—”๋”ฉ ์Šคํ‚ต ๋ฒ„ํŠผ (action='seek'๋ฉด ์ ํ”„, action='next'๋ฉด ๋‹ค์Œ ํ™”) $('#btnSkip')?.addEventListener('click', (e) => { e.stopPropagation(); const action = $('#btnSkip').dataset.action; if (action === 'next') { $('#btnSkip').classList.remove('show'); gotoEpisode(1); return; } const v = $('#player'); const jumpTo = parseFloat($('#btnSkip').dataset.jump); if (v && isFinite(jumpTo)) { v.currentTime = jumpTo; $('#btnSkip').classList.remove('show'); } }); // ์ด์ „ ํ™” / ๋‹ค์Œ ํ™” โ€” currentEpList ๊ธฐ์ค€ (nid ์ž‘์„์ˆ˜๋ก ์ตœ์‹ , ํฐ ๊ฒŒ ์˜ค๋ž˜) // "๋‹ค์Œ ํ™”"๋Š” ๋” ์ตœ์‹  ํšŒ์ฐจ = nid ๋” ์ž‘์€ ํšŒ์ฐจ function gotoEpisode(direction) { if (!currentFavId || !currentEpList.length) return; const sortedAsc = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid); const idx = sortedAsc.findIndex((e, i) => i === currentEpIdx) >= 0 ? sortedAsc.findIndex(e => e.sid === currentEpList[currentEpIdx]?.sid && e.nid === currentEpList[currentEpIdx]?.nid) : -1; if (idx < 0) return; // direction=1: ๋‹ค์Œ ํ™” (์ตœ์‹  ๋ฐฉํ–ฅ, idx-1), -1: ์ด์ „ ํ™” (์˜ค๋ž˜๋œ ๋ฐฉํ–ฅ, idx+1) const target = sortedAsc[idx - direction]; if (!target) return; playEpisode(currentFavId, target.sid, target.nid, { userInitiated: true }) .then(() => $('#player').play().catch(() => {})); } $('#filter')?.addEventListener('input', renderFavs); $('#filterMob')?.addEventListener('input', renderFavs); // ๋ชจ๋ฐ”์ผ ๊ฒ€์ƒ‰ $('#btnSearchToggle').addEventListener('click', () => { if ($('#searchBar').style.display === 'none') openMobileSearch(); else closeMobileSearch(); }); $('#searchClose').addEventListener('click', closeMobileSearch); $('#btnSearchMob').addEventListener('click', () => doSearch($('#searchInputMob').value, 'searchResultsMob')); $('#searchInputMob').addEventListener('keydown', e => { if (e.key === 'Enter') doSearch($('#searchInputMob').value, 'searchResultsMob'); }); // ๋ฐ์Šคํฌํƒ‘ ๊ฒ€์ƒ‰ $('#btnSearch')?.addEventListener('click', () => doSearch($('#searchInput').value, 'searchResults')); $('#searchCloseDt')?.addEventListener('click', () => { $('#searchResultsWrap').style.display = 'none'; $('#searchInput').value = ''; $('#searchResults').innerHTML = ''; }); $('#searchInput')?.addEventListener('keydown', e => { if (e.key === 'Enter') doSearch($('#searchInput').value, 'searchResults'); }); // โ”€โ”€โ”€ ํ‚ค๋…ธ๋ผ์ด์ธ  ๋žญํ‚น โ”€โ”€โ”€ let currentRankingPeriod = 'daily'; const rankingCache = {}; async function loadRanking(period) { currentRankingPeriod = period; renderRanking({ loading: true }); try { if (rankingCache[period]) { renderRanking({ data: rankingCache[period] }); return; } // pending ์‘๋‹ต โ†’ 5์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ ์ตœ๋Œ€ 6ํšŒ ์žฌ์‹œ๋„ (์„œ๋ฒ„๊ฐ€ fetch ์ค‘) let r = await api(`/api/ranking?period=${period}`, { timeout: 90000 }); for (let i = 0; i < 6 && (!r.items || !r.items.length) && r.pending; i++) { renderRanking({ loading: true, message: '๋žญํ‚น ๊ฐ€์ ธ์˜ค๋Š” ์ค‘โ€ฆ' }); await new Promise(rs => setTimeout(rs, 5000)); r = await api(`/api/ranking?period=${period}`, { timeout: 90000 }); } if (r.error) { renderRanking({ error: r.error }); return; } if (!r.items || !r.items.length) { renderRanking({ error: '๋žญํ‚น ๋ฐ์ดํ„ฐ ์—†์Œ' }); return; } rankingCache[period] = r; renderRanking({ data: r }); } catch (e) { renderRanking({ error: e.message }); } } function renderRankingDetail(host, d, title) { const meta = []; if (d.genre) meta.push(`<span>์žฅ๋ฅด<b>${esc(d.genre)}</b></span>`); if (d.airDate) meta.push(`<span>๋ฐฉ์˜<b>${esc(d.airDate)}</b></span>`); if (d.episodes) meta.push(`<span>ํšŒ์ฐจ<b>${esc(d.episodes)}</b></span>`); if (d.rating) meta.push(`<span>๋“ฑ๊ธ‰<b>${esc(d.rating)}</b></span>`); if (d.country) meta.push(`<span>๊ตญ๊ฐ€<b>${esc(d.country)}</b></span>`); if (d.score) meta.push(`<span>ํ‰์ <b style="color:#6ee7a8">${esc(d.score)}</b></span>`); host.innerHTML = ` ${d.synopsis ? `<div class="syn">${esc(d.synopsis)}</div>` : ''} ${meta.length ? `<div class="meta-row">${meta.join('')}</div>` : ''} ${(d.cast && d.cast.length) ? `<div class="cast"><b>์ถœ์—ฐ:</b> ${d.cast.map(esc).join(', ')}</div>` : ''} ${d.ott ? `<div class="cast"><b>OTT:</b> ${esc(d.ott)}</div>` : ''} <div class="trailer-wrap" data-trailer-title="${esc(title || '')}"> <div class="trailer-loading">์˜ˆ๊ณ ํŽธ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ</div> </div> `; // ์˜ˆ๊ณ ํŽธ ๋น„๋™๊ธฐ ๋กœ๋“œ loadTrailer(host.querySelector('.trailer-wrap'), title); } async function loadTrailer(host, title) { if (!host || !title) return; try { const r = await api(`/api/yt-trailer?title=${encodeURIComponent(title)}`); if (r.error || !r.embed) { host.innerHTML = ''; return; } host.innerHTML = ` <div class="trailer-label">์˜ˆ๊ณ ํŽธ</div> <div class="trailer-frame"> <iframe src="${esc(r.embed)}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen referrerpolicy="strict-origin-when-cross-origin"></iframe> </div> `; } catch { host.innerHTML = ''; } } function renderRanking(state) { const hosts = [$('#rankingBoxDt'), $('#rankingBoxMob')].filter(Boolean); const tabs = ['daily', 'weekly', 'monthly']; const tabLabel = { daily: '์ผ๊ฐ„', weekly: '์ฃผ๊ฐ„', monthly: '์›”๊ฐ„' }; let body = ''; if (state.loading) body = `<div style="padding:10px;color:var(--muted);font-size:12px">๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ</div>`; else if (state.error) body = `<div style="padding:10px;color:#ff7b7b;font-size:12px">${esc(state.error)}</div>`; else if (state.data) { body = '<div class="ranking-list">' + state.data.items.map((it, i) => { const kinoId = (it.href || '').match(/\/title\/(\d+)/)?.[1]; return ` <div class="rk-item" data-search="${esc(it.title)}" data-kid="${kinoId || ''}"> <div class="rk-rank">${i + 1}</div> ${it.poster ? `<img class="rk-poster" src="${esc(viaProxy(it.poster))}" loading="lazy" referrerpolicy="no-referrer" />` : `<div class="rk-poster placeholder">?</div>`} <div class="rk-title"> <b>${esc(it.title)}</b> <div class="rk-meta">${esc(it.category || '')}${it.year ? ' ยท ' + it.year : ''}</div> </div> ${kinoId ? `<button class="rk-more" data-more="${kinoId}" title="์ž์„ธํžˆ">์ž์„ธํžˆ</button>` : ''} </div> ${kinoId ? `<div class="rk-detail" data-detail="${kinoId}"></div>` : ''} `;}).join('') + '</div>'; } for (const host of hosts) { host.innerHTML = ` <div class="ranking-head"> <h3>OTT TOP 10</h3> <div class="ranking-tabs"> ${tabs.map(t => `<button data-period="${t}" class="${currentRankingPeriod === t ? 'active' : ''}">${tabLabel[t]}</button>`).join('')} </div> </div> ${body} `; // ํƒญ ์ด๋ฒคํŠธ host.querySelectorAll('.ranking-tabs button').forEach(b => { b.addEventListener('click', () => loadRanking(b.dataset.period)); }); // ํ•ญ๋ชฉ ํด๋ฆญ โ†’ ์ž๋™ ๊ฒ€์ƒ‰ (G-15: 1ํƒญ ๊ฒ€์ƒ‰ + ํ† ์ŠคํŠธ ํ”ผ๋“œ๋ฐฑ). ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๋กœ ์ž๋™ ์Šคํฌ๋กค host.querySelectorAll('.rk-item').forEach(it => { it.addEventListener('click', (e) => { if (e.target.closest('.rk-more')) return; // ์ž์„ธํžˆ ๋ฒ„ํŠผ์€ ๋ณ„๋„ ๋™์ž‘ const title = it.dataset.search; if (isMobile()) { openMobileSearch(); $('#searchInputMob').value = title; doSearch(title, 'searchResultsMob'); // ๋ชจ๋ฐ”์ผ์€ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ๋ณด๊ด€ํ•จ ์œ„์ชฝ์ด๋ผ ๊ทธ์ชฝ์œผ๋กœ ์Šคํฌ๋กค setTimeout(() => { $('#searchResultsMob')?.scrollIntoView({ behavior: 'smooth', block: 'start' }); }, 50); } else { $('#searchInput').value = title; doSearch(title, 'searchResults'); // ๋ฐ์Šคํฌํƒ‘: ์‚ฌ์ด๋“œ ํŒจ๋„ #searchResultsWrap์ด ํ‘œ์‹œ๋œ ํ›„ ๊ทธ๋ฆฌ๋กœ ์Šคํฌ๋กค setTimeout(() => { $('#searchResultsWrap')?.scrollIntoView({ behavior: 'smooth', block: 'start' }); }, 50); } showMediaToast?.(`๊ฒ€์ƒ‰: ${title}`); }); }); // "์ž์„ธํžˆ" ๋ฒ„ํŠผ โ†’ ์ƒ์„ธ ํŽผ์นจ host.querySelectorAll('.rk-more').forEach(btn => { btn.addEventListener('click', async (e) => { e.stopPropagation(); const kid = btn.dataset.more; const detail = host.querySelector(`.rk-detail[data-detail="${kid}"]`); if (!detail) return; const isOpen = detail.classList.contains('open'); // ๋‹ค๋ฅธ ํŽผ์นœ ๊ฑฐ ๋‹ค ๋‹ซ๊ธฐ + ๊ทธ ๋ฒ„ํŠผ ํ…์ŠคํŠธ๋„ "์ž์„ธํžˆ"๋กœ ๋˜๋Œ๋ฆฌ๊ธฐ (ํ•œ ๋ฒˆ์— ํ•˜๋‚˜๋งŒ) host.querySelectorAll('.rk-detail.open').forEach(d => { d.classList.remove('open'); const otherKid = d.dataset.detail; const otherBtn = host.querySelector(`.rk-more[data-more="${otherKid}"]`); if (otherBtn) otherBtn.textContent = '์ž์„ธํžˆ'; }); if (isOpen) { btn.textContent = '์ž์„ธํžˆ'; return; } btn.textContent = '์ ‘๊ธฐ'; detail.classList.add('open'); if (!detail.dataset.loaded) { detail.innerHTML = '<div class="loading">๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ</div>'; try { const r = await api(`/api/ranking-detail?id=${kid}`); if (r.error) throw new Error(r.error); const card = btn.closest('.rk-item'); renderRankingDetail(detail, r, card?.dataset.search || ''); detail.dataset.loaded = '1'; } catch (err) { detail.innerHTML = `<div class="loading">๋กœ๋“œ ์‹คํŒจ: ${esc(err.message)}</div>`; } } }); }); } } // โ”€โ”€โ”€ ๋ถ€ํŠธ โ”€โ”€โ”€ // โ”€โ”€โ”€ ์ผ์‹œ์ •์ง€ ์˜ค๋ฒ„๋ ˆ์ด (๊ฐ€์šด๋ฐ ํฐ ์žฌ์ƒ ๋ฒ„ํŠผ) โ”€โ”€โ”€ (function setupPauseOverlay() { const v = $('#player'); const overlay = $('#pauseOverlay'); if (!v || !overlay) return; function update() { // ์˜์ƒ ๋กœ๋“œ ์•ˆ ๋๊ฑฐ๋‚˜(src ์—†์Œ/empty ๋ฉ”์‹œ์ง€ ํ‘œ์‹œ ์ค‘) ended ์ƒํƒœ๋Š” ํ‘œ์‹œ ์•ˆ ํ•จ if (!v.src || v.ended) { overlay.hidden = true; return; } overlay.hidden = !v.paused; } v.addEventListener('play', update); v.addEventListener('pause', update); v.addEventListener('ended', update); v.addEventListener('loadedmetadata', update); v.addEventListener('emptied', () => { overlay.hidden = true; }); // ์˜ค๋ฒ„๋ ˆ์ด ํด๋ฆญ โ†’ ์žฌ์ƒ overlay.addEventListener('click', () => v.play().catch(() => {})); })(); // โ”€โ”€โ”€ ์ขŒ์ธก ํŒจ๋„ ํ† ๊ธ€/๋ฆฌ์‚ฌ์ด์ฆˆ (๋ฐ์Šคํฌํƒ‘) โ”€โ”€โ”€ function toggleSidePanel() { // ํ† ๊ธ€ ์• ๋‹ˆ๋ฉ”์ด์…˜๋งŒ transition ์ผœ๊ณ , ๋๋‚˜๋ฉด ๋„๊ธฐ (๋“œ๋ž˜๊ทธ ์‹œ ๋Š๊น€ ๋ฐฉ์ง€) document.body.classList.add('with-transition'); const next = !document.body.classList.contains('left-collapsed'); document.body.classList.toggle('left-collapsed', next); localStorage.setItem('tvchak.leftCollapsed', next ? '1' : '0'); setTimeout(() => document.body.classList.remove('with-transition'), 250); } (function setupSideToggle() { const collapsed = localStorage.getItem('tvchak.leftCollapsed') === '1'; if (collapsed) document.body.classList.add('left-collapsed'); // ์ €์žฅ๋œ ๋„ˆ๋น„ ์ ์šฉ const savedW = parseInt(localStorage.getItem('tvchak.leftWidth') || '0', 10); if (savedW >= 200 && savedW <= 600) document.body.style.setProperty('--left-w', savedW + 'px'); $('#btnSideToggle')?.addEventListener('click', toggleSidePanel); // ๋“œ๋ž˜๊ทธ ๋ฆฌ์‚ฌ์ด์ฆˆ const handle = $('#resizeHandle'); if (handle) { let dragging = false; handle.addEventListener('mousedown', (e) => { e.preventDefault(); dragging = true; handle.classList.add('dragging'); document.body.style.cursor = 'ew-resize'; document.body.style.userSelect = 'none'; }); window.addEventListener('mousemove', (e) => { if (!dragging) return; const w = Math.max(200, Math.min(600, e.clientX)); document.body.style.setProperty('--left-w', w + 'px'); }); window.addEventListener('mouseup', () => { if (!dragging) return; dragging = false; handle.classList.remove('dragging'); document.body.style.cursor = ''; document.body.style.userSelect = ''; const w = parseInt(getComputedStyle(document.body).getPropertyValue('--left-w'), 10); if (w >= 200 && w <= 600) localStorage.setItem('tvchak.leftWidth', String(w)); }); // ๋”๋ธ”ํด๋ฆญ โ†’ ๊ธฐ๋ณธ ๋„ˆ๋น„ ๋ฆฌ์…‹ handle.addEventListener('dblclick', () => { document.body.style.setProperty('--left-w', '340px'); localStorage.setItem('tvchak.leftWidth', '340'); }); } })(); // โ”€โ”€โ”€ ํ‚ค๋ณด๋“œ ๋‹จ์ถ•ํ‚ค โ”€โ”€โ”€ // ํ™”๋ฉด ์ž ๊ธˆ (๋ชจ๋ฐ”์ผ ํ’€์Šคํฌ๋ฆฐ) (function setupLock() { const wrap = $('#videoWrap'); const btn = $('#btnLock'); if (!wrap || !btn) return; // ์ž ๊ธด ์ž๋ฌผ์‡ (๋‹ซํžŒ ๊ณ ๋ฆฌ) / ์—ด๋ฆฐ ์ž๋ฌผ์‡ (๊ณ ๋ฆฌ ๋ถ„๋ฆฌ) const SVG_LOCKED = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="11" width="16" height="10" rx="2"></rect><path d="M8 11V8a4 4 0 0 1 8 0v3"></path></svg>'; const SVG_UNLOCKED = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="11" width="16" height="10" rx="2"></rect><path d="M8 11V8a4 4 0 0 1 8 0v3M16 5v3"></path></svg>'; function setLocked(on) { wrap.classList.toggle('locked', on); btn.innerHTML = on ? SVG_LOCKED : SVG_UNLOCKED; btn.title = on ? 'ํ™”๋ฉด ์ž ๊ธˆ ํ•ด์ œ' : 'ํ™”๋ฉด ์ž ๊ธˆ'; } btn.addEventListener('click', (e) => { e.stopPropagation(); setLocked(!wrap.classList.contains('locked')); // ์ž ๊ธˆ ์งํ›„ ์ž๋ฌผ์‡ ๊ฐ€ ์ž ์‹œ ํฌ๋ฏธํ•˜๊ฒŒ ๋ณด์˜€๋‹ค ์‚ฌ๋ผ์ง€๋„๋ก (show-controls 3์ดˆ ์œ ์ง€) if (wrap.classList.contains('locked')) pingLockHint(); }); // ํ’€์Šคํฌ๋ฆฐ ๋‚˜๊ฐ€๋ฉด ์ž๋™ ํ•ด์ œ document.addEventListener('fullscreenchange', () => { if (!document.fullscreenElement) setLocked(false); }); document.addEventListener('webkitfullscreenchange', () => { if (!document.webkitFullscreenElement) setLocked(false); }); // ์ž ๊ธˆ ์ƒํƒœ์—์„  wrap ๋‚ด ๋‹ค๋ฅธ ์ด๋ฒคํŠธ(ํด๋ฆญ/ํ„ฐ์น˜/๋”๋ธ”ํด๋ฆญ/ํœ )๋ฅผ ์บก์ฒ˜ ๋‹จ๊ณ„์—์„œ ์ฐจ๋‹จ // ๋‹จ, ํ„ฐ์น˜ ์‹ ํ˜ธ๋Š” ์ž ๊ธˆ ๋ฒ„ํŠผ๋งŒ ์ž ๊น ๋…ธ์ถœ์‹œํ‚ค๊ธฐ ์œ„ํ•œ ํŠธ๋ฆฌ๊ฑฐ๋กœ๋„ ์‚ฌ์šฉ (3์ดˆ ํ›„ ์ž๋™ ์ˆจ๊น€) let _lockHintTimer = null; let _lockHintLast = 0; function pingLockHint() { const now = Date.now(); // ๋””๋ฐ”์šด์Šค: 300ms ๋‚ด ์ค‘๋ณต ํ˜ธ์ถœ์€ ํƒ€์ด๋จธ๋งŒ ๊ฐฑ์‹  (๋ฏธ์„ธ ํ„ฐ์น˜ ๋ฌดํ•œ ํ˜ธ์ถœ ์‚ฌ๊ณ  ๋ฐฉ์ง€) if (now - _lockHintLast < 300 && wrap.classList.contains('show-controls')) { clearTimeout(_lockHintTimer); _lockHintTimer = setTimeout(() => { if (wrap.classList.contains('locked')) wrap.classList.remove('show-controls'); }, 3000); return; } _lockHintLast = now; wrap.classList.add('show-controls'); clearTimeout(_lockHintTimer); _lockHintTimer = setTimeout(() => { if (wrap.classList.contains('locked')) wrap.classList.remove('show-controls'); }, 3000); } // ๋‹ค๋ฅธ IIFE์˜ showControls๊ฐ€ ์ž ๊ธˆ ์ƒํƒœ์ผ ๋•Œ ์œ„์ž„ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋…ธ์ถœ window.__pingLockHint = pingLockHint; const blockedTypes = ['click', 'dblclick', 'touchstart', 'touchend', 'touchmove', 'wheel', 'mousedown', 'pointerdown']; // ์ž๋ฌผ์‡  hint ์žฌ๋…ธ์ถœ์€ ๋ช…์‹œ์  ์˜๋„๊ฐ€ ๋ณด์ด๋Š” ์ด๋ฒคํŠธ(touchstart/pointerdown/mousedown/click)์—๋งŒ. // touchmove/wheel์€ ๋ฏธ์„ธ ์ž…๋ ฅ์ด๋ผ ping ํ˜ธ์ถœ ์•ˆ ํ•จ. const hintTypes = new Set(['touchstart', 'pointerdown', 'mousedown', 'click']); for (const type of blockedTypes) { wrap.addEventListener(type, (e) => { if (!wrap.classList.contains('locked')) return; // ์ž ๊ธˆ ๋ฒ„ํŠผ ์ž์ฒด๋Š” ํ†ต๊ณผ if (e.target.closest('#btnLock')) return; // ์ž ๊ธˆ ์ค‘ wrap ํ„ฐ์น˜/ํด๋ฆญ์€ ์ฐจ๋‹จ + ์ž๋ฌผ์‡  hint ์žฌ๋…ธ์ถœ (๋””๋ฐ”์šด์Šค๋กœ ๋ฌดํ•œ ํ˜ธ์ถœ ๋ฐฉ์ง€) if (hintTypes.has(type)) pingLockHint(); e.stopPropagation(); e.preventDefault?.(); }, true); } })(); // F: ํ’€์Šคํฌ๋ฆฐ(ํ™•๋Œ€ ๊ฐ€๋Šฅ) ํ† ๊ธ€ / S: ์ขŒ์ธก ํŒจ๋„ ์ ‘๊ธฐยทํŽผ์น˜๊ธฐ (function setupShortcuts() { document.addEventListener('keydown', (e) => { // ์ž…๋ ฅ ํ•„๋“œ์— ํฌ์ปค์Šค๋˜์–ด ์žˆ์œผ๋ฉด ๋ฌด์‹œ const t = e.target; if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return; if (e.ctrlKey || e.metaKey || e.altKey) return; const k = e.key.toLowerCase(); if (k === 'f') { e.preventDefault(); $('#btnFsZoom')?.click(); } else if (k === 's') { e.preventDefault(); toggleSidePanel(); } else if (k === 'd') { e.preventDefault(); togglePip(); } else if (e.key === '+' || e.key === '=' || e.key === '-' || e.key === '_') { e.preventDefault(); const isPlus = e.key === '+' || e.key === '='; if (e.shiftKey) { // Shift + +/- : ์žฌ์ƒ์†๋„ ์กฐ์ • adjustPlaybackRate(isPlus ? 0.25 : -0.25); } else { // +/- : ํ’€์Šคํฌ๋ฆฐ์ผ ๋•Œ๋งŒ ์˜์ƒ ํ™•๋Œ€/์ถ•์†Œ const vz = window._videoZoom; if (vz?.isFullscreen()) { vz.setZoom(vz.getZoom() + (isPlus ? 0.25 : -0.25)); } } } else if (e.key === ' ' || k === 'k') { // ์ŠคํŽ˜์ด์Šค / K : ์žฌ์ƒยท์ •์ง€ e.preventDefault(); const v = $('#player'); if (v && v.src) { if (v.paused) v.play().catch(() => {}); else v.pause(); } } else if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') { // โ†/โ†’ : ์žฌ์ƒ ์œ„์น˜ ์ด๋™ (๊ธฐ๋ณธ 5์ดˆ, Shift+ 10์ดˆ) const v = $('#player'); if (!v || !v.src || !isFinite(v.duration)) return; e.preventDefault(); const step = e.shiftKey ? 10 : 5; const dir = e.key === 'ArrowLeft' ? -1 : 1; v.currentTime = Math.max(0, Math.min(v.duration, v.currentTime + dir * step)); } else if (e.key === '[' || e.key === ']' || e.key === ';' || e.key === "'") { // ๋‹จ์ถ•ํ‚ค: [ ์˜คํ”„๋‹ ์‹œ์ž‘(๊ณ ๊ธ‰, 0์ดˆ ๊ธฐ๋ณธ) / ] ์˜คํ”„๋‹ ๋(์‹œ์ž‘=0์ดˆ ์ž๋™) / ; ์—”๋”ฉ(ํ˜„์žฌ ์œ„์น˜) / ' ์ดˆ๊ธฐํ™” const map = { '[': 'opStart', ']': 'opEnd', ';': 'edFromEnd', "'": 'clear' }; e.preventDefault(); applySkipMark(map[e.key]); } else if (k === 'm') { // ์Œ์†Œ๊ฑฐ ํ† ๊ธ€ e.preventDefault(); const v = $('#player'); if (v) { v.muted = !v.muted; if (typeof showMediaToast === 'function') showMediaToast(v.muted ? '์Œ์†Œ๊ฑฐ' : '๐Ÿ”Š'); } } else if (k === 'n') { // ๋‹ค์Œ ํ™” (๋” ์ตœ์‹  ํšŒ์ฐจ) e.preventDefault(); gotoEpisode(1); } else if (k === 'p') { // ์ด์ „ ํ™” (๋” ์˜ค๋ž˜๋œ ํšŒ์ฐจ) e.preventDefault(); gotoEpisode(-1); } }); })(); function adjustPlaybackRate(delta) { const v = $('#player'); if (!v) return; const next = Math.max(0.25, Math.min(3, Math.round((v.playbackRate + delta) * 100) / 100)); v.playbackRate = next; showRateToast(next); } function showRateToast(rate) { showToast(`${rate}x`); } function showToast(text) { let toast = $('#rateToast'); if (!toast) { toast = document.createElement('div'); toast.id = 'rateToast'; toast.className = 'rate-toast'; document.getElementById('videoWrap').appendChild(toast); } toast.textContent = text; toast.classList.add('show'); clearTimeout(showToast._t); showToast._t = setTimeout(() => toast.classList.remove('show'), 1500); } async function togglePip() { const v = $('#player'); if (!v || !v.src) return; try { if (document.pictureInPictureElement) { await document.exitPictureInPicture(); } else if (document.pictureInPictureEnabled && !v.disablePictureInPicture) { await v.requestPictureInPicture(); } } catch (e) { console.warn('PiP failed', e); } } // โ‹ฎ ๋”๋ณด๊ธฐ ๋ฉ”๋‰ด โ€” ์žฌ์ƒ์†๋„/PIP/๋‹ค์šด๋กœ๋“œ ํ†ตํ•ฉ (function setupMoreMenu() { const btn = document.getElementById('zcMore'); const menu = document.getElementById('moreMenu'); const v = document.getElementById('player'); if (!btn || !menu || !v) return; function updateActive() { const rate = v.playbackRate || 1; for (const b of menu.querySelectorAll('.more-rates button')) { b.classList.toggle('active', Math.abs(parseFloat(b.dataset.rate) - rate) < 0.001); } const dl = document.getElementById('mmDownload'); if (dl) dl.hidden = !window._currentDownload; } function openMenu() { updateActive(); if (typeof updateSkipMenuLabels === 'function') updateSkipMenuLabels(); menu.hidden = false; } function closeMenu() { menu.hidden = true; } btn.addEventListener('click', (e) => { e.stopPropagation(); if (menu.hidden) openMenu(); else closeMenu(); }); // ๋ฐ”๊นฅ ํด๋ฆญ / Esc๋กœ ๋‹ซ๊ธฐ document.addEventListener('click', (e) => { if (!menu.hidden && !e.target.closest('#moreMenu, #zcMore')) closeMenu(); }); document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menu.hidden) closeMenu(); }); // ์žฌ์ƒ์†๋„ ๋ฒ„ํŠผ menu.querySelectorAll('.more-rates button').forEach(b => { b.addEventListener('click', () => { const rate = parseFloat(b.dataset.rate); if (isFinite(rate) && rate > 0) { try { v.playbackRate = rate; // ์‹œ๋ฆฌ์ฆˆ๋ณ„ ๊ธฐ์–ต โ€” ๊ธฐ์กด lastPlaybackRate ํ•„๋“œ ํ™œ์šฉ const fav = currentFavId ? favs.find(f => f.id === currentFavId) : null; if (fav) { fav.lastPlaybackRate = rate; saveFavs(); } updateActive(); if (typeof showMediaToast === 'function') showMediaToast(`์žฌ์ƒ ์†๋„ ${rate}ร—`); } catch {} } }); }); // PIP document.getElementById('mmPip')?.addEventListener('click', () => { togglePip(); closeMenu(); }); // ์Šคํ‚ต ๋งˆํ‚น (moreMenu ๋‚ด๋ถ€) menu.querySelectorAll('.more-skip button[data-skip]').forEach(b => { b.addEventListener('click', (e) => { e.stopPropagation(); if (typeof applySkipMark === 'function') applySkipMark(b.dataset.skip); closeMenu(); }); }); // ๋‹ค์šด๋กœ๋“œ document.getElementById('mmDownload')?.addEventListener('click', () => { const d = window._currentDownload; if (!d) return; const a = document.createElement('a'); a.href = d.url; a.download = d.name; a.rel = 'noopener'; document.body.appendChild(a); a.click(); a.remove(); closeMenu(); }); // playbackRate ์™ธ๋ถ€ ๋ณ€๊ฒฝ ๊ฐ์ง€(ํ‚ค๋ณด๋“œ Shift+/- ๋“ฑ)๋„ ๋ฉ”๋‰ด active ๋™๊ธฐํ™” v.addEventListener('ratechange', () => { if (!menu.hidden) updateActive(); }); })(); // โ”€โ”€โ”€ A1: ๊ฒ€์ƒ‰ ์ž๋™์™„์„ฑ (์ตœ๊ทผ ๊ฒ€์ƒ‰์–ด + ๋ณด๊ด€ํ•จ ๋ถ€๋ถ„์ผ์น˜) โ”€โ”€โ”€ function setupSearchAutocomplete(inputId, listId, searchFn) { const inp = document.getElementById(inputId); const list = document.getElementById(listId); if (!inp || !list) return; let focusedIdx = -1; function render() { const q = inp.value.trim().toLowerCase(); const recent = loadRecentSearches(); const favHits = q ? favs.filter(f => (f.title || '').toLowerCase().includes(q)).slice(0, 6) : []; const recentHits = q ? recent.filter(w => w.toLowerCase().includes(q) && w.toLowerCase() !== q).slice(0, 6) : recent.slice(0, 8); const items = []; for (const f of favHits) items.push({ type: 'fav', value: f.title, sub: '๋ณด๊ด€ํ•จ' }); for (const w of recentHits) items.push({ type: 'recent', value: w, sub: '์ตœ๊ทผ ๊ฒ€์ƒ‰' }); if (!items.length) { list.classList.remove('show'); list.innerHTML = ''; return; } list.innerHTML = ''; items.forEach((it, i) => { const div = document.createElement('div'); div.className = 'ac-item' + (i === focusedIdx ? ' focused' : ''); div.innerHTML = `<span class="ac-icon">${it.type === 'fav' ? 'โ˜…' : 'โŒ›'}</span>` + `<span class="ac-label">${esc(it.value)}</span>` + (it.type === 'recent' ? `<button class="ac-del" data-del="${esc(it.value)}" title="์‚ญ์ œ">โœ•</button>` : ''); div.addEventListener('mousedown', (e) => { if (e.target.dataset.del !== undefined) { removeRecentSearch(e.target.dataset.del); render(); return; } inp.value = it.value; list.classList.remove('show'); searchFn(it.value); }); list.appendChild(div); }); list.classList.add('show'); } inp.addEventListener('focus', render); inp.addEventListener('input', () => { focusedIdx = -1; render(); }); inp.addEventListener('keydown', (e) => { if (!list.classList.contains('show')) return; const items = list.querySelectorAll('.ac-item'); if (e.key === 'ArrowDown') { e.preventDefault(); focusedIdx = Math.min(items.length - 1, focusedIdx + 1); render(); } else if (e.key === 'ArrowUp') { e.preventDefault(); focusedIdx = Math.max(-1, focusedIdx - 1); render(); } else if (e.key === 'Enter' && focusedIdx >= 0) { e.preventDefault(); const el = items[focusedIdx]; const label = el?.querySelector('.ac-label')?.textContent; if (label) { inp.value = label; list.classList.remove('show'); searchFn(label); } } else if (e.key === 'Escape') { list.classList.remove('show'); } }); // ์™ธ๋ถ€ ํด๋ฆญ ์‹œ ๋‹ซ๊ธฐ document.addEventListener('mousedown', (e) => { if (!list.contains(e.target) && e.target !== inp) list.classList.remove('show'); }); } // โ”€โ”€โ”€ D2: ์ •๋ ฌ ์…€๋ ‰ํŠธ ๋ฐ”์ธ๋”ฉ โ”€โ”€โ”€ function setupSortSelects() { const cur = localStorage.getItem(LS_SORT()) || 'default'; for (const id of ['sortSelDt', 'sortSelMob']) { const el = document.getElementById(id); if (!el) continue; el.value = cur; el.addEventListener('change', () => { localStorage.setItem(LS_SORT(), el.value); // ๋‹ค๋ฅธ select๋„ ๋™๊ธฐํ™” for (const otherId of ['sortSelDt', 'sortSelMob']) { if (otherId !== id) { const o = document.getElementById(otherId); if (o) o.value = el.value; } } renderFavs(); }); } } // โ”€โ”€โ”€ D14: ์‹œ์ฒญ ํ†ต๊ณ„ โ”€โ”€โ”€ function setupStats() { function fmtH(sec) { if (!sec || sec < 60) return Math.round(sec || 0) + '์ดˆ'; const m = Math.floor(sec / 60); if (m < 60) return m + '๋ถ„'; const h = Math.floor(m / 60); return h + '์‹œ๊ฐ„ ' + (m % 60) + '๋ถ„'; } function buildStats() { // progress.time ํ•ฉ๊ณ„ (์‹œ๋ฆฌ์ฆˆ๋ณ„), finished ํšŒ์ฐจ ์ˆ˜, ์ตœ๊ทผ 1์ฃผ/1๋‹ฌ ์ถ”์ • // ์ตœ๊ทผ 1์ฃผ: clickedAt ๊ธฐ์ค€ const now = Date.now(); const W = 7 * 86400000, M = 30 * 86400000; let totalSec = 0, finishedEps = 0, weekSec = 0, monthSec = 0; const top = []; for (const f of favs) { let favSec = 0, favFin = 0; const prog = f.progress || {}; for (const lab of Object.keys(prog)) { const p = prog[lab]; if (p?.finished && p?.duration) favSec += p.duration; else if (p?.time) favSec += p.time; if (p?.finished) favFin++; } totalSec += favSec; finishedEps += favFin; if (f.clickedAt) { if (now - f.clickedAt < W) weekSec += favSec; if (now - f.clickedAt < M) monthSec += favSec; } if (favSec > 0) top.push({ title: f.title, sec: favSec, fin: favFin }); } top.sort((a, b) => b.sec - a.sec); return { totalSec, finishedEps, weekSec, monthSec, top: top.slice(0, 5) }; } function open() { const s = buildStats(); const body = document.getElementById('statsBody'); if (!body) return; body.innerHTML = ` <div class="stat-row"><span>์ด ์‹œ์ฒญ ์ถ”์ •</span><b>${fmtH(s.totalSec)}</b></div> <div class="stat-row"><span>์ด๋ฒˆ ์ฃผ ์ถ”์ •</span><b>${fmtH(s.weekSec)}</b></div> <div class="stat-row"><span>์ด๋ฒˆ ๋‹ฌ ์ถ”์ •</span><b>${fmtH(s.monthSec)}</b></div> <div class="stat-row"><span>๋‹ค ๋ณธ ํšŒ์ฐจ ์ˆ˜</span><b>${s.finishedEps}</b></div> <div style="margin-top:14px;font-size:11px;color:var(--muted)">๋งŽ์ด ๋ณธ ์‹œ๋ฆฌ์ฆˆ Top 5</div> ${s.top.map(t => `<div class="stat-row"><span>${esc(t.title || '')}</span><b>${fmtH(t.sec)} ยท ${t.fin}ํ™” ์™„๋ฃŒ</b></div>`).join('') || '<div class="stat-row" style="color:var(--muted)">๋ฐ์ดํ„ฐ ์—†์Œ</div>'} <div style="margin-top:10px;font-size:10px;color:var(--muted)">* ์‹œ์ฒญ ์‹œ๊ฐ„์€ ์ง„ํ–‰๋ฅ (time) ๋˜๋Š” finishedร—duration ํ•ฉ์œผ๋กœ ์ถ”์ •ํ•œ ๊ฐ’์ž…๋‹ˆ๋‹ค.</div> `; document.getElementById('statsModal').classList.add('show'); } for (const id of ['btnStatsDt', 'btnStatsMob']) { document.getElementById(id)?.addEventListener('click', open); } document.getElementById('statsClose')?.addEventListener('click', () => { document.getElementById('statsModal').classList.remove('show'); }); document.getElementById('statsModal')?.addEventListener('click', (e) => { if (e.target.id === 'statsModal') document.getElementById('statsModal').classList.remove('show'); }); } // โ”€โ”€โ”€ B11: ๋ถ€ํŒ… ์‹œ ์ด์–ด๋ณด๊ธฐ ๋น… ๋ฐฐ๋„ˆ โ”€โ”€โ”€ function showResumeHero() { // ๊ฐ€์žฅ ์ตœ๊ทผ ํด๋ฆญํ•œ fav ์ค‘ ์ด์–ด๋ณด๊ธฐ ๊ฐ€๋Šฅํ•œ ๊ฒƒ const candidates = favs .filter(f => f.progress && f.lastLabel && f.progress[f.lastLabel]?.time > 5 && !f.progress[f.lastLabel]?.finished) .sort((a, b) => (b.clickedAt || 0) - (a.clickedAt || 0)); if (!candidates.length) return; const f = candidates[0]; const dismissKey = `${f.id}@${f.lastLabel}@${Math.floor((f.progress[f.lastLabel].time || 0))}`; if (localStorage.getItem(LS_RESUME_HERO_DISMISS()) === dismissKey) return; const hero = document.getElementById('resumeHero'); const title = document.getElementById('rhTitle'); const meta = document.getElementById('rhMeta'); if (!hero) return; const t = f.progress[f.lastLabel].time; const mm = String(Math.floor(t / 60)).padStart(2, '0'); const ss = String(Math.floor(t % 60)).padStart(2, '0'); title.textContent = `${f.title || '(์ œ๋ชฉ)'} ยท ${f.lastLabel}`; meta.textContent = `${mm}:${ss} ๋ถ€ํ„ฐ ์ด์–ด๋ณด๊ธฐ`; hero.style.display = 'flex'; hero.onclick = (e) => { if (e.target.id === 'rhClose') return; hero.style.display = 'none'; selectFav(f.id, { source: f.source || 'tvchak', sid: f.lastSid, nid: f.lastNid }); }; document.getElementById('rhClose').onclick = (e) => { e.stopPropagation(); localStorage.setItem(LS_RESUME_HERO_DISMISS(), dismissKey); hero.style.display = 'none'; }; } // โ”€โ”€โ”€ B6: ๋ชจ๋ฐ”์ผ ์Šค์™€์ดํ”„ (์ขŒ/์šฐ = ์ด์ „/๋‹ค์Œ ํ™”) โ”€โ”€โ”€ function setupSwipe() { const wrap = document.getElementById('videoWrap'); if (!wrap) return; let sx = 0, sy = 0, st = 0; wrap.addEventListener('touchstart', (e) => { if (wrap.classList.contains('locked')) return; // ๋‘ ์†๊ฐ€๋ฝ(ํ•€์น˜) ๋‹ฟ์œผ๋ฉด ์Šค์™€์ดํ”„ ํ›„๋ณด ํ๊ธฐ. ์•ˆ ๊ทธ๋Ÿฌ๋ฉด ํ•€์น˜ ํ›„ ์† ๋–ผ๋Š” ์ขŒํ‘œ ์ฐจ์ด๋กœ ๋‹ค์Œํ™” ์˜ค์ธ. if (e.touches.length >= 2) { sx = 0; return; } if (e.touches.length !== 1) return; sx = e.touches[0].clientX; sy = e.touches[0].clientY; st = Date.now(); }, { passive: true }); wrap.addEventListener('touchmove', (e) => { // ์ค‘๊ฐ„์— ๋‘ ์†๊ฐ€๋ฝ์œผ๋กœ ๋Š˜์–ด๋‚˜๋ฉด๋„ ํ๊ธฐ if (e.touches.length >= 2) sx = 0; }, { passive: true }); wrap.addEventListener('touchend', (e) => { if (wrap.classList.contains('locked')) return; if (!sx) return; // touchend ์‹œ์ ์— ์—ฌ์ „ํžˆ ์†๊ฐ€๋ฝ 1๊ฐœ ์ด์ƒ ๋‚จ์•„์žˆ์œผ๋ฉด(๋ฉ€ํ‹ฐํ„ฐ์น˜ ์ผ๋ถ€๋งŒ ๋—Œ) ์Šค์™€์ดํ”„ X if (e.touches.length > 0) { sx = 0; return; } const t = e.changedTouches[0]; const dx = t.clientX - sx, dy = t.clientY - sy, dt = Date.now() - st; sx = 0; if (dt > 500) return; // ๋„ˆ๋ฌด ๋А๋ฆฐ ๋™์ž‘์€ ๋ฌด์‹œ if (Math.abs(dx) < 60 || Math.abs(dx) < Math.abs(dy) * 1.5) return; // ์ขŒ์ธก ์Šค์™€์ดํ”„ โ†’ ๋‹ค์Œ ํ™” (์‚ฌ์šฉ์ž ์ง๊ด€: ์ขŒโ†’์šฐ ๋„˜๊ธฐ๊ธฐ) if (dx < 0) gotoEpisode(1); else gotoEpisode(-1); }, { passive: true }); } // โ”€โ”€โ”€ C7: ์‹œ๋ฆฌ์ฆˆ๋ณ„ ์žฌ์ƒ์†๋„ ๊ธฐ์–ต โ”€โ”€โ”€ function setupRateMemory() { const v = document.getElementById('player'); if (!v) return; v.addEventListener('ratechange', () => { if (!currentFavId) return; const fav = favs.find(f => f.id === currentFavId); if (!fav) return; if (fav.lastPlaybackRate !== v.playbackRate) { fav.lastPlaybackRate = v.playbackRate; saveFavs(); } }); // ์ƒˆ ์˜์ƒ loadedmetadata ์‹œ ์‹œ๋ฆฌ์ฆˆ ๊ธฐ์–ต ์†๋„ ์ ์šฉ v.addEventListener('loadedmetadata', () => { const fav = favs.find(f => f.id === currentFavId); if (fav && typeof fav.lastPlaybackRate === 'number' && fav.lastPlaybackRate > 0) { try { v.playbackRate = fav.lastPlaybackRate; } catch {} } }); } // โ”€โ”€โ”€ C8: ์žฌ์ƒ ์‹คํŒจ ์ž๋™ ์žฌ์‹œ๋„ + ํ† ์ŠคํŠธ โ”€โ”€โ”€ function showMediaToast(msg, ms = 1500) { const el = document.getElementById('mediaToast'); if (!el) return; el.textContent = msg; el.classList.add('show'); clearTimeout(el._t); el._t = setTimeout(() => el.classList.remove('show'), ms); } function setupVideoErrorRetry() { const v = document.getElementById('player'); if (!v) return; let retried = false; let reloadedForStall = false; // ๋ณต๊ตฌ ๊ธฐ์ค€ ์Šค๋ƒ…์ƒท: refreshAll/syncFavsFromOtherDevices๊ฐ€ currentEpList/currentEpIdx๋ฅผ // ๊ฐˆ์•„๋ผ์šฐ๋Š” ์‚ฌ์ด stall ๋ณต๊ตฌ๊ฐ€ ํŠธ๋ฆฌ๊ฑฐ๋˜๋ฉด currentEpList[currentEpIdx]๊ฐ€ ๋‹ค๋ฅธ ํšŒ์ฐจ๋กœ ๋ฐ”๋€Œ๋Š” // ์‚ฌ๊ณ (2026-06-08)๊ฐ€ ์žˆ์—ˆ์Œ. loadstart ์‹œ์ ์˜ sid/nid/favId๋ฅผ ๋ฐ•์•„ ๋‘๊ณ  ๊ทธ ๊ฐ’์œผ๋กœ๋งŒ ๋ณต๊ตฌ. let snap = { favId: null, favSource: null, sid: null, nid: null }; v.addEventListener('loadstart', () => { retried = false; reloadedForStall = false; if (currentFavId && currentEpIdx >= 0 && currentEpList[currentEpIdx]) { const ep = currentEpList[currentEpIdx]; snap = { favId: currentFavId, favSource: currentFavSource || null, sid: ep.sid, nid: ep.nid }; } }); v.addEventListener('error', () => { if (retried) { showMediaToast('์žฌ์ƒ ์‹คํŒจ. ์ž ์‹œ ํ›„ ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.', 3000); return; } if (!snap.favId || snap.sid == null) return; retried = true; showMediaToast('์ž๋™ ์žฌ์‹œ๋„ ์ค‘โ€ฆ', 2500); setTimeout(() => { playEpisode(snap.favId, snap.sid, snap.nid, { userInitiated: false }).catch(() => {}); }, 3000); }); // stalled ์ž๋™ ์žฌ๊ฐœ: // <video>๊ฐ€ ์žฌ์ƒ ์ค‘ ๋„คํŠธ์›Œํฌ ๋Š๊น€ยท์„œ๋ฒ„ RST(HF push ์‹œ ๋“ฑ)๋กœ ๋ฉˆ์ถ”๋ฉด error ์ด๋ฒคํŠธ ์—†์ด stalled/waiting๋งŒ ๋ฐœ์ƒ. // currentTime์ด 8์ดˆ ๋™์•ˆ ์ง„ํ–‰ ์•ˆ ๋˜๋ฉด ์ž๋™ ๋ณต๊ตฌ: โ‘  ์งง์€ seek๋กœ buffer ๋‹ค์‹œ ์ฑ„์›€ โ†’ โ‘ก ์•ˆ ๋˜๋ฉด ์ƒˆ stream URL๋กœ reload. let lastTime = 0; let lastTimeAt = Date.now(); let stallCheckInterval = null; // ์ผ์‹œ์ •์ง€ ์‹œ๊ฐ ๊ธฐ๋ก โ€” ์˜ค๋ž˜ ๋ฉˆ์ท„๋‹ค ์žฌ์ƒํ•˜๋ฉด mp4 progressive ์ปค๋„ฅ์…˜์ด ์ฃฝ์–ด // ์žฌ๊ฐœ ์‹œ buffer ์žฌ์ถฉ์ „์— ์‹คํŒจ(waitingโ†’stalled ๋ฌดํ•œ)ํ•˜๋Š” ์‚ฌ๊ณ  ๋ฐฉ์ง€์šฉ. // (2026-07-17 ์ง„๋‹จ: 31๋ถ„ ์ผ์‹œ์ •์ง€ ํ›„ ์žฌ์ƒ โ†’ waiting/stalled โ†’ seek๋ณต๊ตฌ ์‹คํŒจ โ†’ ์žฌ๋กœ๋“œ. // seek ๋ณต๊ตฌ๋Š” mp4์—์„  ์ด๋ฏธ ๋ฒ„ํผ์— ์žˆ๋Š” ๊ตฌ๊ฐ„ ๋˜๊ฐ๊ธฐ๋ผ ๋ฌด์˜๋ฏธ. ์˜ค๋ž˜ ๋ฉˆ์ท„์œผ๋ฉด ์„ ์ œ ์žฌ๋กœ๋“œ๊ฐ€ ์ •๋‹ต.) let pausedAt = 0; const LONG_PAUSE_MS = 60000; // ์ด ์ด์ƒ ๋ฉˆ์ท„๋‹ค ์žฌ์ƒํ•˜๋ฉด ์„ ์ œ ์žฌ๋กœ๋“œ // ๊ฐ™์€ ํšŒ์ฐจ๋ฅผ ์ƒˆ stream URL๋กœ ์žฌ๋กœ๋“œ ํ›„ resumeTime ์œ„์น˜์—์„œ ์ด์–ด๋ณด๊ธฐ. // stall 2์ฐจ ๋ณต๊ตฌ์™€ "์˜ค๋ž˜ ์ผ์‹œ์ •์ง€ ํ›„ ์„ ์ œ ์žฌ๋กœ๋“œ" ๋‘˜ ๋‹ค ์ด ํ•จ์ˆ˜๋ฅผ ์”€. function reconnectStream(resumeTime, toastMsg) { if (!snap.favId || snap.sid == null) return; reloadedForStall = true; // ์žฌ๋กœ๋“œ ์ง์ „ zoom ์ƒํƒœ ๋ณด์กด โ€” ๋ชจ๋ฐ”์ผ ์ผ๋ถ€ ๋ธŒ๋ผ์šฐ์ €๋Š” src ๊ต์ฒด ์‹œ fullscreen auto-exitํ•˜๋ฉฐ zoom์ด ๋ฆฌ์…‹๋จ const savedZoom = window._videoZoom?.getZoom?.() ?? 1; const wasFullscreen = window._videoZoom?.isFullscreen?.() ?? false; showMediaToast(toastMsg || '์ŠคํŠธ๋ฆผ ์žฌ์—ฐ๊ฒฐ ์ค‘โ€ฆ', 2500); playEpisode(snap.favId, snap.sid, snap.nid, { userInitiated: false }).then(() => { // ๋Š๊ธด ์œ„์น˜์—์„œ ์žฌ๊ฐœ const onCanPlay = () => { try { if (resumeTime > 0) v.currentTime = resumeTime; v.play().catch(() => {}); } catch {} v.removeEventListener('canplay', onCanPlay); // zoom ๋ณต์› โ€” fullscreen์ด ์ž๋™ ์ข…๋ฃŒ๋๋‹ค๋ฉด ๋‹ค์‹œ ์ง„์ž…ํ•œ ๋’ค์— ์ ์šฉ if (savedZoom > 1) { const restoreZoom = () => { try { window._videoZoom?.setZoom?.(savedZoom); } catch {} }; if (wasFullscreen && !window._videoZoom?.isFullscreen?.()) { // ์ž๋™ ํ’€์Šคํฌ๋ฆฐ ์žฌ์ง„์ž… ์‹œ๋„. ์‹คํŒจํ•ด๋„ ๋‹ค์Œ ์‚ฌ์šฉ์ž ์ง„์ž… ์‹œ restoreSavedZoom์ด fav ์ €์žฅ๊ฐ’์œผ๋กœ ๋ณต์›. const wrap = document.getElementById('videoWrap'); (wrap?.requestFullscreen?.call(wrap) || wrap?.webkitRequestFullscreen?.call(wrap) || Promise.resolve()) .then(restoreZoom).catch(restoreZoom); } else if (window._videoZoom?.isFullscreen?.()) { restoreZoom(); } } }; v.addEventListener('canplay', onCanPlay); }).catch(() => {}); } v.addEventListener('playing', () => { reloadedForStall = false; if (stallCheckInterval) clearInterval(stallCheckInterval); // โ”€โ”€ ์˜ค๋ž˜ ์ผ์‹œ์ •์ง€ ํ›„ ์žฌ๊ฐœ = mp4 progressive ์ปค๋„ฅ์…˜์ด ์ฃฝ์–ด buffer ์žฌ์ถฉ์ „ ์‹คํŒจํ•˜๋Š” ์ผ€์ด์Šค. // stall(8์ดˆ+seek์‹คํŒจ+5์ดˆ) ์„ ๊ธฐ๋‹ค๋ฆฌ๋ฉฐ "๋‹ค์‹œ ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค"๊ฐ€ ๋ฐ˜๋ณต๋˜๊ธฐ ์ „์—, ์žฌ๊ฐœ ์ฆ‰์‹œ ์„ ์ œ ์žฌ๋กœ๋“œ. // (2026-07-17 ๋กœ๊ทธ๋กœ ํ™•์ธ: 31๋ถ„ ์ผ์‹œ์ •์ง€ ํ›„ ์žฌ์ƒ โ†’ waiting/stalled โ†’ seek ๋ฌด์˜๋ฏธ โ†’ ๊ฒฐ๊ตญ ์žฌ๋กœ๋“œ๋กœ๋งŒ ๋ณต๊ตฌ๋จ.) if (pausedAt && Date.now() - pausedAt > LONG_PAUSE_MS && !reloadedForStall) { const resumeTime = v.currentTime; pausedAt = 0; reconnectStream(resumeTime, '์˜ค๋ž˜ ๋ฉˆ์ถฐ ์žˆ์–ด ๋‹ค์‹œ ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹คโ€ฆ'); return; // ์žฌ๋กœ๋“œ๊ฐ€ ์ƒˆ playing์„ ๋‹ค์‹œ ๋ฐœ์ƒ์‹œํ‚ค๋ฏ€๋กœ ์ด๋ฒˆ interval์€ ์•ˆ ๊ฑธ์–ด๋„ ๋จ } pausedAt = 0; // ์žฌ์ƒ(์žฌ)๊ฐœ ์‹œ์  ๊ธฐ์ค€์œผ๋กœ stall ๊ธฐ์ค€๊ฐ’ ๋ฆฌ์…‹. // Why: ์ผ์‹œ์ •์ง€๋กœ interval์ด ๋ฉˆ์ถ˜ ๋™์•ˆ lastTimeAt์ด ์˜› ์‹œ๊ฐ์— ๊ณ ์ •๋ผ ์žˆ๋Š”๋ฐ, // ์ด๊ฑธ ๋ฆฌ์…‹ ์•ˆ ํ•˜๋ฉด ์žฌ์ƒ ์žฌ๊ฐœ ์งํ›„ ์ฒซ ์ฒดํฌ์—์„œ stalledMs = (์ง€๊ธˆ - ๋ฉˆ์ถ”๊ธฐ์ „)์ด // ๊ทธ๋Œ€๋กœ 8์ดˆ๋ฅผ ๋„˜๊ฒจ ์ฆ‰์‹œ "์ŠคํŠธ๋ฆผ ์žฌ์—ฐ๊ฒฐ"์ด ์˜ค๋ฐœ๋™ํ•œ๋‹ค (์ผ์‹œ์ •์ง€ํ•  ๋•Œ๋งˆ๋‹ค ๋Š๊น€์˜ ์›์ธ). lastTime = v.currentTime; lastTimeAt = Date.now(); stallCheckInterval = setInterval(() => { if (v.paused || v.ended || v.seeking) { lastTime = v.currentTime; lastTimeAt = Date.now(); return; } // ์ง„ํ–‰ ์ค‘์ธ๋ฐ currentTime์ด ์•ˆ ์›€์ง์ž„ โ†’ stall if (Math.abs(v.currentTime - lastTime) > 0.05) { lastTime = v.currentTime; lastTimeAt = Date.now(); return; } const stalledMs = Date.now() - lastTimeAt; if (stalledMs < 8000) return; // 8์ดˆ ๊ทธ๋ ˆ์ด์Šค if (reloadedForStall) return; // ์ด๋ฏธ ์‹œ๋„ํ•จ // 1์ฐจ ๋ณต๊ตฌ: ์งง์€ seek (buffer reset). mp4 direct์—๋„ ํšจ๊ณผ ์žˆ์Œ try { const t = v.currentTime; v.currentTime = Math.max(0, t - 0.5); v.play().catch(() => {}); showMediaToast('๋„คํŠธ์›Œํฌ ๋Š๊น€ ๊ฐ์ง€, ์žฌ๊ฐœ ์‹œ๋„โ€ฆ', 2000); lastTimeAt = Date.now() + 4000; // 4์ดˆ ์ถ”๊ฐ€ ๊ทธ๋ ˆ์ด์Šค } catch {} // 2์ฐจ ๋ณต๊ตฌ: seek ํ›„ 4์ดˆ ๋” ๊ธฐ๋‹ค๋ ค๋„ ์•ˆ ํ’€๋ฆฌ๋ฉด ๊ฐ™์€ ํšŒ์ฐจ reload (์ƒˆ stream URL ๋ฐœ๊ธ‰) setTimeout(() => { if (!v.paused && Math.abs(v.currentTime - lastTime) < 0.05 && !reloadedForStall) { // currentEpIdx ๋Œ€์‹  loadstart ์‹œ์ ์— ๋ฐ•์•„ ๋‘” snap.sid/nid๋กœ ๋ณต๊ตฌ (๋‹ค๋ฅธ ํ™” ์‚ฌ๊ณ  ๋ฐฉ์ง€) reconnectStream(v.currentTime); } }, 5000); }, 2000); }); v.addEventListener('pause', () => { if (stallCheckInterval) { clearInterval(stallCheckInterval); stallCheckInterval = null; } // ended๊ฐ€ ์•„๋‹Œ ์‹ค์ œ ์ผ์‹œ์ •์ง€์ผ ๋•Œ๋งŒ ์‹œ๊ฐ ๊ธฐ๋ก (์žฌ์ƒ ๋๋‚˜์„œ pause๋œ ๊ฑด ์ œ์™ธ) if (!v.ended) pausedAt = Date.now(); }); v.addEventListener('ended', () => { if (stallCheckInterval) { clearInterval(stallCheckInterval); stallCheckInterval = null; } pausedAt = 0; }); } // โ”€โ”€โ”€ D12: ์Œ๋Ÿ‰/์žฌ์ƒ์†๋„ ์ธ๋””์ผ€์ดํ„ฐ โ”€โ”€โ”€ function setupMediaIndicators() { const v = document.getElementById('player'); if (!v) return; let lastVol = v.volume; v.addEventListener('volumechange', () => { if (Math.abs(v.volume - lastVol) > 0.001 || v.muted !== undefined) { lastVol = v.volume; showMediaToast(v.muted ? '๐Ÿ”‡ ์Œ์†Œ๊ฑฐ' : `๐Ÿ”Š ${Math.round(v.volume * 100)}%`); } }); v.addEventListener('ratechange', () => { showMediaToast(`โ–ถ ${v.playbackRate.toFixed(2).replace(/0$/, '')}ร—`); }); } // โ”€โ”€โ”€ C5: ์นด์šดํŠธ๋‹ค์šด ๋ฒ„ํŠผ + G-6: ํ‚ค๋ณด๋“œ ๋‹จ์ถ•ํ‚ค โ”€โ”€โ”€ let _ncPaused = false; function setupNextCountdownButtons() { // ๋ชจ๋ฐ”์ผ์—์„œ wrap capture ๋‹จ๊ณ„ ํ•ธ๋“ค๋Ÿฌ๋‚˜ click ํ•ฉ์„ฑ ์ง€์—ฐ์œผ๋กœ ์ทจ์†Œ/์ง€๊ธˆ์‹œ์ฒญ์ด ์•ˆ ๋จน๋Š” ์‚ฌ๊ณ ๊ฐ€ // ๋ฐ˜๋ณต๋ผ์„œ, pointerup์œผ๋กœ ์ง์ ‘ ๋ฐ›๊ณ  wrap ์ชฝ ํ•ธ๋“ค๋Ÿฌ๋กœ ์ƒˆ์–ด๋‚˜๊ฐ€์ง€ ์•Š๊ฒŒ stopPropagation๊นŒ์ง€ ๋ฐ•๋Š”๋‹ค. // click๋„ ์‚ด๋ ค๋‘์–ด ๋ฐ์Šคํฌํƒ‘ยทํ‚ค๋ณด๋“œ(Enter ํ•ฉ์„ฑ) ํ˜ธํ™˜. const ncBox = document.getElementById('nextCountdown'); const doCancel = (e) => { e?.stopPropagation?.(); e?.preventDefault?.(); cancelNextCountdown(); }; const doGo = (e) => { e?.stopPropagation?.(); e?.preventDefault?.(); const titleEl = document.getElementById('ncTitle'); if (!titleEl) return; const label = titleEl.textContent; cancelNextCountdown(); const sortedAsc = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid); const next = sortedAsc.find(e => (e.label || `${e.nid}ํ™”`) === label); if (next) { playEpisode(currentFavId, next.sid, next.nid, { userInitiated: true }).then(() => { $('#player').play().catch(() => {}); }); } }; // pointerup์ด click๋ณด๋‹ค ๋จผ์ € ๋ฐœํ™” + ๋ชจ๋“  ์ž…๋ ฅํƒ€์ž…(ํ„ฐ์น˜/๋งˆ์šฐ์Šค/ํŽœ) ํ†ตํ•ฉ. // ๊ฐ™์€ ํƒญ์—์„œ click์ด ๋˜ ๋ฐœํ™”ํ•ด๋„ ์นด์šดํŠธ๋‹ค์šด์ด ์ด๋ฏธ ๋‹ซํ˜€์„œ ๋‘ ๋ฒˆ์งธ ํ˜ธ์ถœ์€ no-op. const ncCancelBtn = document.getElementById('ncCancel'); const ncGoBtn = document.getElementById('ncGo'); ncCancelBtn?.addEventListener('pointerup', doCancel); ncCancelBtn?.addEventListener('click', doCancel); ncGoBtn?.addEventListener('pointerup', doGo); ncGoBtn?.addEventListener('click', doGo); // ๋ฐ•์Šค ์ „์ฒด์˜ touch/pointer ์ด๋ฒคํŠธ๊ฐ€ wrap์˜ ๋”๋ธ”ํƒญยทhold ํ•ธ๋“ค๋Ÿฌ๋กœ ์ƒˆ์–ด๋‚˜๊ฐ€์ง€ ์•Š๊ฒŒ ์ฐจ๋‹จ. // closest ๊ฐ€๋“œ(2518/2565ํ–‰)์— ๋”ํ•ด ์ด์ค‘ ์•ˆ์ „๋ง โ€” capture ๋‹จ๊ณ„์—์„œ wrap์ด ์ด๋ฏธ ๋ณด๊ณ  ๋„˜์–ด๊ฐ€๋„ // ์ดํ›„ ๋‹จ๊ณ„์—์„œ ๋‹ค๋ฅธ ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ๋”๋ธ”ํƒญ์œผ๋กœ ์˜ค์ธํ•˜์ง€ ์•Š๋„๋ก. if (ncBox) { for (const t of ['touchstart','touchend','pointerdown','pointerup','click']) { ncBox.addEventListener(t, (e) => e.stopPropagation(), true); } } // G-6: Enter=์ง€๊ธˆ์‹œ์ฒญ, Esc=์ทจ์†Œ, Space=์ผ์‹œ์ •์ง€ (์นด์šดํŠธ๋‹ค์šด ํ‘œ์‹œ ์ค‘์ผ ๋•Œ๋งŒ) document.addEventListener('keydown', (e) => { const el = document.getElementById('nextCountdown'); if (!el || !el.classList.contains('show')) return; // ์ž…๋ ฅ์ฐฝ ํฌ์ปค์Šค๋˜์–ด ์žˆ์œผ๋ฉด ๋ฌด์‹œ const t = e.target; if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return; if (e.key === 'Enter') { e.preventDefault(); document.getElementById('ncGo')?.click(); } else if (e.key === 'Escape') { e.preventDefault(); cancelNextCountdown(); } else if (e.key === ' ') { e.preventDefault(); _ncPaused = !_ncPaused; const label = document.querySelector('#nextCountdown .nc-label'); if (label) label.style.opacity = _ncPaused ? '0.5' : '1'; } }); } // โ”€โ”€โ”€ G-10: ๋‹จ์ถ•ํ‚ค ์•ˆ๋‚ด ๋ชจ๋‹ฌ โ”€โ”€โ”€ function setupShortcutsHelp() { const open = () => document.getElementById('shortcutsModal').classList.add('show'); const close = () => document.getElementById('shortcutsModal').classList.remove('show'); document.getElementById('shortcutsClose')?.addEventListener('click', close); document.getElementById('shortcutsModal')?.addEventListener('click', (e) => { if (e.target.id === 'shortcutsModal') close(); }); document.addEventListener('keydown', (e) => { const t = e.target; if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return; if (e.key === '?' || (e.key === '/' && e.shiftKey)) { e.preventDefault(); const modal = document.getElementById('shortcutsModal'); if (modal.classList.contains('show')) close(); else open(); } }); } // F-13: โ—€/โ–ถ nav ๋ฒ„ํŠผ ์ œ๊ฑฐ๋จ โ€” ์Šค์™€์ดํ”„(B6)์™€ ํšŒ์ฐจ ์นฉ ํด๋ฆญ์œผ๋กœ ๋Œ€์ฒด function setupEpNavButtons() {} function updateEpNavButtons() {} // โ”€โ”€โ”€ F-8: ๋‹ค์Œ ํ™” ๋ฏธ๋ฆฌ๋ณด๊ธฐ (์˜์ƒ hover ์‹œ ์ž ๊น) โ”€โ”€โ”€ function setupNextPreview() { const wrap = document.getElementById('videoWrap'); const btn = document.getElementById('nextPreview'); if (!wrap || !btn) return; let hideT = null; function findNext() { if (!currentEpList.length || currentEpIdx < 0) return null; const sortedAsc = [...currentEpList].sort((a, b) => a.sid - b.sid || a.nid - b.nid); const idx = sortedAsc.findIndex(e => e.sid === currentEpList[currentEpIdx].sid && e.nid === currentEpList[currentEpIdx].nid); if (idx <= 0) return null; return sortedAsc[idx - 1]; } function show() { const next = findNext(); if (!next) { btn.classList.remove('show'); return; } btn.textContent = `๋‹ค์Œ โ–ถ ${next.label || (next.nid + 'ํ™”')}`; btn.classList.add('show'); clearTimeout(hideT); // ๋ชจ๋ฐ”์ผ์—์„œ ํ‘œ์‹œโ†’์†๊ฐ€๋ฝ ์ด๋™โ†’ํƒญ์— ์‹œ๊ฐ„์ด ํ•„์š”ํ•ด 2.5์ดˆ๋Š” ์งง์Œ. 4์ดˆ๋กœ ์—ฌ์œ . hideT = setTimeout(() => btn.classList.remove('show'), 4000); } // ๋งˆ์šฐ์Šค ์›€์ง์ž„ or ํ„ฐ์น˜ wrap.addEventListener('mousemove', show); wrap.addEventListener('touchstart', show, { passive: true }); // ๋ฒ„ํŠผ์— ์†๊ฐ€๋ฝ์ด ๋‹ฟ๋Š” ์ˆœ๊ฐ„์—” ์‚ฌ๋ผ์ง€์ง€ ์•Š๋„๋ก ํƒ€์ด๋จธ ํ•ด์ œ โ€” ์‚ฌ์šฉ์ž๊ฐ€ ๋ˆ„๋ฅด๋ ค๋Š” ์˜๋„ ๋ช…ํ™•. btn.addEventListener('touchstart', (e) => { e.stopPropagation(); clearTimeout(hideT); }, { passive: true }); btn.addEventListener('click', (e) => { e.stopPropagation(); const next = findNext(); if (next) { btn.classList.remove('show'); playEpisode(currentFavId, next.sid, next.nid, { userInitiated: true }).then(() => { $('#player').play().catch(() => {}); }); } }); } // โ”€โ”€โ”€ B15: PWA service worker ๋“ฑ๋ก + ์ž๋™ ์—…๋ฐ์ดํŠธ โ”€โ”€โ”€ function setupPWA() { if (!('serviceWorker' in navigator)) return; navigator.serviceWorker.register('/sw.js', { scope: '/' }) .then(reg => { // 1์‹œ๊ฐ„๋งˆ๋‹ค ์—…๋ฐ์ดํŠธ ์ฒดํฌ setInterval(() => reg.update().catch(() => {}), 60 * 60 * 1000); }) .catch((e) => console.warn('SW reg failed:', e)); // ์ƒˆ SW๊ฐ€ ํ™œ์„ฑํ™”๋˜๋ฉด ์ž๋™ reload (ํ•œ ๋ฒˆ๋งŒ). // ๋‹จ ์˜์ƒ ์žฌ์ƒ ์ค‘์ด๋ฉด ๋ณด๋ฅ˜ โ€” ์‚ฌ์šฉ์ž๊ฐ€ ์ผ์‹œ์ •์ง€ํ•˜๊ฑฐ๋‚˜ ๋‹ค์Œ ํƒญ ์ „ํ™˜ ์‹œ ๊ฐฑ์‹ . let _reloading = false; let _pendingReload = false; const tryReload = (reason) => { if (_reloading) return; const v = document.getElementById('player'); const playing = v && !v.paused && !v.ended && v.currentTime > 0; if (playing) { _pendingReload = true; console.log(`[sw] ${reason} โ€” defer reload (playing)`); return; } _reloading = true; console.log(`[sw] ${reason} โ€” reloading`); setTimeout(() => location.reload(), 200); }; navigator.serviceWorker.addEventListener('message', (e) => { if (e.data?.type === 'sw-updated') tryReload('new version activated'); }); // controllerchange๋„ reload (๋‹ค๋ฅธ ํƒญ์—์„œ update ํŠธ๋ฆฌ๊ฑฐ๋˜์—ˆ์„ ๋•Œ) navigator.serviceWorker.addEventListener('controllerchange', () => tryReload('controllerchange')); // ์˜์ƒ์ด ์ผ์‹œ์ •์ง€/์ข…๋ฃŒ๋  ๋•Œ ๋ณด๋ฅ˜๋œ reload ์žฌ์‹œ๋„ document.addEventListener('pause', (e) => { if (_pendingReload && e.target?.id === 'player') tryReload('pending after pause'); }, true); // ํƒญ์ด hidden์œผ๋กœ ๊ฐˆ ๋•Œ๋„ ๊ธฐํšŒ โ€” ์‚ฌ์šฉ์ž๊ฐ€ ๋‹ค๋ฅธ ์ž‘์—… ์ค‘์ด๋ผ ์•ˆ ๋ณด์ž„ document.addEventListener('visibilitychange', () => { if (_pendingReload && document.visibilityState === 'hidden') tryReload('pending on hidden'); }); } (async function boot() { // ์–ด๋А ๋‹จ๊ณ„๊ฐ€ ์‹คํŒจํ•ด๋„ UI๋Š” ๋ฌด์กฐ๊ฑด ๊ทธ๋ ค์ง€๋„๋ก try/catch ๋ณดํ˜ธ. setupSortSelects(); renderProfileTabs(); loadProfileLabels(); // E1: ๋ณ„์นญ ์ผ๊ด„ ์กฐํšŒ (๋น„๋™๊ธฐ, ๋„์ฐฉํ•˜๋ฉด ์ž๋™ ์žฌ๋ Œ๋”) renderFavs(); setupStats(); setupSwipe(); setupRateMemory(); setupVideoErrorRetry(); setupMediaIndicators(); setupNextCountdownButtons(); setupShortcutsHelp(); setupEpNavButtons(); setupNextPreview(); // ๊ฒ€์ƒ‰ ์ž๋™์™„์„ฑ: ๋ฐ์Šคํฌํƒ‘(searchInputโ†’acListDt), ๋ชจ๋ฐ”์ผ(searchInputMobโ†’acListMob) setupSearchAutocomplete('searchInput', 'acListDt', (wd) => { document.getElementById('searchInput').value = wd; pushRecentSearch(wd); doSearch(wd, 'searchResults'); }); setupSearchAutocomplete('searchInputMob', 'acListMob', (wd) => { document.getElementById('searchInputMob').value = wd; pushRecentSearch(wd); doSearch(wd, 'searchResultsMob'); }); setupPWA(); loadDomain().catch(e => console.warn('boot loadDomain:', e)); loadRanking('daily'); // ๋ถ€ํŒ… ์‹œ ๋ณด๊ด€ํ•จ NEW ์ž๋™ ๊ฐ์ง€ โ€” ์‚ฌ์šฉ์ž ํด๋ฆญ ์—†์ด๋„ latestLabel ๊ฐฑ์‹  refreshLatestLabels().catch(e => console.warn('boot latest-labels:', e)); // ๋ถ€ํŒ… ์‹œ progress ๋™๊ธฐํ™”: ์„œ๋ฒ„ pull์„ selectFav๋ณด๋‹ค ๋จผ์ € ๋๋‚ด์•ผ ํ•จ. // Why: localStorage์—” ๋‹ค๋ฅธ ๋””๋ฐ”์ด์Šค๊ฐ€ ๊ฐฑ์‹ ํ•œ ์ตœ์‹  progress๊ฐ€ ์•„์ง ์—†์„ ์ˆ˜ ์žˆ๋Š”๋ฐ, // selectFav๊ฐ€ ์˜› progress๋กœ currentTime์„ ๋ณต์›ํ•˜๋ฉด ๊ณง์žฅ timeupdate๊ฐ€ ๋ฐœํ™”ํ•ด // _pendingPut=true๋ฅผ ์ผ ๋‹ค. ๊ทธ ๋’ค๋กœ๋Š” pullFavsFromServer๊ฐ€ if(_pendingPut) return // ๊ฐ€๋“œ์— ๋ง‰ํ˜€ ์„œ๋ฒ„ ์ตœ์‹ ๊ฐ’์„ ์˜์˜ ๋ชป ๊ฐ€์ ธ์˜ค๊ณ  ์˜› ์‹œ์ ์ด ๊ตณ์–ด์ง„๋‹ค (๋‹ค๋ฅธ ๋””๋ฐ”์ด์Šค์—์„œ // "์ด์–ด๋ณด๊ธฐ๊ฐ€ ํ•œ์ฐธ ์ „ ์‹œ์ ๋ถ€ํ„ฐ ์‹œ์ž‘" ์ฆ์ƒ์˜ ์ง„์งœ ์›์ธ). // ์„œ๋ฒ„๊ฐ€ ์ฃฝ์—ˆ๊ฑฐ๋‚˜ ๋А๋ฆฌ๋ฉด 1.5์ดˆ ํƒ€์ž„์•„์›ƒ ํ›„ ๊ทธ๋ƒฅ ์ง„ํ–‰ โ€” ๋ถ€ํŒ… ๋ฉˆ์ถค ๋ฐฉ์ง€. await Promise.race([ pullFavsFromServer().catch(e => console.warn('boot pullFavs:', e)), new Promise(resolve => setTimeout(resolve, 1500)), ]); renderFavs(); const bootedLastFavId = lastFavId; try { if (bootedLastFavId && favs.find(f => f.id == bootedLastFavId)) { await selectFav(+bootedLastFavId, { silent: true }); } else { // ๋ถ€ํŒ… ์ž๋™ ์„ ํƒ ์•ˆ ํ–ˆ์„ ๋•Œ๋งŒ ์ด์–ด๋ณด๊ธฐ ๋น… ๋ฐฐ๋„ˆ ํ‘œ์‹œ showResumeHero(); } } catch (e) { console.warn('boot selectFav:', e); } })(); </script> </body> </html>
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="theme-color" content="#0f1115" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>OTT Player</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="manifest" href="/manifest.webmanifest">
<meta name="theme-color" content="#0f1115">
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
<link rel="preload" href="https://cdn.jsdelivr.net/npm/hls.js@1.5.15/dist/hls.min.js" as="script" crossorigin>
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.15/dist/hls.min.js" defer></script>
<link rel="apple-touch-icon" href="/favicon.svg" />
<style>
:root {
--bg: #0f1115;
--panel: #161a22;
--panel2: #1d222c;
--border: #2a313d;
--text: #e6e8ec;
--muted: #8a93a6;
--accent: #ff5b6a;
--accent2: #4ea1ff;
--new: #ffb020;
--safe-top: env(safe-area-inset-top, 0px);
--safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
overscroll-behavior: none; }
body { min-height: 100dvh; }
button { font-family: inherit; }
input { font-family: inherit; font-size: 16px; /* iOS ์คŒ ๋ฐฉ์ง€ */ }
/* โ”€โ”€โ”€โ”€โ”€ ๊ณตํ†ต ํผ/๋ฒ„ํŠผ โ”€โ”€โ”€โ”€โ”€ */
.btn { background: var(--panel2); border: 1px solid var(--border); color: var(--text);
border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer; }
.btn:active { background: #2a313d; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: #e34758; }
.btn.ghost { background: transparent; }
.btn.icon { padding: 8px 10px; min-width: 38px; }
input.text { background: var(--panel2); border: 1px solid var(--border); color: var(--text);
border-radius: 8px; padding: 8px 12px; outline: none; width: 100%; }
input.text:focus { border-color: var(--accent2); }
/* โ”€โ”€โ”€โ”€โ”€ ์ƒ๋‹จ ์•ฑ๋ฐ” โ”€โ”€โ”€โ”€โ”€ */
.appbar { position: sticky; top: 0; z-index: 30; background: var(--panel);
border-bottom: 1px solid var(--border);
padding: calc(8px + var(--safe-top)) 10px 8px;
display: flex; align-items: center; gap: 8px; }
.appbar h1 { margin: 0; font-size: 15px; flex: 1; min-width: 0; overflow: hidden;
text-overflow: ellipsis; white-space: nowrap; }
.appbar h1 small { color: var(--muted); font-weight: normal; font-size: 11px; margin-left: 6px; }
.appbar .domain { font-size: 10px; color: #6ee7a8; }
.appbar .domain.bad { color: #ff7b7b; }
/* โ”€โ”€โ”€โ”€โ”€ ๋น„๋””์˜ค โ”€โ”€โ”€โ”€โ”€ */
.video-wrap { position: relative; background: #000; width: 100%; aspect-ratio: 16/9; }
.video-wrap.fill { aspect-ratio: auto; height: 100%; flex: 1; }
video { width: 100%; height: 100%; background: #000; display: block; }
.video-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
color: var(--muted); font-size: 13px; padding: 16px; text-align: center; pointer-events: none; }
.video-empty.hide { display: none; }
.video-loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
color: var(--accent2); font-size: 13px; background: rgba(0,0,0,0.6); padding: 8px 12px; border-radius: 6px; }
/* ์ƒ๋‹จ ํŽ˜์ด์ง€ ๋กœ๋”ฉ ๋ฐ” โ€” ๋ณด๊ด€ํ•จ ํด๋ฆญ ํ›„ episodes/play ๋กœ๋“œ ํ…€์— ํ‘œ์‹œ */
#topLoader { position: fixed; top: 0; left: 0; right: 0; height: 3px;
background: transparent; z-index: 9999; pointer-events: none;
opacity: 0; transition: opacity 0.2s; }
#topLoader.show { opacity: 1; }
#topLoader::before { content: ''; display: block; height: 100%;
background: linear-gradient(90deg, transparent, var(--accent), var(--accent), transparent);
background-size: 50% 100%; background-repeat: no-repeat;
animation: topLoaderSlide 1s linear infinite;
box-shadow: 0 0 8px var(--accent); }
@keyframes topLoaderSlide {
0% { background-position: -50% 0; }
100% { background-position: 150% 0; }
}
.rate-toast { position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
background: rgba(0,0,0,0.75); color: #fff; padding: 8px 18px; border-radius: 999px;
font-size: 20px; font-weight: 800; font-family: "Bebas Neue", sans-serif;
letter-spacing: 0.05em; opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 6; }
.rate-toast.show { opacity: 1; }
/* ์ผ์‹œ์ •์ง€ ์˜ค๋ฒ„๋ ˆ์ด โ€” ๊ฐ€์šด๋ฐ ํฐ ์žฌ์ƒ๋ฒ„ํŠผ */
.pause-overlay {
position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
width: 96px; height: 96px; border-radius: 50%;
background: rgba(0,0,0,0.6); border: 2px solid rgba(255,255,255,0.3);
color: #fff; font-size: 40px; padding-left: 6px;
display: flex; align-items: center; justify-content: center;
cursor: pointer; z-index: 4; backdrop-filter: blur(6px);
transition: transform 0.15s, background 0.15s;
animation: pauseAppear 0.25s ease-out;