dongsik22 Claude Opus 4.7 (1M context) commited on
Commit
8724399
·
1 Parent(s): 14c33fd

feat: 스킵 마킹 UI 통합 (anilife 적용 + 재생바 마커 + 우클릭 메뉴)

Browse files

기존: tvchak만 키보드 [ ] ; 로 마킹. anilife는 자동 chapter만.

추가:
- anilife도 fav.skip 동일 적용 (사용자 마킹 우선, 자동 chapter는 fallback)
- 엔딩 끝(edEnd) 마킹 추가 — 단축키 백슬래시, fav.skip.edEnd
- 풀스크린 재생바(zc-bar) 위에 스킵 구간 노랑 띠 시각 표시
(#skipMarkers 오버레이, .skip-range / .skip-tick)
- 우클릭 컨텍스트 메뉴(#skipCtxMenu) — 비디오 영역 우클릭/모바일 길게 누르기
→ 오프닝/엔딩 시작·끝/초기화 5개 액션
- applySkipMark(kind) 공통 진입점으로 키보드·메뉴 일원화

같은 시리즈의 모든 회차에 자동 적용은 기존 동작 그대로.
loadedmetadata 시 renderSkipMarkers 자동 호출.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. index.html +149 -31
index.html CHANGED
@@ -170,6 +170,21 @@
170
  .zoom-ctrl .zc-time { font-variant-numeric: tabular-nums; min-width: 100px; font-size: 12px; }
171
  .zoom-ctrl .zc-bar { flex: 1; height: 4px; cursor: pointer; accent-color: #e50914;
172
  background: rgba(255,255,255,0.3); border-radius: 2px; -webkit-appearance: none; appearance: none; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  .zoom-ctrl .zc-bar::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
174
  width: 14px; height: 14px; border-radius: 50%; background: #e50914; cursor: pointer; }
175
  .zoom-ctrl .zc-bar::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%;
@@ -758,6 +773,14 @@
758
  <button id="pauseOverlay" class="pause-overlay" hidden>▶</button>
759
  <!-- 오프닝/엔딩 스킵 버튼 (chapter 또는 사용자 마킹 구간 진입 시 표시) -->
760
  <button id="btnSkip" class="skip-btn" hidden>스킵 ⏭</button>
 
 
 
 
 
 
 
 
761
  <!-- H-11: 화질 선택 / H-5: 오디오·자막 -->
762
  <select id="hlsQuality" class="hls-quality" aria-label="화질"></select>
763
  <select id="hlsAudio" class="hls-audio" aria-label="오디오"></select>
@@ -780,7 +803,10 @@
780
  <div id="zoomCtrl" class="zoom-ctrl" hidden>
781
  <button id="zcPlay" class="zc-btn">▶</button>
782
  <span id="zcTime" class="zc-time">0:00 / 0:00</span>
783
- <input id="zcBar" class="zc-bar" type="range" min="0" max="1000" value="0" />
 
 
 
784
  <button id="zcMute" class="zc-btn" title="음소거 (M)">🔊</button>
785
  <input id="zcVol" class="zc-vol" type="range" min="0" max="100" value="100" title="볼륨" />
786
  <button id="zcReset" class="zc-btn" title="줌 1배로">↺</button>
@@ -1605,6 +1631,115 @@ let _currentHls = null;
1605
  // 현재 영상의 chapter (anilife) - { op:{start,end}, ed:{start,end} } 또는 null
1606
  let _currentSkips = null;
1607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1608
  // ─── 재생 ───
1609
  async function playEpisode(id, sid, nid, opts = {}) {
1610
  const userInitiated = opts.userInitiated !== false; // 기본 true
@@ -1618,16 +1753,17 @@ async function playEpisode(id, sid, nid, opts = {}) {
1618
  if (_currentHls) { try { _currentHls.destroy(); } catch {} _currentHls = null; }
1619
 
1620
  _currentSkips = null;
1621
- // tvchak: 사용자가 마킹한 오프닝/엔딩 구간 적용 (같은 시리즈 = 같은 fav 안에서 모든 회차 공통)
1622
- if (src === 'tvchak' && fav?.skip) {
 
1623
  const s = fav.skip;
1624
  const skips = {};
1625
  if (typeof s.opStart === 'number' && typeof s.opEnd === 'number' && s.opEnd > s.opStart) {
1626
  skips.op = { start: s.opStart, end: s.opEnd };
1627
  }
1628
  if (typeof s.edStart === 'number') {
1629
- // 엔딩은 시작만 마킹, 끝은 영상 종료 시점 (timeupdate에서 duration 활용)
1630
- skips.ed = { start: s.edStart, end: Infinity };
1631
  }
1632
  if (skips.op || skips.ed) _currentSkips = skips;
1633
  }
@@ -1646,7 +1782,8 @@ async function playEpisode(id, sid, nid, opts = {}) {
1646
  // - 첫 chapter (5분 이하)면 오프닝
1647
  // - 마지��� chapter (또는 끝에서 두번째, 5분 이하)면 엔딩
1648
  // - "트레일러/다음화 예고"용 미세 chapter는 무시
1649
- if (Array.isArray(p.chapters) && p.chapters.length >= 2) {
 
1650
  const chs = p.chapters;
1651
  const skips = {};
1652
  // 오프닝: 첫 chapter, 시작 0 근처 + 길이 10~300초
@@ -2891,31 +3028,11 @@ function toggleSidePanel() {
2891
  const step = e.shiftKey ? 10 : 5;
2892
  const dir = e.key === 'ArrowLeft' ? -1 : 1;
2893
  v.currentTime = Math.max(0, Math.min(v.duration, v.currentTime + dir * step));
2894
- } else if (e.key === '[' || e.key === ']' || e.key === ';' || e.key === "'") {
2895
- // 오프닝/엔딩 구간 마킹 (tvchak fav에 저장, 같은 시리즈의 모든 회차에 자동 적용)
2896
- const v = $('#player');
2897
- if (!v || !currentFavId || currentFavSource !== 'tvchak') return;
2898
- const fav = favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === 'tvchak');
2899
- if (!fav) return;
2900
  e.preventDefault();
2901
- fav.skip = fav.skip || {};
2902
- const t = Math.floor(v.currentTime);
2903
- const fmt = (s) => `${Math.floor(s/60)}:${String(s%60).padStart(2,'0')}`;
2904
- let msg = '';
2905
- if (e.key === '[') { fav.skip.opStart = t; msg = `오프닝 시작: ${fmt(t)}`; }
2906
- else if (e.key === ']') { fav.skip.opEnd = t; msg = `오프닝 끝: ${fmt(t)}`; }
2907
- else if (e.key === ';') { fav.skip.edStart = t; msg = `엔딩 시작: ${fmt(t)}`; }
2908
- else if (e.key === "'") { delete fav.skip; msg = '스킵 마킹 초기화'; }
2909
- saveFavs();
2910
- // 현재 영상에도 즉시 반영
2911
- if (fav.skip) {
2912
- const skips = {};
2913
- if (fav.skip.opStart != null && fav.skip.opEnd != null) skips.op = { start: fav.skip.opStart, end: fav.skip.opEnd };
2914
- if (fav.skip.edStart != null) skips.ed = { start: fav.skip.edStart, end: Infinity };
2915
- _currentSkips = (skips.op || skips.ed) ? skips : null;
2916
- } else { _currentSkips = null; }
2917
- // 토스트
2918
- showToast(msg);
2919
  }
2920
  });
2921
  })();
@@ -3169,12 +3286,13 @@ function setupRateMemory() {
3169
  saveFavs();
3170
  }
3171
  });
3172
- // 새 영상 loadedmetadata 시 시리즈 기억 속도 적용
3173
  v.addEventListener('loadedmetadata', () => {
3174
  const fav = favs.find(f => f.id === currentFavId);
3175
  if (fav && typeof fav.lastPlaybackRate === 'number' && fav.lastPlaybackRate > 0) {
3176
  try { v.playbackRate = fav.lastPlaybackRate; } catch {}
3177
  }
 
3178
  });
3179
  }
3180
 
 
170
  .zoom-ctrl .zc-time { font-variant-numeric: tabular-nums; min-width: 100px; font-size: 12px; }
171
  .zoom-ctrl .zc-bar { flex: 1; height: 4px; cursor: pointer; accent-color: #e50914;
172
  background: rgba(255,255,255,0.3); border-radius: 2px; -webkit-appearance: none; appearance: none; }
173
+ /* 스킵 구간 시각 표시 — zc-bar 위에 반투명 노랑 띠 */
174
+ .skip-markers .skip-range { position: absolute; top: 0; bottom: 0;
175
+ background: rgba(255, 200, 0, 0.55); border-radius: 2px; }
176
+ .skip-markers .skip-tick { position: absolute; top: -2px; bottom: -2px; width: 2px;
177
+ background: #ffc800; box-shadow: 0 0 4px rgba(255,200,0,0.8); }
178
+ /* 스킵 마킹 컨텍스트 메뉴 */
179
+ .skip-ctx-menu { position: absolute; z-index: 2147483647; background: rgba(20,22,28,0.96);
180
+ border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 4px;
181
+ box-shadow: 0 4px 20px rgba(0,0,0,0.6); min-width: 180px; }
182
+ .skip-ctx-menu[hidden] { display: none; }
183
+ .skip-ctx-menu button { display: block; width: 100%; text-align: left;
184
+ background: transparent; border: 0; color: #e3e6eb; font-size: 13px;
185
+ padding: 8px 12px; border-radius: 4px; cursor: pointer; }
186
+ .skip-ctx-menu button:hover { background: rgba(255,255,255,0.08); }
187
+ .skip-ctx-menu button[data-skip="clear"] { color: #ff9090; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 2px; }
188
  .zoom-ctrl .zc-bar::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
189
  width: 14px; height: 14px; border-radius: 50%; background: #e50914; cursor: pointer; }
190
  .zoom-ctrl .zc-bar::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%;
 
773
  <button id="pauseOverlay" class="pause-overlay" hidden>▶</button>
774
  <!-- 오프닝/엔딩 스킵 버튼 (chapter 또는 사용자 마킹 구간 진입 시 표시) -->
775
  <button id="btnSkip" class="skip-btn" hidden>스킵 ⏭</button>
776
+ <!-- 스킵 마킹 컨텍스트 메뉴 (비디오 우클릭/길게 누르기) -->
777
+ <div id="skipCtxMenu" class="skip-ctx-menu" hidden>
778
+ <button data-skip="opStart">⏵ 오프닝 시작 마킹</button>
779
+ <button data-skip="opEnd">⏵ 오프닝 끝 마킹</button>
780
+ <button data-skip="edStart">⏵ 엔딩 시작 마킹</button>
781
+ <button data-skip="edEnd">⏵ 엔딩 끝 마킹</button>
782
+ <button data-skip="clear">✕ 마킹 초기화</button>
783
+ </div>
784
  <!-- H-11: 화질 선택 / H-5: 오디오·자막 -->
785
  <select id="hlsQuality" class="hls-quality" aria-label="화질"></select>
786
  <select id="hlsAudio" class="hls-audio" aria-label="오디오"></select>
 
803
  <div id="zoomCtrl" class="zoom-ctrl" hidden>
804
  <button id="zcPlay" class="zc-btn">▶</button>
805
  <span id="zcTime" class="zc-time">0:00 / 0:00</span>
806
+ <div class="zc-bar-wrap" style="flex:1; position:relative; display:flex; align-items:center;">
807
+ <input id="zcBar" class="zc-bar" type="range" min="0" max="1000" value="0" style="width:100%;" />
808
+ <div id="skipMarkers" class="skip-markers" style="position:absolute; left:0; right:0; top:50%; transform:translateY(-50%); height:6px; pointer-events:none;"></div>
809
+ </div>
810
  <button id="zcMute" class="zc-btn" title="음소거 (M)">🔊</button>
811
  <input id="zcVol" class="zc-vol" type="range" min="0" max="100" value="100" title="볼륨" />
812
  <button id="zcReset" class="zc-btn" title="줌 1배로">↺</button>
 
1631
  // 현재 영상의 chapter (anilife) - { op:{start,end}, ed:{start,end} } 또는 null
1632
  let _currentSkips = null;
1633
 
1634
+ // 풀스크린 재생바 위에 스킵 구간 시각 표시
1635
+ function renderSkipMarkers() {
1636
+ const host = document.getElementById('skipMarkers');
1637
+ if (!host) return;
1638
+ host.innerHTML = '';
1639
+ const v = document.getElementById('player');
1640
+ const dur = v?.duration;
1641
+ if (!_currentSkips || !dur || !isFinite(dur) || dur <= 0) return;
1642
+ const add = (start, end, isTick) => {
1643
+ if (start == null || end == null) return;
1644
+ const e = isFinite(end) ? end : dur;
1645
+ if (e <= start) return;
1646
+ const left = Math.max(0, (start / dur) * 100);
1647
+ const width = Math.min(100, ((e - start) / dur) * 100);
1648
+ const el = document.createElement('div');
1649
+ el.className = isTick ? 'skip-tick' : 'skip-range';
1650
+ el.style.left = left + '%';
1651
+ if (!isTick) el.style.width = width + '%';
1652
+ host.appendChild(el);
1653
+ };
1654
+ if (_currentSkips.op) add(_currentSkips.op.start, _currentSkips.op.end, false);
1655
+ if (_currentSkips.ed) add(_currentSkips.ed.start, _currentSkips.ed.end, false);
1656
+ }
1657
+
1658
+ // 스킵 마킹 공통 적용 함수 — 키보드·우클릭 메뉴 공통 진입점.
1659
+ // kind: 'opStart' | 'opEnd' | 'edStart' | 'edEnd' | 'clear'
1660
+ function applySkipMark(kind) {
1661
+ const v = document.getElementById('player');
1662
+ if (!v || !currentFavId) return;
1663
+ const fav = favs.find(f => f.id === currentFavId && (f.source || 'tvchak') === (currentFavSource || 'tvchak'));
1664
+ if (!fav) return;
1665
+ const t = Math.floor(v.currentTime);
1666
+ const fmt = (s) => `${Math.floor(s/60)}:${String(s%60).padStart(2,'0')}`;
1667
+ let msg = '';
1668
+ if (kind === 'clear') { delete fav.skip; msg = '스킵 마킹 초기화'; }
1669
+ else {
1670
+ fav.skip = fav.skip || {};
1671
+ if (kind === 'opStart') { fav.skip.opStart = t; msg = `오프닝 시작: ${fmt(t)}`; }
1672
+ else if (kind === 'opEnd') { fav.skip.opEnd = t; msg = `오프닝 끝: ${fmt(t)}`; }
1673
+ else if (kind === 'edStart') { fav.skip.edStart = t; msg = `엔딩 시작: ${fmt(t)}`; }
1674
+ else if (kind === 'edEnd') { fav.skip.edEnd = t; msg = `엔딩 끝: ${fmt(t)}`; }
1675
+ else return;
1676
+ }
1677
+ saveFavs();
1678
+ // 현재 영상에도 즉시 반영
1679
+ if (fav.skip) {
1680
+ const skips = {};
1681
+ if (fav.skip.opStart != null && fav.skip.opEnd != null) skips.op = { start: fav.skip.opStart, end: fav.skip.opEnd };
1682
+ if (fav.skip.edStart != null) skips.ed = { start: fav.skip.edStart, end: (typeof fav.skip.edEnd === 'number' && fav.skip.edEnd > fav.skip.edStart) ? fav.skip.edEnd : Infinity };
1683
+ _currentSkips = (skips.op || skips.ed) ? skips : null;
1684
+ } else { _currentSkips = null; }
1685
+ renderSkipMarkers();
1686
+ if (typeof showToast === 'function') showToast(msg);
1687
+ }
1688
+
1689
+ // 우클릭 / 길게 누르기 컨텍스트 메뉴
1690
+ (function setupSkipContextMenu() {
1691
+ const wrap = document.querySelector('.video-wrap');
1692
+ const menu = document.getElementById('skipCtxMenu');
1693
+ if (!wrap || !menu) return;
1694
+ function showMenu(clientX, clientY) {
1695
+ if (!currentFavId) return; // 재생 중일 때만
1696
+ const rect = wrap.getBoundingClientRect();
1697
+ let x = clientX - rect.left, y = clientY - rect.top;
1698
+ menu.hidden = false;
1699
+ // 화면 밖 안 나가게
1700
+ const mw = menu.offsetWidth, mh = menu.offsetHeight;
1701
+ if (x + mw > rect.width) x = rect.width - mw - 4;
1702
+ if (y + mh > rect.height) y = rect.height - mh - 4;
1703
+ menu.style.left = x + 'px';
1704
+ menu.style.top = y + 'px';
1705
+ }
1706
+ function hideMenu() { menu.hidden = true; }
1707
+ // 우클릭
1708
+ wrap.addEventListener('contextmenu', (e) => {
1709
+ // 비디오 영역 우클릭만 (컨트롤바 우클릭은 브라우저 기본 메뉴 살림)
1710
+ if (e.target.closest('#zoomCtrl, .hls-quality, .hls-audio, .hls-sub')) return;
1711
+ if (!currentFavId) return;
1712
+ e.preventDefault();
1713
+ showMenu(e.clientX, e.clientY);
1714
+ });
1715
+ // 모바일 길게 누르기 — touchstart로 600ms 측정
1716
+ let touchTimer = null;
1717
+ wrap.addEventListener('touchstart', (e) => {
1718
+ if (e.target.closest('#zoomCtrl')) return;
1719
+ if (!currentFavId) return;
1720
+ const t = e.touches[0];
1721
+ const cx = t.clientX, cy = t.clientY;
1722
+ touchTimer = setTimeout(() => { showMenu(cx, cy); }, 600);
1723
+ }, { passive: true });
1724
+ wrap.addEventListener('touchmove', () => { clearTimeout(touchTimer); }, { passive: true });
1725
+ wrap.addEventListener('touchend', () => { clearTimeout(touchTimer); }, { passive: true });
1726
+ // 메뉴 클릭 → 액션 + 닫기
1727
+ menu.addEventListener('click', (e) => {
1728
+ const btn = e.target.closest('button[data-skip]');
1729
+ if (!btn) return;
1730
+ e.stopPropagation();
1731
+ applySkipMark(btn.dataset.skip);
1732
+ hideMenu();
1733
+ });
1734
+ // 바깥 클릭 / Esc 시 닫기
1735
+ document.addEventListener('click', (e) => {
1736
+ if (!menu.hidden && !e.target.closest('#skipCtxMenu')) hideMenu();
1737
+ });
1738
+ document.addEventListener('keydown', (e) => {
1739
+ if (e.key === 'Escape' && !menu.hidden) hideMenu();
1740
+ });
1741
+ })();
1742
+
1743
  // ─── 재생 ───
1744
  async function playEpisode(id, sid, nid, opts = {}) {
1745
  const userInitiated = opts.userInitiated !== false; // 기본 true
 
1753
  if (_currentHls) { try { _currentHls.destroy(); } catch {} _currentHls = null; }
1754
 
1755
  _currentSkips = null;
1756
+ // 사용자가 마킹한 오프닝/엔딩 구간 적용 (같은 시리즈 = 같은 fav 안에서 모든 회차 공통).
1757
+ // tvchak·anilife 둘 다 동일하게 동작. 사용자 마킹은 anilife 자동 chapter보다 우선.
1758
+ if (fav?.skip) {
1759
  const s = fav.skip;
1760
  const skips = {};
1761
  if (typeof s.opStart === 'number' && typeof s.opEnd === 'number' && s.opEnd > s.opStart) {
1762
  skips.op = { start: s.opStart, end: s.opEnd };
1763
  }
1764
  if (typeof s.edStart === 'number') {
1765
+ // 엔딩 끝 마킹: edEnd 있으면 그것, 없으면 영상 종료 시점
1766
+ skips.ed = { start: s.edStart, end: (typeof s.edEnd === 'number' && s.edEnd > s.edStart) ? s.edEnd : Infinity };
1767
  }
1768
  if (skips.op || skips.ed) _currentSkips = skips;
1769
  }
 
1782
  // - 첫 chapter (5분 이하)면 오프닝
1783
  // - 마지��� chapter (또는 끝에서 두번째, 5분 이하)면 엔딩
1784
  // - "트레일러/다음화 예고"용 미세 chapter는 무시
1785
+ // 사용자 마킹(_currentSkips 이미 설정됨)이 있으면 자동 chapter는 무시
1786
+ if (!_currentSkips && Array.isArray(p.chapters) && p.chapters.length >= 2) {
1787
  const chs = p.chapters;
1788
  const skips = {};
1789
  // 오프닝: 첫 chapter, 시작 0 근처 + 길이 10~300초
 
3028
  const step = e.shiftKey ? 10 : 5;
3029
  const dir = e.key === 'ArrowLeft' ? -1 : 1;
3030
  v.currentTime = Math.max(0, Math.min(v.duration, v.currentTime + dir * step));
3031
+ } else if (e.key === '[' || e.key === ']' || e.key === ';' || e.key === "'" || e.key === '\\') {
3032
+ // 단축키: [ 오프닝 시작 / ] 오프닝 끝 / ; 엔딩 시작 / \ 엔딩 끝 / ' 초기화
3033
+ const map = { '[': 'opStart', ']': 'opEnd', ';': 'edStart', '\\': 'edEnd', "'": 'clear' };
 
 
 
3034
  e.preventDefault();
3035
+ applySkipMark(map[e.key]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3036
  }
3037
  });
3038
  })();
 
3286
  saveFavs();
3287
  }
3288
  });
3289
+ // 새 영상 loadedmetadata 시 시리즈 기억 속도 적용 + 스킵 마커 그리기
3290
  v.addEventListener('loadedmetadata', () => {
3291
  const fav = favs.find(f => f.id === currentFavId);
3292
  if (fav && typeof fav.lastPlaybackRate === 'number' && fav.lastPlaybackRate > 0) {
3293
  try { v.playbackRate = fav.lastPlaybackRate; } catch {}
3294
  }
3295
+ renderSkipMarkers();
3296
  });
3297
  }
3298