@kangsicj/nexussync 1.6.15 → 1.6.17

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.15
11
+ // @version 1.6.17
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.15
11
+ // @version 1.6.17
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.15';
49
+ const NXU_VERSION = '1.6.17';
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.15';
54
+ const NXU_RANK = '11.6.17';
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=';
@@ -249,7 +249,7 @@ async function handle(m) {
249
249
  'nxu_idle_timeout', 'nxu_sub_size', 'nxu_sub_opacity', 'nxu_sub_position', 'nxu_speaker_language',
250
250
  'nxu_subtitle_language', 'nxu_audio_mode', 'nxu_translation_provider', 'nxu_stt_local_first',
251
251
  'nxu_smart_speech_locale', 'nxu_fab_pos', 'nxu_asr_provider', 'nxu_key_openai', 'nxu_key_anthropic', 'nxu_key_groq', 'nxu_key_deepl',
252
- 'nxu_model_openai', 'nxu_model_anthropic', 'nxu_cinema_ambient', 'nxu_cinema_fit', 'nxu_cc_remaining', 'nxu_cinema_controls', 'nxu_nickname', 'nxu_color', 'nxu_quick_replies', 'nxu_chat_translate', 'nxu_sync_offset', 'nxu_cover_band', 'nxu_cover_marks', 'nxu_travel', 'nxu_auto_next', 'nxu_auto_cinema_sites', 'nxu_ad_guard', 'nxu_glossary', 'nxu_panel_size_chat-panel', 'nxu_panel_size_sub-log-panel', 'nxu_panel_size_debug-panel', 'nxu_panel_size_trans-modal', 'nxu_cinema_rotate', 'nxu_rotate_denied_' + HOST, 'nxu_resume', 'nxu_resume_on', 'nxu_sub_pick_' + HOST
252
+ 'nxu_model_openai', 'nxu_model_anthropic', 'nxu_cinema_ambient', 'nxu_cinema_fit', 'nxu_cc_remaining', 'nxu_cinema_controls', 'nxu_nickname', 'nxu_color', 'nxu_quick_replies', 'nxu_chat_translate', 'nxu_sync_offset', 'nxu_cover_band', 'nxu_cover_marks', 'nxu_travel', 'nxu_auto_next', 'nxu_auto_cinema_sites', 'nxu_ad_guard', 'nxu_glossary', 'nxu_panel_size_chat-panel', 'nxu_panel_size_sub-log-panel', 'nxu_panel_size_debug-panel', 'nxu_panel_size_trans-modal', 'nxu_cinema_rotate', 'nxu_rotate_denied_' + HOST, 'nxu_resume', 'nxu_resume_on', 'nxu_sub_pick_' + HOST, 'nxu_rate_' + HOST
253
253
  ]);
254
254
 
255
255
  // ───────────────────────── Cross-origin HTTP (GM xhr first, fetch fallback)
@@ -766,7 +766,7 @@ async function handle(m) {
766
766
  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).',
767
767
  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.',
768
768
  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',
769
- subLoaded: '💬 Subtitles: {name}', subMulti: 'Several subtitles at once — each dot is the colour of its lines on screen; tap one to take it away.', subNone: 'No subtitles found in this video.', subMoreLangs: '🌐 {n} more languages', subRestored: '💬 Subtitles picked again: {name}', resumeFrom: 'Continue from {time}', setResume: 'Offer to continue where I stopped', 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.',
769
+ subLoaded: '💬 Subtitles: {name}', subMulti: 'Several subtitles at once — each dot is the colour of its lines on screen; tap one to take it away.', subNone: 'No subtitles found in this video.', subMoreLangs: '🌐 {n} more languages', subRestored: '💬 Subtitles picked again: {name}', resumeFrom: 'Continue from {time}', rateRestored: '⏩ {rate}x — the speed you last used on this site (pick 1x to forget it)', setResume: 'Offer to continue where I stopped', 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.',
770
770
  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.',
771
771
  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).',
772
772
  settings: 'Settings', setProfile: 'Profile', setAvatar: 'Avatar', setStatus: 'Status message', setStatusPh: 'e.g. Popcorn ready 🍿', setReactions: 'My reactions',
@@ -893,7 +893,7 @@ async function handle(m) {
893
893
  tuneSrcSame: '🟢 모두 같은 영상이에요 — 프레임 단위로 자동으로 맞추고 있어요.', tuneSrcDiff: '🟠 서로 다른 버전이에요 (길이 차이 {s}) — 잠시 재생하면 자동으로 맞추고, 여기서 직접 맞출 수도 있어요.', tuneSrcUnknown: '다른 사람의 영상 정보를 기다리는 중…', tuneSrcShifted: '🟠 길이는 같지만 장면이 달라요 — 재생하는 동안 자동으로 맞추고, 여기서 직접 맞출 수도 있어요.', tuneDiffPicture: '시간은 같지만 화면이 달라요', tuneShiftFound: '길이는 같지만 장면이 달라서 타이밍을 {s} 자동 보정했어요 (누르면 되돌리기).',
894
894
  tuneSameReset: '⏱ 상대와 같은 영상이라 타이밍 보정을 해제했어요.', tuneAutoApplied: '다른 버전이라 타이밍을 {s} 자동 보정했어요 (누르면 되돌리기).', tuneSuggest: '서로 영상 길이가 {s} 달라요. 눌러서 맞춰 보세요.',
895
895
  subMenu: '자막', xsubOff: '끄기', subTrack: '영상에 포함된 자막', subSearch: '🔎 자막 찾기 (OpenSubtitles)', subFile: '📂 자막 파일 열기…', subAi: '🧠 AI 실시간 자막', subDelay: '싱크', subLater: '늦게', subEarlier: '빠르게', xsubSize: '크기',
896
- subLoaded: '💬 자막: {name}', subMulti: '자막 여러 개를 함께 보는 중 — 점 색이 화면 자막 색이에요. 누르면 그 자막만 꺼져요.', subNone: '이 영상에는 포함된 자막이 없어요.', subMoreLangs: '🌐 다른 언어 {n}개 더 보기', subRestored: '💬 지난번 자막을 다시 켰어요: {name}', resumeFrom: '{time}부터 이어보기', setResume: '보던 곳부터 이어보기 제안', subSiteOnly: '이 사이트는 자기 메뉴에서만 이 자막을 불러와요. 오른쪽 위에서 사이트 컨트롤로 바꾼 뒤 거기서 골라 주세요.', subSuggest: '💬 자막이 없나요? 찾아보기', subLoadFail: '자막을 불러오지 못했어요.',
896
+ subLoaded: '💬 자막: {name}', subMulti: '자막 여러 개를 함께 보는 중 — 점 색이 화면 자막 색이에요. 누르면 그 자막만 꺼져요.', subNone: '이 영상에는 포함된 자막이 없어요.', subMoreLangs: '🌐 다른 언어 {n}개 더 보기', subRestored: '💬 지난번 자막을 다시 켰어요: {name}', resumeFrom: '{time}부터 이어보기', rateRestored: '⏩ {rate}x — 이 사이트에서 마지막으로 쓴 속도예요 (1x를 고르면 잊어요)', setResume: '보던 곳부터 이어보기 제안', subSiteOnly: '이 사이트는 자기 메뉴에서만 이 자막을 불러와요. 오른쪽 위에서 사이트 컨트롤로 바꾼 뒤 거기서 골라 주세요.', subSuggest: '💬 자막이 없나요? 찾아보기', subLoadFail: '자막을 불러오지 못했어요.',
897
897
  osTitle: '자막 찾기', osTmdbLooking: 'TMDB에서 영어 제목을 찾는 중…', osTmdbNone: 'TMDB에서 영어 제목을 찾지 못했어요 — 알고 있다면 직접 입력하세요.', osQuery: '제목 (영어 제목이 가장 잘 찾아져요)', osSeason: '시즌', osEpisode: '회차', osLang: '언어', osSearch: '검색', osSearching: '찾는 중…', osNone: '찾지 못했어요. 영어 제목으로 바꾸거나 연도를 빼 보세요.', osError: 'OpenSubtitles가 응답하지 않아요. 잠시 후 다시 시도하세요.', osDownloads: '다운로드 {n}회', osLoading: '불러오는 중…', osHint: '자막은 OpenSubtitles.org에서 가져와 NexusSync 스타일로 보여 줘요. 빠르거나 늦으면 자막 메뉴의 “싱크”로 맞추세요.',
898
898
  viewMenu: '화면', viewAudio: '오디오 트랙', viewBright: '밝기', viewBoost: '볼륨 부스트', viewReset: '초기화', boostBlocked: '이 영상은 다른 사이트에서 오는 소리라 여기서 키울 수 없어요.',
899
899
  settings: '설정', setProfile: '프로필', setAvatar: '아바타', setStatus: '상태 메시지', setStatusPh: '예: 팝콘 준비 완료 🍿', setReactions: '내 리액션',
@@ -1279,7 +1279,8 @@ async function handle(m) {
1279
1279
  visibility: hidden !important; pointer-events: none !important; transition: none !important; animation: none !important; }
1280
1280
  .nxu-site-ui-off :is([class*="caption" i], [class*="subtitle" i], [class*="text-track" i], [class*="cue" i], [class*="danmaku" i]) { visibility: visible !important; }
1281
1281
  .nxu-site-ui-off .nxu-site-hide { visibility: hidden !important; pointer-events: none !important; transition: none !important; animation: none !important; }
1282
- .nxu-site-ui-off .nxu-dsub-src, .nxu-site-ui-off .nxu-dsub-src * { visibility: hidden !important; }
1282
+ /* Hidden by opacity (not visibility): what the site itself shows or hides inside can still be read. */
1283
+ .nxu-site-ui-off .nxu-dsub-src { opacity: 0 !important; clip-path: inset(100%) !important; pointer-events: none !important; transition: none !important; animation: none !important; }
1283
1284
  .nxu-cue-mirror { position: absolute !important; left: calc(50% + var(--nxu-cue-shift, 0px)) !important; right: auto !important; top: auto !important; bottom: var(--nxu-cue-bottom, 6%) !important; transform: translateX(-50%) !important;
1284
1285
  width: var(--nxu-cue-width, 90%) !important; max-width: 96% !important; height: auto !important; margin: 0 !important; padding: 0 !important; border: 0 !important; background: none !important;
1285
1286
  flex-direction: column !important; align-items: center !important; gap: 3px !important; z-index: 2147483646 !important; transition: bottom 0.3s ease !important; pointer-events: none !important; visibility: visible !important; opacity: 1 !important; }
@@ -1426,7 +1427,8 @@ async function handle(m) {
1426
1427
  _startAmbient(video, root) {
1427
1428
  this._stopAmbient();
1428
1429
  this._ambientPaused = false;
1429
- if (!video || !root || !this.ambientEnabled()) return;
1430
+ if (!video || !root || !this.ambientEnabled() || (this._ambientBlocked && this._ambientBlockedFor === video)) return;
1431
+ this._ambientBlocked = false; this._ambientBlockedFor = video; this._layerBelow = false;
1430
1432
  try { if (video.mediaKeys || video.webkitKeys) return; } catch (_) { } // DRM video always draws black
1431
1433
  const doc = video.ownerDocument;
1432
1434
  if (root.getRootNode() !== doc) return; // player inside a site's shadow DOM: our styles can't reach it
@@ -1455,6 +1457,8 @@ async function handle(m) {
1455
1457
  this._matchLayerZ(layer, root);
1456
1458
  const cleared = new Map();
1457
1459
  this._clearBackdrops(video, root, cleared);
1460
+ setTimeout(() => this._guardGlow(), 60);
1461
+ setTimeout(() => this._guardGlow(), 900);
1458
1462
  // Reading a video frame is the costly part (it was almost all of cinema's CPU time at
1459
1463
  // 16 a second). Six a second with a stronger blend looks the same: the glow eases
1460
1464
  // between scenes anyway, and a cut still shows within a fraction of a second.
@@ -1574,10 +1578,50 @@ async function handle(m) {
1574
1578
  try {
1575
1579
  const z = (root.ownerDocument.defaultView || window).getComputedStyle(root).zIndex;
1576
1580
  // One below the root (never level with it: some layouts then drew the glow on top).
1577
- const want = /^-?\d+$/.test(z) ? String(Math.max(-2147483647, Number(z) - 1)) : '0';
1581
+ const cs = (root.ownerDocument.defaultView || window).getComputedStyle(root);
1582
+ // A root that is not positioned ignores its z-index: any positioned layer at 0 or
1583
+ // more would be drawn over it (the whole picture looked blurred), so the glow goes below.
1584
+ const want = this._layerBelow || cs.position === 'static' ? '-1' : /^-?\d+$/.test(z) ? String(Math.max(-2147483647, Number(z) - 1)) : '0';
1578
1585
  if (layer.style.getPropertyValue('z-index') !== want) layer.style.setProperty('z-index', want, 'important');
1579
1586
  } catch (_) { }
1580
1587
  },
1588
+ // Is the glow drawn over the picture? Asked of the browser itself (what is on top at the
1589
+ // middle of the video), whatever the page's layout does. The glow and the video are
1590
+ // made hit-testable for the question only.
1591
+ _glowCoversVideo(a) {
1592
+ const doc = a.video.ownerDocument;
1593
+ const r = a.video.getBoundingClientRect();
1594
+ if (r.width < 40 || r.height < 40 || typeof doc.elementsFromPoint !== 'function') return false;
1595
+ const view = doc.defaultView || window;
1596
+ const x = Math.min(view.innerWidth - 2, Math.max(1, r.left + r.width / 2)), y = Math.min(view.innerHeight - 2, Math.max(1, r.top + r.height / 2));
1597
+ const keepL = a.layer.style.getPropertyValue('pointer-events'), prioL = a.layer.style.getPropertyPriority('pointer-events');
1598
+ const keepV = a.video.style.getPropertyValue('pointer-events'), prioV = a.video.style.getPropertyPriority('pointer-events');
1599
+ let covers = false;
1600
+ try {
1601
+ a.layer.style.setProperty('pointer-events', 'auto', 'important');
1602
+ a.video.style.setProperty('pointer-events', 'auto', 'important');
1603
+ const hits = doc.elementsFromPoint(x, y);
1604
+ const li = hits.indexOf(a.layer), vi = hits.indexOf(a.video);
1605
+ covers = li !== -1 && vi !== -1 && li < vi;
1606
+ } catch (_) { }
1607
+ if (keepL) a.layer.style.setProperty('pointer-events', keepL, prioL); else a.layer.style.removeProperty('pointer-events');
1608
+ if (keepV) a.video.style.setProperty('pointer-events', keepV, prioV); else a.video.style.removeProperty('pointer-events');
1609
+ return covers;
1610
+ },
1611
+ // Checked shortly after the glow starts and while cinema is on: first it is put below
1612
+ // everything; if the page still draws it over the picture, it is switched off here.
1613
+ _guardGlow() {
1614
+ const a = this._ambient;
1615
+ if (!a || !this._glowCoversVideo(a)) return;
1616
+ if (!this._layerBelow) {
1617
+ this._layerBelow = true;
1618
+ this._matchLayerZ(a.layer, a.root);
1619
+ if (!this._glowCoversVideo(a)) { logDebug('Ambient light moved below the page (it was drawn over the picture).', 'info'); return; }
1620
+ }
1621
+ logDebug('Ambient light off for this player: the page draws it over the picture.', 'warn');
1622
+ this._stopAmbient();
1623
+ this._ambientBlocked = true;
1624
+ },
1581
1625
  _ambientMisplaced(a) {
1582
1626
  return !a.layer.isConnected || !a.root.classList.contains('nxu-ambient-on') ||
1583
1627
  (a.root.parentNode && a.root.parentNode.nodeType === 1 && a.layer.nextSibling !== a.root);
@@ -1796,7 +1840,7 @@ async function handle(m) {
1796
1840
  // The site may fade or blur its video later (e.g. once it starts playing).
1797
1841
  const why = this._seeThrough(a.video, a.root);
1798
1842
  if (why) { logDebug('Ambient light off for this player: ' + why, 'info'); this._stopAmbient(); this._ambientPaused = true; }
1799
- else { this._matchLayerZ(a.layer, a.root); this._clearBackdrops(a.video, a.root, a.cleared); }
1843
+ else { this._matchLayerZ(a.layer, a.root); this._clearBackdrops(a.video, a.root, a.cleared); this._guardGlow(); }
1800
1844
  } else if (this._ambientPaused && this.ambientEnabled() && this.applied.video && this.applied.chain[0]?.root && Date.now() - (this._ambientTry || 0) > 2000) {
1801
1845
  this._ambientTry = Date.now();
1802
1846
  // Turned off only while the site faded or covered its picture (loading,
@@ -5098,7 +5142,7 @@ async function handle(m) {
5098
5142
  f.setAttribute('aria-hidden', 'true');
5099
5143
  f.tabIndex = -1;
5100
5144
  f.style.cssText = 'position:fixed;width:1px;height:1px;left:-10px;top:-10px;border:0;opacity:0;pointer-events:none;';
5101
- const timer = setTimeout(() => { this._ready = null; f.remove(); reject(Object.assign(new Error('helper frame did not answer'), { code: 'helper' })); }, 12000);
5145
+ const timer = setTimeout(() => { this._ready = null; window.removeEventListener('message', onMsg); f.remove(); this._frame = null; reject(Object.assign(new Error('helper frame did not answer'), { code: 'helper' })); }, 12000);
5102
5146
  const onMsg = (e) => {
5103
5147
  const m = e.data;
5104
5148
  if (!m || m.nxuWhisper !== this._token || e.source !== f.contentWindow) return;
@@ -10895,7 +10939,7 @@ async function handle(m) {
10895
10939
  const root = STATE.isCinema && CINEMA.nexusControls() && CINEMA.applied?.chain?.[0]?.root;
10896
10940
  const v = CINEMA.applied?.video;
10897
10941
  if (!root || !v || root === v || root.ownerDocument !== document) { this.stop(); return; }
10898
- if (this._root === root) return;
10942
+ if (this._root === root) { this.scan(); return; } // (also once a second: silence and moves are noticed without a redraw)
10899
10943
  this.stop();
10900
10944
  this._root = root;
10901
10945
  // Scanned again a little later too: the list of the player's text layers is refreshed
@@ -10912,39 +10956,78 @@ async function handle(m) {
10912
10956
  clearTimeout(this._timer); this._timer = 0; clearTimeout(this._late);
10913
10957
  document.querySelectorAll('.nxu-dsub-src').forEach(n => n.classList.remove('nxu-dsub-src'));
10914
10958
  if (this._src && !SUBS.active()) SUBS._render('');
10915
- this._src = null; this._srcSig = null; this._cands.clear();
10959
+ this._src = null; this._srcSig = null; this._srcParent = null; this._otherAt = 0; clearTimeout(this._otherTimer); this._cands.clear();
10960
+ },
10961
+ // The text the site is showing in it right now. Lines the site keeps in the page but
10962
+ // hides (earlier cues left with display:none) are not read: innerText is what is
10963
+ // rendered. Only inside something this script hid itself is the raw text used.
10964
+ _text(el) {
10965
+ const mine = el.closest('.nxu-site-hide');
10966
+ // (An element the site took out of the layout reports all its text as innerText.)
10967
+ if (!mine && !el.getClientRects().length) return '';
10968
+ const raw = mine ? el.textContent : el.innerText ?? el.textContent;
10969
+ return String(raw || '').replace(/[ \t]+/g, ' ').replace(/\n{2,}/g, '\n').trim().slice(0, 300);
10916
10970
  },
10917
- _text(el) { return String(el.innerText || el.textContent || '').replace(/[ \t]+/g, ' ').replace(/\n{2,}/g, '\n').trim().slice(0, 300); },
10918
10971
  scan() {
10919
10972
  const root = this._root;
10920
10973
  if (!root || !root.isConnected) { this.stop(); return; }
10921
- if (this._src && this._src.isConnected) { this._show(); return; }
10922
10974
  const v = CINEMA.applied?.video;
10923
10975
  const cands = new Set();
10924
10976
  try { root.querySelectorAll(this.SEL).forEach(el => cands.add(el)); } catch (_) { }
10925
10977
  (CINEMA._textLayers || []).forEach(el => cands.add(el));
10978
+ const ok = (el) => el.isConnected && !el.contains(v) && !el.closest('.nxu-cue-mirror') && !el.querySelector('button, input, svg, [role="slider"]');
10926
10979
  // Many players (React and the like) draw each line as a new element: candidates are
10927
10980
  // followed by their place and look (tag, classes, parent), not by the element itself.
10928
- const sigOf = (el) => `${el.tagName}|${el.className}|${el.parentElement?.className || ''}|${el.parentElement?.tagName || ''}`;
10929
- if (this._srcSig) {
10930
- const tag = this._srcSig.split('|')[0];
10931
- const again = [...cands, ...root.getElementsByTagName(tag)].find(el => el.isConnected && !el.contains(v) && sigOf(el) === this._srcSig);
10932
- if (again) { this._src = again; again.classList.add('nxu-dsub-src'); this._show(); return; }
10933
- if (this._src && !this._src.isConnected) { this._src = null; if (!SUBS.active()) SUBS._render(''); }
10934
- return;
10935
- }
10981
+ const sigOf = (el) => `${el.tagName}|${String(el.className).replace(/\s*nxu-[\w-]+/g, '')}|${el.parentElement?.className || ''}|${el.parentElement?.tagName || ''}`;
10936
10982
  const now = Date.now();
10983
+ // Every candidate's text changes are noted (subtitles change, titles and watermarks do not).
10984
+ const live = [];
10937
10985
  for (const el of cands) {
10938
- if (!el.isConnected || el.contains(v) || el.closest('.nxu-cue-mirror') || el.querySelector('button, input, svg, [role="slider"]')) continue;
10939
- const txt = this._text(el);
10940
- const key = sigOf(el);
10941
- const c = this._cands.get(key) || { last: null, changes: [], };
10986
+ if (!ok(el)) continue;
10987
+ const key = sigOf(el), txt = this._text(el);
10988
+ const c = this._cands.get(key) || { last: null, changes: [] };
10942
10989
  if (txt !== c.last) { if (c.last !== null) c.changes.push(now); c.last = txt; }
10943
10990
  c.changes = c.changes.filter(ts => now - ts < 30000);
10944
10991
  this._cands.set(key, c);
10945
- // Two changes of its text within half a minute: subtitles, not a title.
10946
- 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; }
10992
+ live.push({ el, key, txt, c });
10947
10993
  }
10994
+ const claim = (el, key) => {
10995
+ if (this._src && this._src !== el) this._src.classList?.remove('nxu-dsub-src');
10996
+ this._src = el; this._srcSig = key; this._srcParent = el.parentElement;
10997
+ el.classList.add('nxu-dsub-src');
10998
+ };
10999
+ // 1. The source found before: the same element, one that looks the same, or the new
11000
+ // child of the same parent (a line redrawn with other class names).
11001
+ let src = this._src && this._src.isConnected ? this._src : null;
11002
+ if (!src && this._srcSig) {
11003
+ const tag = this._srcSig.split('|')[0];
11004
+ src = [...cands, ...root.getElementsByTagName(tag)].find(el => ok(el) && sigOf(el) === this._srcSig)
11005
+ || (this._srcParent?.isConnected ? [...this._srcParent.children].find(el => el.tagName === tag && ok(el) && this._text(el)) : null) || null;
11006
+ if (src) claim(src, this._srcSig);
11007
+ else if (this._src) { this._src = null; }
11008
+ }
11009
+ if (src && !src.classList.contains('nxu-dsub-src')) src.classList.add('nxu-dsub-src'); // a redraw reset its classes
11010
+ if (src && this._text(src)) { this._otherAt = 0; this._show(); return; }
11011
+ // 2. Found before but silent now. If the site meanwhile shows changing text somewhere
11012
+ // else (it redrew its subtitles into another element — after fullscreen, a quality
11013
+ // switch…), follow it there: its subtitles are never left hidden and unshown.
11014
+ if (this._srcSig) {
11015
+ const other = live.find(x => x.el !== src && !(src && (src.contains(x.el) || x.el.contains(src))) && x.txt && x.c.changes.length && now - x.c.changes[x.c.changes.length - 1] < 15000);
11016
+ if (!other) this._otherAt = 0;
11017
+ else if (!this._otherAt) { this._otherAt = now; clearTimeout(this._otherTimer); this._otherTimer = setTimeout(() => this.scan(), 1300); }
11018
+ else if (now - this._otherAt >= 1200) {
11019
+ this._otherAt = 0;
11020
+ claim(other.el, other.key);
11021
+ logDebug('Site subtitles moved to another element; following them.', 'info');
11022
+ this._show();
11023
+ return;
11024
+ }
11025
+ if (!SUBS.active()) SUBS._render('');
11026
+ return;
11027
+ }
11028
+ // 3. Nothing found yet: two changes of a text within half a minute are subtitles, not a title.
11029
+ const hit = live.find(x => x.c.changes.length >= 2);
11030
+ if (hit) { claim(hit.el, hit.key); logDebug('Site subtitles shown in the NexusSync layer.', 'info'); this._show(); }
10948
11031
  },
10949
11032
  _show() {
10950
11033
  if (SUBS.active()) return; // the user picked other subtitles
@@ -11357,6 +11440,29 @@ async function handle(m) {
11357
11440
  } catch (_) { }
11358
11441
  }, 1200);
11359
11442
 
11443
+ // ───────────────────────── Speed per site
11444
+ // The speed you pick in the speed menu is kept per site and used again for the next video
11445
+ // there when you watch on your own (in a room the room's speed rules). 1x forgets it.
11446
+ const RATE_MEMORY = {
11447
+ key() { return 'nxu_rate_' + HOST; },
11448
+ save(rate) { STORE.set(this.key(), Math.abs(rate - 1) < 0.01 ? 0 : +rate.toFixed(2)); },
11449
+ _seen: new WeakSet(),
11450
+ watch(v) {
11451
+ if (!IS_TOP || !v || this._seen.has(v)) return;
11452
+ this._seen.add(v);
11453
+ const apply = () => {
11454
+ const r = Number(STORE.get(this.key(), 0));
11455
+ if (!(r >= 0.25 && r <= 4) || Math.abs(r - 1) < 0.01 || STATE.handshakeVerified || v !== STATE.video) return;
11456
+ if (Math.abs((v.playbackRate || 1) - 1) > 0.01) return; // the site set its own speed
11457
+ RATE.apply(v, r);
11458
+ updateRateButton();
11459
+ showToast(t('rateRestored', { rate: r }));
11460
+ logDebug(`Speed ${r}x used again on this site.`, 'info');
11461
+ };
11462
+ if (v.readyState >= 1) setTimeout(apply, 300); else v.addEventListener('loadedmetadata', () => setTimeout(apply, 300), { once: true });
11463
+ }
11464
+ };
11465
+
11360
11466
  // ───────────────────────── Continue watching
11361
11467
  // Where you stopped in a long video (5 min+) is kept per page, and when you open that page
11362
11468
  // again on your own (not in a room) a small card offers to continue from there — only an
@@ -11424,8 +11530,10 @@ async function handle(m) {
11424
11530
  v.addEventListener('timeupdate', watch);
11425
11531
  }
11426
11532
  };
11427
- window.addEventListener('pagehide', () => { try { if (STATE.video) RESUME.save(STATE.video); } catch (_) { } });
11428
- document.addEventListener('visibilitychange', () => { try { if (document.hidden && STATE.video) RESUME.save(STATE.video); } catch (_) { } });
11533
+ if (IS_TOP) {
11534
+ window.addEventListener('pagehide', () => { try { if (STATE.video) RESUME.save(STATE.video); } catch (_) { } });
11535
+ document.addEventListener('visibilitychange', () => { try { if (document.hidden && STATE.video) RESUME.save(STATE.video); } catch (_) { } });
11536
+ }
11429
11537
 
11430
11538
  // ───────────────────────── Next episode
11431
11539
  // On series pages (drama/anime sites) the page usually has a "next episode" link or
@@ -13292,7 +13400,7 @@ async function handle(m) {
13292
13400
  };
13293
13401
  menu.replaceChildren(createEl('div', 'cc-menu-title', t('ccSpeed')), ...[0.5, 0.75, 1, 1.25, 1.5, 1.75, 2].map(r => {
13294
13402
  const item = createEl('button', Math.abs(r - current) < 0.01 ? 'sel' : '', r === 1 ? t('ccNormal') : `${r}x`, { type: 'button', role: 'menuitemradio' });
13295
- item.onclick = () => { setSharedRate(r); this.toggleRateMenu(false); this._poke(); };
13403
+ item.onclick = () => { setSharedRate(r); if (!STATE.handshakeVerified) RATE_MEMORY.save(r); this.toggleRateMenu(false); this._poke(); };
13296
13404
  return item;
13297
13405
  }), createEl('div', 'cc-menu-title', '😴 ' + t('sleepTitle') + (SLEEP.active() ? ' · ' + SLEEP.label() : '')),
13298
13406
  sleepItem(t('sleepNone'), 0, !SLEEP.active()), sleepItem(t('sleepMin', { n: 15 }), 15, false), sleepItem(t('sleepMin', { n: 30 }), 30, false),
@@ -13463,8 +13571,11 @@ async function handle(m) {
13463
13571
  if (!top) return;
13464
13572
  if (!STATE.isCinema || this.controlsMode() === 'nexus') { top.style.top = ''; return; }
13465
13573
  const now = Date.now();
13466
- if (now - (this._barAt || 0) < 700) return;
13574
+ const sizeKey = innerWidth + 'x' + innerHeight;
13575
+ // ~150 hit tests: redone when the window changes size, otherwise at most every 3 s.
13576
+ if (now - (this._barAt || 0) < (sizeKey === this._barSize ? 3000 : 250)) return;
13467
13577
  this._barAt = now;
13578
+ this._barSize = sizeKey;
13468
13579
  const boxes = [this.els.modeBtn, this.els.exitBtn].filter(b => b.getClientRects().length).map(b => b.getBoundingClientRect());
13469
13580
  if (!boxes.length) return;
13470
13581
  const host = document.getElementById('nxu-host');
@@ -14107,7 +14218,7 @@ async function handle(m) {
14107
14218
  if (!IS_TOP) this._hookBridgeVideo(nextVideo);
14108
14219
  if (STATE.isCinema) keepInline(nextVideo);
14109
14220
  if (STATE.handshakeVerified) attachVideoHooks();
14110
- if (IS_TOP) { try { SUB_MEMORY.watch(nextVideo); } catch (_) { } try { RESUME.watch(nextVideo); } catch (_) { } }
14221
+ if (IS_TOP) { try { SUB_MEMORY.watch(nextVideo); } catch (_) { } try { RESUME.watch(nextVideo); } catch (_) { } try { RATE_MEMORY.watch(nextVideo); } catch (_) { } }
14111
14222
  } else if (nextFrame) {
14112
14223
  logDebug('Media: player inside embedded frame ' + String(nextFrame.src || '').slice(0, 60), 'success');
14113
14224
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kangsicj/nexussync",
3
- "version": "1.6.15",
3
+ "version": "1.6.17",
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",