@kangsicj/nexussync 1.6.11 → 1.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  // @icon https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/assets/icon.svg
9
9
  // @updateURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.meta.js
10
10
  // @downloadURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js
11
- // @version 1.6.11
11
+ // @version 1.6.12
12
12
  // @description Watch any web video together in perfect sync: cinema mode, live AI subtitles & translation, chat bubbles with auto-translation, quick ink, cover, go-together to the next episode.
13
13
  // @description:ko 어떤 웹 영상이든 완벽한 싱크로 함께 보기: 시네마 모드, 실시간 AI 자막·번역, 자동 번역 말풍선 채팅, 잠깐 그리기, 가리기, 다음 화도 함께.
14
14
  // @match *://*/*
@@ -8,7 +8,7 @@
8
8
  // @icon https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/assets/icon.svg
9
9
  // @updateURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.meta.js
10
10
  // @downloadURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js
11
- // @version 1.6.11
11
+ // @version 1.6.12
12
12
  // @description Watch any web video together in perfect sync: cinema mode, live AI subtitles & translation, chat bubbles with auto-translation, quick ink, cover, go-together to the next episode.
13
13
  // @description:ko 어떤 웹 영상이든 완벽한 싱크로 함께 보기: 시네마 모드, 실시간 AI 자막·번역, 자동 번역 말풍선 채팅, 잠깐 그리기, 가리기, 다음 화도 함께.
14
14
  // @match *://*/*
@@ -46,12 +46,12 @@
46
46
 
47
47
  // The version of the code that is actually running (the manager's metadata can lag
48
48
  // behind when an old copy is still installed).
49
- const NXU_VERSION = '1.6.11';
49
+ const NXU_VERSION = '1.6.12';
50
50
  // Rank used by the one-instance guard below and to tell newer builds apart in a room.
51
51
  // It is independent of the public version (1.0.0 is the first public release, after
52
52
  // private builds that reached ranks up to 10.2.0), so every older copy still installed
53
53
  // steps aside instead of this release.
54
- const NXU_RANK = '11.6.11';
54
+ const NXU_RANK = '11.6.12';
55
55
  const NXU_SESSION = Math.random().toString(36).slice(2, 10); // this page load // raise with every release
56
56
  // App icon (same artwork as assets/icon.svg / @icon), inlined so it shows offline too.
57
57
  const NXU_ICON = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2IiByb2xlPSJpbWciIGFyaWEtbGFiZWw9Ik5leHVzU3luYyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJueGJnIiB4MT0iMCIgeTE9IjAiIHgyPSIxIiB5Mj0iMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjNWIyZWZmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmY0ZmEzIi8+PC9saW5lYXJHcmFkaWVudD48cmFkaWFsR3JhZGllbnQgaWQ9Im54Z2xvdyIgY3g9IjAuODIiIGN5PSIwLjE0IiByPSIwLjciPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzdjZjlmZiIgc3RvcC1vcGFjaXR5PSIwLjU1Ii8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjN2NmOWZmIiBzdG9wLW9wYWNpdHk9IjAiLz48L3JhZGlhbEdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0ibnhwbGF5IiB4MT0iMCIgeTE9IjAiIHgyPSIxIiB5Mj0iMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZmZmZmZmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmZlM2YxIi8+PC9saW5lYXJHcmFkaWVudD48Y2xpcFBhdGggaWQ9Im54ciI+PHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIHJ4PSI1OCIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNueHIpIj48cmVjdCB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgZmlsbD0idXJsKCNueGJnKSIvPjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSJ1cmwoI254Z2xvdykiLz48ZyBmaWxsPSJub25lIiBzdHJva2U9IiNmZmZmZmYiIHN0cm9rZS13aWR0aD0iMTUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTYwIDExNiBBNzAgNzAgMCAwIDEgMTc4IDcyIi8+PHBhdGggZD0iTTE5NiAxNDAgQTcwIDcwIDAgMCAxIDc4IDE4NCIvPjwvZz48cGF0aCBkPSJNMTg2IDUwIEwyMDAgOTIgTDE1NyA4NiBaIiBmaWxsPSIjZmZmZmZmIi8+PHBhdGggZD0iTTcwIDIwNiBMNTYgMTY0IEw5OSAxNzAgWiIgZmlsbD0iI2ZmZmZmZiIvPjxwYXRoIGQ9Ik0xMTAgOTIgUTEwNCA4OCAxMDQgOTYgTDEwNCAxNjAgUTEwNCAxNjggMTEwIDE2NCBMMTYyIDEzMiBRMTY4IDEyOCAxNjIgMTI0IFoiIGZpbGw9InVybCgjbnhwbGF5KSIvPjwvZz48L3N2Zz4=';
@@ -764,7 +764,7 @@ async function handle(m) {
764
764
  tuneSrcSame: '🟢 Same video on every device — kept in step automatically, frame by frame.', tuneSrcDiff: '🟠 Different versions (length differs by {s}) — the timing is found automatically after a little playing, or set it here.', tuneSrcUnknown: 'Waiting for the others’ video…', tuneSrcShifted: '🟠 Same length, but the scenes differ — the timing is lined up automatically while you play, or set it here.', tuneDiffPicture: 'Same time, but the pictures differ', tuneShiftFound: 'Same length but different scenes: timing set to {s} automatically (tap to undo).',
765
765
  tuneSameReset: '⏱ Same video as the others: timing correction removed.', tuneAutoApplied: 'Different version: timing set to {s} automatically (tap to undo).', tuneSuggest: 'Your videos differ by {s}. Tap to line them up.',
766
766
  subMenu: 'Subtitles', xsubOff: 'Off', subTrack: 'From the video', subSearch: '🔎 Find subtitles (OpenSubtitles)', subFile: '📂 Open a subtitle file…', subAi: '🧠 AI live subtitles', subDelay: 'Timing', subLater: 'later', subEarlier: 'earlier', xsubSize: 'Size',
767
- subLoaded: '💬 Subtitles: {name}', subMulti: 'Several subtitles at once — tap one to take it away.', subNone: 'No subtitles found in this video.', subSuggest: '💬 No subtitles? Find them', subLoadFail: 'Could not load these subtitles.',
767
+ subLoaded: '💬 Subtitles: {name}', subMulti: 'Several subtitles at once — tap one to take it away.', subNone: 'No subtitles found in this video.', subMoreLangs: '🌐 {n} more languages', subSiteOnly: 'This site loads that subtitle only from its own menu — switch to the site controls (top right) and pick it there.', subSuggest: '💬 No subtitles? Find them', subLoadFail: 'Could not load these subtitles.',
768
768
  osTitle: 'Find subtitles', osTmdbLooking: 'Looking up the English title on TMDB…', osTmdbNone: 'No English title found on TMDB — type it yourself if you know it.', osQuery: 'Title (English titles work best)', osSeason: 'Season', osEpisode: 'Episode', osLang: 'Language', osSearch: 'Search', osSearching: 'Searching…', osNone: 'Nothing found. Try the English title, or remove the year.', osError: 'OpenSubtitles did not answer. Try again in a moment.', osDownloads: '{n} downloads', osLoading: 'Loading…', osHint: 'Subtitles come from OpenSubtitles.org and are shown in NexusSync’s own style; use “Timing” in the subtitle menu if they are early or late.',
769
769
  viewMenu: 'Picture', viewAudio: 'Soundtrack', viewBright: 'Brightness', viewBoost: 'Volume boost', viewReset: 'Reset', boostBlocked: 'This video’s sound cannot be boosted here (it comes from another site).',
770
770
  settings: 'Settings', setProfile: 'Profile', setAvatar: 'Avatar', setStatus: 'Status message', setStatusPh: 'e.g. Popcorn ready 🍿', setReactions: 'My reactions',
@@ -889,7 +889,7 @@ async function handle(m) {
889
889
  tuneSrcSame: '🟢 모두 같은 영상이에요 — 프레임 단위로 자동으로 맞추고 있어요.', tuneSrcDiff: '🟠 서로 다른 버전이에요 (길이 차이 {s}) — 잠시 재생하면 자동으로 맞추고, 여기서 직접 맞출 수도 있어요.', tuneSrcUnknown: '다른 사람의 영상 정보를 기다리는 중…', tuneSrcShifted: '🟠 길이는 같지만 장면이 달라요 — 재생하는 동안 자동으로 맞추고, 여기서 직접 맞출 수도 있어요.', tuneDiffPicture: '시간은 같지만 화면이 달라요', tuneShiftFound: '길이는 같지만 장면이 달라서 타이밍을 {s} 자동 보정했어요 (누르면 되돌리기).',
890
890
  tuneSameReset: '⏱ 상대와 같은 영상이라 타이밍 보정을 해제했어요.', tuneAutoApplied: '다른 버전이라 타이밍을 {s} 자동 보정했어요 (누르면 되돌리기).', tuneSuggest: '서로 영상 길이가 {s} 달라요. 눌러서 맞춰 보세요.',
891
891
  subMenu: '자막', xsubOff: '끄기', subTrack: '영상에 포함된 자막', subSearch: '🔎 자막 찾기 (OpenSubtitles)', subFile: '📂 자막 파일 열기…', subAi: '🧠 AI 실시간 자막', subDelay: '싱크', subLater: '늦게', subEarlier: '빠르게', xsubSize: '크기',
892
- subLoaded: '💬 자막: {name}', subMulti: '자막 여러 개를 함께 보는 중 — 누르면 그 자막만 꺼져요.', subNone: '이 영상에는 포함된 자막이 없어요.', subSuggest: '💬 자막이 없나요? 찾아보기', subLoadFail: '자막을 불러오지 못했어요.',
892
+ subLoaded: '💬 자막: {name}', subMulti: '자막 여러 개를 함께 보는 중 — 누르면 그 자막만 꺼져요.', subNone: '이 영상에는 포함된 자막이 없어요.', subMoreLangs: '🌐 다른 언어 {n}개 더 보기', subSiteOnly: '이 사이트는 자기 메뉴에서만 이 자막을 불러와요. 오른쪽 위에서 사이트 컨트롤로 바꾼 뒤 거기서 골라 주세요.', subSuggest: '💬 자막이 없나요? 찾아보기', subLoadFail: '자막을 불러오지 못했어요.',
893
893
  osTitle: '자막 찾기', osTmdbLooking: 'TMDB에서 영어 제목을 찾는 중…', osTmdbNone: 'TMDB에서 영어 제목을 찾지 못했어요 — 알고 있다면 직접 입력하세요.', osQuery: '제목 (영어 제목이 가장 잘 찾아져요)', osSeason: '시즌', osEpisode: '회차', osLang: '언어', osSearch: '검색', osSearching: '찾는 중…', osNone: '찾지 못했어요. 영어 제목으로 바꾸거나 연도를 빼 보세요.', osError: 'OpenSubtitles가 응답하지 않아요. 잠시 후 다시 시도하세요.', osDownloads: '다운로드 {n}회', osLoading: '불러오는 중…', osHint: '자막은 OpenSubtitles.org에서 가져와 NexusSync 스타일로 보여 줘요. 빠르거나 늦으면 자막 메뉴의 “싱크”로 맞추세요.',
894
894
  viewMenu: '화면', viewAudio: '오디오 트랙', viewBright: '밝기', viewBoost: '볼륨 부스트', viewReset: '초기화', boostBlocked: '이 영상은 다른 사이트에서 오는 소리라 여기서 키울 수 없어요.',
895
895
  settings: '설정', setProfile: '프로필', setAvatar: '아바타', setStatus: '상태 메시지', setStatusPh: '예: 팝콘 준비 완료 🍿', setReactions: '내 리액션',
@@ -7453,6 +7453,7 @@ async function handle(m) {
7453
7453
  wrapper?.classList.toggle('touch-peek', IS_TOUCH && STATE.isCinema);
7454
7454
  getContainer()?.classList.remove('chrome-idle');
7455
7455
  if (CUE_MIRROR.box) CUE_MIRROR.render();
7456
+ if (IS_TOP && STATE.isCinema) { try { CINEMA_UI.placeSiteBar(); } catch (_) { } }
7456
7457
  getOpenPanels().forEach(panel => {
7457
7458
  panel.style.opacity = '1';
7458
7459
  panel.style.pointerEvents = 'auto';
@@ -10470,6 +10471,21 @@ async function handle(m) {
10470
10471
  },
10471
10472
  active() { return this.layers.length > 0; },
10472
10473
  hasTrack(tr) { return this.layers.some(l => l.track === tr); },
10474
+ // 1 = your subtitle language, 2 = English, 3 = anything else (labels or codes like "kor").
10475
+ langRank(tr) {
10476
+ const want = baseLang(STORE.get('nxu_subtitle_language', '') || navigator.language || 'en') || 'en';
10477
+ const is = (code) => {
10478
+ const lang = String(tr.language || '').toLowerCase(), label = String(tr.label || '').toLowerCase();
10479
+ if (lang === code || lang.startsWith(code + '-') || lang.startsWith(code + '_')) return true;
10480
+ const three = { ko: ['kor'], en: ['eng'], ja: ['jpn', 'jap'], zh: ['chi', 'zho'], es: ['spa'], fr: ['fre', 'fra'], de: ['ger', 'deu'], pt: ['por'], ru: ['rus'], it: ['ita'], vi: ['vie'], th: ['tha'], id: ['ind'] }[code] || [];
10481
+ if (three.includes(lang)) return true;
10482
+ try {
10483
+ const names = [new Intl.DisplayNames(['en'], { type: 'language' }).of(code), new Intl.DisplayNames([code], { type: 'language' }).of(code)].map(s => String(s).toLowerCase());
10484
+ return names.some(n => n && label.startsWith(n));
10485
+ } catch (_) { return false; }
10486
+ };
10487
+ return is(want) ? 1 : want !== 'en' && is('en') ? 2 : 3;
10488
+ },
10473
10489
  _ensureBox() {
10474
10490
  const c = getContainer();
10475
10491
  if (!c) return null;
@@ -10510,6 +10526,44 @@ async function handle(m) {
10510
10526
  tr.mode = 'hidden'; // cues still arrive, the browser does not draw them itself
10511
10527
  tr.addEventListener('cuechange', this._onCue);
10512
10528
  this._add({ kind: 'track', track: tr, label: tr.label || tr.language || t('subTrack') });
10529
+ this._askSite(tr);
10530
+ },
10531
+ // Some players list every language as an empty track and fetch the cues only when the
10532
+ // language is picked in their own menu (meowtv). Picked here, such a track stays empty:
10533
+ // pick it in the site's menu too, the same entry (the n-th one of that name), then close it.
10534
+ _askSite(tr) {
10535
+ const v = STATE.video;
10536
+ if (!v || tr._nxuAsked) return;
10537
+ setTimeout(async () => {
10538
+ if (!this.hasTrack(tr) || tr.cues?.length) return;
10539
+ // A <track src> loads its own file: nothing to ask the site for.
10540
+ if ([...v.querySelectorAll('track')].some(el => el.track === tr && el.src)) return;
10541
+ tr._nxuAsked = true;
10542
+ const label = (tr.label || '').trim();
10543
+ const same = this.tracks().filter(x => (x.label || '').trim() === label);
10544
+ const nth = Math.max(0, same.indexOf(tr));
10545
+ const wait = (ms) => new Promise(r => setTimeout(r, ms));
10546
+ const isSubBtn = (b) => /subtit|caption|자막|\bcc\b/i.test([b.getAttribute('aria-label'), b.title, b.getAttribute('data-tooltip'), b.textContent.length < 20 ? b.textContent : ''].join(' '));
10547
+ let scope = v.parentElement;
10548
+ for (let i = 0; scope && i < 8 && ![...scope.querySelectorAll('button,[role="button"]')].some(isSubBtn); i++) scope = scope.parentElement;
10549
+ const toggle = scope && [...scope.querySelectorAll('button,[role="button"]')].find(isSubBtn);
10550
+ if (label && toggle) {
10551
+ try {
10552
+ toggle.click();
10553
+ await wait(400);
10554
+ const pick = [...scope.querySelectorAll('button,[role="menuitem"],[role="menuitemradio"],[role="option"],li')]
10555
+ .filter(el => !el.contains(toggle) && (el.innerText || el.textContent || '').trim() === label);
10556
+ const target = pick[Math.min(nth, pick.length - 1)];
10557
+ if (target) target.click();
10558
+ await wait(300);
10559
+ if (target?.isConnected && target.getClientRects().length) toggle.click(); // close the site's menu
10560
+ } catch (_) { }
10561
+ }
10562
+ await wait(2500);
10563
+ if (!this.hasTrack(tr)) return;
10564
+ if (tr.cues?.length) { this.tick(true); logDebug(`Subtitles: "${label}" loaded through the site's own menu.`, 'info'); }
10565
+ else showToast(t('subSiteOnly'));
10566
+ }, 1500);
10513
10567
  },
10514
10568
  useCues(cues, label) { this._add({ kind: 'cues', cues: cues.sort((a, b) => a.s - b.s), label }); },
10515
10569
  _loop() { clearInterval(this._timer); this._timer = setInterval(() => this.tick(), 150); this.tick(true); },
@@ -10638,16 +10692,21 @@ async function handle(m) {
10638
10692
  if (this._root === root) return;
10639
10693
  this.stop();
10640
10694
  this._root = root;
10641
- this._obs = new MutationObserver(() => { if (!this._timer) this._timer = setTimeout(() => { this._timer = 0; this.scan(); }, 80); });
10695
+ // Scanned again a little later too: the list of the player's text layers is refreshed
10696
+ // a moment after the player redraws.
10697
+ this._obs = new MutationObserver(() => {
10698
+ if (!this._timer) this._timer = setTimeout(() => { this._timer = 0; this.scan(); }, 80);
10699
+ clearTimeout(this._late); this._late = setTimeout(() => this.scan(), 350);
10700
+ });
10642
10701
  this._obs.observe(root, { childList: true, subtree: true, characterData: true });
10643
10702
  this.scan();
10644
10703
  },
10645
10704
  stop() {
10646
10705
  this._obs?.disconnect(); this._obs = null; this._root = null;
10647
- clearTimeout(this._timer); this._timer = 0;
10706
+ clearTimeout(this._timer); this._timer = 0; clearTimeout(this._late);
10648
10707
  document.querySelectorAll('.nxu-dsub-src').forEach(n => n.classList.remove('nxu-dsub-src'));
10649
10708
  if (this._src && !SUBS.active()) SUBS._render('');
10650
- this._src = null; this._cands.clear();
10709
+ this._src = null; this._srcSig = null; this._cands.clear();
10651
10710
  },
10652
10711
  _text(el) { return String(el.innerText || el.textContent || '').replace(/[ \t]+/g, ' ').replace(/\n{2,}/g, '\n').trim().slice(0, 300); },
10653
10712
  scan() {
@@ -10658,16 +10717,27 @@ async function handle(m) {
10658
10717
  const cands = new Set();
10659
10718
  try { root.querySelectorAll(this.SEL).forEach(el => cands.add(el)); } catch (_) { }
10660
10719
  (CINEMA._textLayers || []).forEach(el => cands.add(el));
10720
+ // Many players (React and the like) draw each line as a new element: candidates are
10721
+ // followed by their place and look (tag, classes, parent), not by the element itself.
10722
+ const sigOf = (el) => `${el.tagName}|${el.className}|${el.parentElement?.className || ''}|${el.parentElement?.tagName || ''}`;
10723
+ if (this._srcSig) {
10724
+ const tag = this._srcSig.split('|')[0];
10725
+ const again = [...cands, ...root.getElementsByTagName(tag)].find(el => el.isConnected && !el.contains(v) && sigOf(el) === this._srcSig);
10726
+ if (again) { this._src = again; again.classList.add('nxu-dsub-src'); this._show(); return; }
10727
+ if (this._src && !this._src.isConnected) { this._src = null; if (!SUBS.active()) SUBS._render(''); }
10728
+ return;
10729
+ }
10661
10730
  const now = Date.now();
10662
10731
  for (const el of cands) {
10663
10732
  if (!el.isConnected || el.contains(v) || el.closest('.nxu-cue-mirror') || el.querySelector('button, input, svg, [role="slider"]')) continue;
10664
10733
  const txt = this._text(el);
10665
- const c = this._cands.get(el) || { last: null, changes: [], };
10734
+ const key = sigOf(el);
10735
+ const c = this._cands.get(key) || { last: null, changes: [], };
10666
10736
  if (txt !== c.last) { if (c.last !== null) c.changes.push(now); c.last = txt; }
10667
10737
  c.changes = c.changes.filter(ts => now - ts < 30000);
10668
- this._cands.set(el, c);
10738
+ this._cands.set(key, c);
10669
10739
  // Two changes of its text within half a minute: subtitles, not a title.
10670
- if (c.changes.length >= 2) { this._src = el; el.classList.add('nxu-dsub-src'); logDebug('Site subtitles shown in the NexusSync layer.', 'info'); this._show(); return; }
10740
+ if (c.changes.length >= 2) { this._src = el; this._srcSig = key; el.classList.add('nxu-dsub-src'); logDebug('Site subtitles shown in the NexusSync layer.', 'info'); this._show(); return; }
10671
10741
  }
10672
10742
  },
10673
10743
  _show() {
@@ -12563,7 +12633,7 @@ async function handle(m) {
12563
12633
  root.append(gesture, scrim, rippleL, rippleR, spinner, center, flash, scrub, top, bottom, menu, help);
12564
12634
  container.appendChild(root);
12565
12635
  this.root = root;
12566
- this.els = { gesture, scrim, rippleL, rippleR, flash, spinner, spinnerLabel, scrub, title, room, helpBtn, rotateBtn, modeBtn, exitBtn, center, cBack, cPlay, cFwd, bottom, seek, track, bufferBar, progress, pins, thumb, range, hover, playBtn, backBtn, fwdBtn, vol, muteBtn, volume, time, live, rateBtn, subBtn, viewBtn, fitBtn, ambientBtn, pipBtn, fsBtn, menu, help };
12636
+ this.els = { top, gesture, scrim, rippleL, rippleR, flash, spinner, spinnerLabel, scrub, title, room, helpBtn, rotateBtn, modeBtn, exitBtn, center, cBack, cPlay, cFwd, bottom, seek, track, bufferBar, progress, pins, thumb, range, hover, playBtn, backBtn, fwdBtn, vol, muteBtn, volume, time, live, rateBtn, subBtn, viewBtn, fitBtn, ambientBtn, pipBtn, fsBtn, menu, help };
12567
12637
 
12568
12638
  const stop = (e) => e.stopPropagation();
12569
12639
  [top, bottom, menu, help, center].forEach(el => el.addEventListener('pointerdown', stop));
@@ -12904,14 +12974,23 @@ async function handle(m) {
12904
12974
  this.els.help.classList.remove('open');
12905
12975
  menu.classList.toggle('open', open);
12906
12976
  menu.dataset.kind = 'sub';
12907
- if (!open) return;
12977
+ if (!open) { this._subAll = false; return; }
12908
12978
  const item = (label, sel, fn) => { const b = createEl('button', sel ? 'sel' : '', label, { type: 'button', role: 'menuitemradio' }); b.onclick = (ev) => { ev.stopPropagation(); fn(); }; return b; };
12909
12979
  const tracks = SUBS.tracks();
12910
12980
  const nothing = !SUBS.active() && !TRANSLATOR.active && !DOM_SUBS._src;
12911
12981
  const kids = [createEl('div', 'cc-menu-title', t('subMenu')),
12912
12982
  item(t('xsubOff'), nothing, () => { SUBS.off(); if (TRANSLATOR.active) TRANSLATOR.stop(t('subOff')); this.toggleSubMenu(false); })];
12913
12983
  // Several can be on at once (up to three): tap to add, tap again to take away.
12914
- tracks.forEach((tr, i) => kids.push(item('🎞 ' + (tr.label || tr.language || t('subTrack') + ' ' + (i + 1)), SUBS.hasTrack(tr), () => { SUBS.useTrack(tr); this.toggleSubMenu(true); })));
12984
+ const name = (tr, i) => tr.label || tr.language || t('subTrack') + ' ' + (i + 1);
12985
+ const seen = {}, total = {};
12986
+ tracks.forEach((tr, i) => { const n = name(tr, i); total[n] = (total[n] || 0) + 1; });
12987
+ const rows = tracks.map((tr, i) => { const n = name(tr, i); seen[n] = (seen[n] || 0) + 1; return { tr, label: total[n] > 1 ? `${n} ${seen[n]}` : n, rank: SUBS.hasTrack(tr) ? 0 : SUBS.langRank(tr), i }; });
12988
+ rows.sort((a, b) => a.rank - b.rank || a.i - b.i);
12989
+ // A long list (players offering 100+ tracks) shows your languages first, the rest on request.
12990
+ const fold = rows.length > 12 && !this._subAll;
12991
+ const shown = fold ? rows.filter(r => r.rank < 3) : rows;
12992
+ shown.forEach(r => kids.push(item('🎞 ' + r.label, SUBS.hasTrack(r.tr), () => { SUBS.useTrack(r.tr); this.toggleSubMenu(true); })));
12993
+ if (fold && shown.length < rows.length) kids.push(item(t('subMoreLangs', { n: rows.length - shown.length }), false, () => { this._subAll = true; this.toggleSubMenu(true); }));
12915
12994
  SUBS.layers.filter(l => l.kind === 'cues').forEach(l => kids.push(item('💬 ' + l.label, true, () => { SUBS.remove(l.id); this.toggleSubMenu(true); })));
12916
12995
  if (SUBS.layers.length > 1) kids.push(createEl('div', 'cc-menu-note', t('subMulti')));
12917
12996
  kids.push(item(t('subSearch'), false, () => { this.toggleSubMenu(false); OPENSUBS.open(); }));
@@ -13036,6 +13115,35 @@ async function handle(m) {
13036
13115
  return was;
13037
13116
  },
13038
13117
 
13118
+ // With the site's own controls, our two buttons (switch / exit) sit at the top right, where
13119
+ // many players keep theirs (cast, settings…). They step down below any site control there,
13120
+ // so neither covers the other.
13121
+ placeSiteBar() {
13122
+ const top = this.els?.top;
13123
+ if (!top) return;
13124
+ if (!STATE.isCinema || this.controlsMode() === 'nexus') { top.style.top = ''; return; }
13125
+ const now = Date.now();
13126
+ if (now - (this._barAt || 0) < 700) return;
13127
+ this._barAt = now;
13128
+ const boxes = [this.els.modeBtn, this.els.exitBtn].filter(b => b.getClientRects().length).map(b => b.getBoundingClientRect());
13129
+ if (!boxes.length) return;
13130
+ const host = document.getElementById('nxu-host');
13131
+ const from = Math.min(...boxes.map(r => r.left)) - 8, to = Math.max(...boxes.map(r => r.right)) + 8;
13132
+ const band = Math.min(140, innerHeight / 4);
13133
+ let low = 0;
13134
+ for (let x = Math.max(0, from); x <= Math.min(innerWidth - 1, to); x += 16) {
13135
+ for (let y = 2; y <= band; y += 10) {
13136
+ const el = document.elementsFromPoint(x, y).find(n => n !== host && !host?.contains(n));
13137
+ const c = el?.closest?.('button,a[href],[role="button"],select,input');
13138
+ if (!c) continue;
13139
+ const r = c.getBoundingClientRect();
13140
+ if (r.height < 90 && r.width < innerWidth / 2 && r.top < band) low = Math.max(low, r.bottom);
13141
+ }
13142
+ }
13143
+ const base = top.parentElement?.getBoundingClientRect().top || 0;
13144
+ top.style.top = low ? `${Math.round(low - base)}px` : '';
13145
+ },
13146
+
13039
13147
  // While paused (or a menu is open) the controls stay up instead of fading out.
13040
13148
  keepVisible() {
13041
13149
  if (!STATE.isCinema || !this.root || this.controlsMode() !== 'nexus') return false;
@@ -13069,7 +13177,10 @@ async function handle(m) {
13069
13177
  this.els.fsBtn.style.display = fullscreenSupported() ? '' : 'none';
13070
13178
  this.els.volume.style.display = IS_IOS ? 'none' : '';
13071
13179
  this.els.pipBtn.style.display = STATE.video && (document.pictureInPictureEnabled || typeof STATE.video.webkitSetPresentationMode === 'function') ? '' : 'none';
13072
- this.els.title.textContent = document.title || HOST;
13180
+ const msTitle = !MEDIA_SESSION._owned && navigator.mediaSession?.metadata?.title;
13181
+ this.els.title.textContent = msTitle || document.title || HOST;
13182
+ this._barAt = 0;
13183
+ this.placeSiteBar();
13073
13184
  if (!on) this._resetGestures();
13074
13185
  clearInterval(this._loop);
13075
13186
  this._loop = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kangsicj/nexussync",
3
- "version": "1.6.11",
3
+ "version": "1.6.12",
4
4
  "description": "Watch-together userscript: media sync, cinema mode, live AI subtitles, chat bubbles and quick ink for Violentmonkey, Tampermonkey and iOS Userscripts.",
5
5
  "keywords": [
6
6
  "userscript",