@kangsicj/nexussync 1.2.1 โ†’ 1.3.1

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.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <br>
6
6
 
7
- [![Version](https://img.shields.io/badge/version-1.2.1-7C4DFF?style=for-the-badge)](./CHANGELOG.md)
7
+ [![Version](https://img.shields.io/badge/version-1.3.1-7C4DFF?style=for-the-badge)](./CHANGELOG.md)
8
8
  [![Tampermonkey](https://img.shields.io/badge/Tampermonkey-PC%20%C2%B7%20Android-00485B?style=for-the-badge&logo=tampermonkey&logoColor=white)](https://www.tampermonkey.net/)
9
9
  [![iOS Safari](https://img.shields.io/badge/Userscripts-iPhone%20%C2%B7%20iPad-0A84FF?style=for-the-badge&logo=safari&logoColor=white)](https://apps.apple.com/app/userscripts/id1463298887)
10
10
  [![Sponsor](https://img.shields.io/badge/Fairy-Sponsor-FF6FB5?style=for-the-badge&logo=githubsponsors&logoColor=white)](https://fairy.hada.io/@jinny)
@@ -61,7 +61,7 @@ Draw a quick circle around that actor and it glows on everyone's screen โ€” on t
61
61
  <td valign="top">
62
62
 
63
63
  ### ๐Ÿง  Live AI subtitles
64
- No subtitles on that video? Turn on live speech recognition with translation into your language, with a glossary for names and terms so characters are always spelled right.
64
+ No subtitles on that video? Pick your language, choose **video sound** and press Start โ€” NexusSync listens to the video itself and writes live, translated subtitles, with a glossary so names are always spelled right.
65
65
 
66
66
  </td>
67
67
  </tr>
@@ -71,6 +71,7 @@ No subtitles on that video? Turn on live speech recognition with translation int
71
71
 
72
72
  - **Next episode, together** โ€” move on to the next episode and you stay in the room; friends follow with one tap. Near the end, an *Up next* card counts down and opens it for you.
73
73
  - **Cinema by itself** โ€” open a page with one movie or episode and it switches to cinema as soon as the video is ready, keeping the site's player so you can still pick subtitles or a server. Turn it off per site.
74
+ - **See who's here** โ€” everyone in the room is listed by name and colour, with a ๐Ÿ’ค when someone's screen is off.
74
75
  - **Make it yours** โ€” pick your name and colour; your bubbles and doodles wear it on every screen.
75
76
  - **Calm, never jumpy** โ€” phones going to sleep, slow Wi-Fi or a player restarting on its own never pause the whole room.
76
77
  - **No accidental pauses** โ€” tapping the chat, a doodle or a reaction never nudges the video for anyone.
@@ -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.2.1
11
+ // @version 1.3.1
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.2.1
11
+ // @version 1.3.1
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 *://*/*
@@ -43,12 +43,12 @@
43
43
 
44
44
  // The version of the code that is actually running (the manager's metadata can lag
45
45
  // behind when an old copy is still installed).
46
- const NXU_VERSION = '1.2.1';
46
+ const NXU_VERSION = '1.3.1';
47
47
  // Rank used by the one-instance guard below and to tell newer builds apart in a room.
48
48
  // It is independent of the public version (1.0.0 is the first public release, after
49
49
  // private builds that reached ranks up to 10.2.0), so every older copy still installed
50
50
  // steps aside instead of this release.
51
- const NXU_RANK = '11.2.1';
51
+ const NXU_RANK = '11.3.1';
52
52
  const NXU_SESSION = Math.random().toString(36).slice(2, 10); // this page load // raise with every release
53
53
  // App icon (same artwork as assets/icon.svg / @icon), inlined so it shows offline too.
54
54
  const NXU_ICON = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2IiByb2xlPSJpbWciIGFyaWEtbGFiZWw9Ik5leHVzU3luYyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJueGJnIiB4MT0iMCIgeTE9IjAiIHgyPSIxIiB5Mj0iMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjNWIyZWZmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmY0ZmEzIi8+PC9saW5lYXJHcmFkaWVudD48cmFkaWFsR3JhZGllbnQgaWQ9Im54Z2xvdyIgY3g9IjAuODIiIGN5PSIwLjE0IiByPSIwLjciPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzdjZjlmZiIgc3RvcC1vcGFjaXR5PSIwLjU1Ii8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjN2NmOWZmIiBzdG9wLW9wYWNpdHk9IjAiLz48L3JhZGlhbEdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0ibnhwbGF5IiB4MT0iMCIgeTE9IjAiIHgyPSIxIiB5Mj0iMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZmZmZmZmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmZlM2YxIi8+PC9saW5lYXJHcmFkaWVudD48Y2xpcFBhdGggaWQ9Im54ciI+PHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIHJ4PSI1OCIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNueHIpIj48cmVjdCB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgZmlsbD0idXJsKCNueGJnKSIvPjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSJ1cmwoI254Z2xvdykiLz48ZyBmaWxsPSJub25lIiBzdHJva2U9IiNmZmZmZmYiIHN0cm9rZS13aWR0aD0iMTUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTYwIDExNiBBNzAgNzAgMCAwIDEgMTc4IDcyIi8+PHBhdGggZD0iTTE5NiAxNDAgQTcwIDcwIDAgMCAxIDc4IDE4NCIvPjwvZz48cGF0aCBkPSJNMTg2IDUwIEwyMDAgOTIgTDE1NyA4NiBaIiBmaWxsPSIjZmZmZmZmIi8+PHBhdGggZD0iTTcwIDIwNiBMNTYgMTY0IEw5OSAxNzAgWiIgZmlsbD0iI2ZmZmZmZiIvPjxwYXRoIGQ9Ik0xMTAgOTIgUTEwNCA4OCAxMDQgOTYgTDEwNCAxNjAgUTEwNCAxNjggMTEwIDE2NCBMMTYyIDEzMiBRMTY4IDEyOCAxNjIgMTI0IFoiIGZpbGw9InVybCgjbnhwbGF5KSIvPjwvZz48L3N2Zz4=';
@@ -322,7 +322,7 @@
322
322
  const bool = v => v === undefined || typeof v === 'boolean';
323
323
  switch (data.type) {
324
324
  case 'NXU_VIDEO_FOUND':
325
- return num(data.videoW) && num(data.videoH) && (num(data.duration) || data.duration === undefined) && bool(data.paused) && bool(data.playing);
325
+ return num(data.videoW) && num(data.videoH) && (num(data.duration) || data.duration === undefined) && bool(data.paused) && bool(data.playing) && bool(data.live);
326
326
  case 'NXU_VIDEO_LOST':
327
327
  case 'NXU_ACTIVITY':
328
328
  case 'NXU_CINEMA_EXIT_REQ':
@@ -330,7 +330,7 @@
330
330
  return true;
331
331
  case 'NXU_VIDEO_EVENT':
332
332
  return ['play', 'pause', 'seeked', 'ratechange', 'timeupdate', 'waiting', 'canplay', 'volume'].includes(data.event) &&
333
- num(data.currentTime) && num(data.playbackRate) && typeof data.paused === 'boolean' && str(data.remoteEventId);
333
+ num(data.currentTime) && num(data.playbackRate) && typeof data.paused === 'boolean' && str(data.remoteEventId) && bool(data.live);
334
334
  case 'NXU_FULLSCREEN_STATE':
335
335
  return typeof data.active === 'boolean';
336
336
  case 'NXU_HOTKEY':
@@ -671,17 +671,30 @@
671
671
  subtitleLanguage: 'Translate subtitles to', audioSource: 'Audio source', audioAuto: 'Auto (video audio when possible + mic)', audioMic: 'Microphone only',
672
672
  audioMedia: 'Video / tab audio only', audioDual: 'Microphone + video audio',
673
673
  audioHelp: 'Auto listens to the page video directly when the browser allows it, otherwise through the microphone (turn the speaker volume up).',
674
+ heardSound: 'What to listen to', srcMedia: '๐ŸŽฌ Video sound (recommended)', srcMic: '๐ŸŽค Microphone',
675
+ srcMediaHelp: 'Listens to the video itself โ€” no speakers needed. If the browser asks what to share, pick this tab and turn on โ€œShare tab audioโ€.',
676
+ srcMicHelp: 'Listens through the microphone: play the video out loud through the speakers (not headphones).',
677
+ srcIosHelp: 'On iPhone and iPad, Safari can only listen through the microphone โ€” play the video through the speaker.',
678
+ videoLanguage: 'Language spoken in the video', subtitleLanguageReq: 'Subtitle language (required)', chooseLanguage: 'โ€” Choose a language โ€”',
679
+ subPickLanguage: 'Choose the subtitle language first.', subAskMic: '๐ŸŽค Tap โ€œAllowโ€ when the browser asks for the microphone.',
680
+ subAskTab: '๐ŸŽฌ Choose this tab and turn on โ€œShare tab audioโ€, then press Share.',
681
+ subMicBlockedSite: 'This site does not allow the microphone โ€” listening to the video sound instead.',
682
+ subMicBlockedNoMedia: 'This site does not allow the microphone, and the video sound cannot be captured here.',
683
+ subUsingMicFallback: 'The video sound could not be heard directly โ€” listening through the microphone (turn the speakers up).',
684
+ subTabShareEnded: 'Tab audio sharing stopped, so subtitles were turned off.',
685
+ subHearVideo: '๐ŸŽง Listening to the video', subHearMic: '๐ŸŽง Listening through the microphone', subVideoSilent: '๐Ÿ”‡ No sound reaches the subtitles from this video',
686
+ subIssueNet: 'โš ๏ธ Speech service connection is unstable โ€” retrying', subShareTab: '๐ŸŽฌ Connect tab sound', subTabNotShared: 'Tab audio was not shared. Choose this tab and turn on โ€œShare tab audioโ€.',
674
687
  subPosition: 'Subtitle position', posVideo: 'Over the video', posScreen: 'Bottom of the screen', subSize: 'Size', subOpacity: 'Opacity',
675
688
  advanced: 'Advanced', translationEngine: 'Translation engine', providerAuto: 'Google first, on-device as backup (best quality)', providerBrowser: 'On-device only (private)',
676
689
  providerGoogle: 'Google only', providerHelp: 'Online translation reads whole sentences far better; the on-device model shows the live line and steps in when offline.',
677
690
  localFirst: 'Prefer on-device speech recognition', localFirstHelp: 'Uses the offline speech model when the browser has it installed.',
678
691
  hotkeyHelp: 'Shortcuts: Alt+Shift+T subtitles ยท Alt+Shift+C cinema ยท Alt+Shift+N menu ยท in cinema: Space, โ†/โ†’, โ†‘/โ†“, M, F',
679
- subStart: 'Start subtitles', subStop: 'Stop subtitles', subStarting: 'Startingโ€ฆ', subStatusIdle: 'Ready. Press Start, then allow microphone access if asked.',
692
+ subStart: 'Start subtitles', subStop: 'Stop subtitles', subStarting: 'Startingโ€ฆ', subStatusIdle: 'Ready. Choose the languages, then press Start.',
680
693
  subStatusStarting: 'Preparing audio inputโ€ฆ', subListening: 'Listening', auto: 'Auto', inputMic: 'mic', inputMedia: 'video audio',
681
694
  engineLocal: 'on-device', engineOnline: 'online', translation: 'Translation', recognition: 'Recognition', speaker: 'Speaker', time: 'Time', confidence: 'Confidence',
682
695
  speakerMic: 'Mic', speakerMedia: 'Video', speakerMixed: 'Mixed',
683
696
  subOn: '๐ŸŽ™๏ธ AI subtitles ON', subOff: '๐Ÿ”‡ AI subtitles OFF', subUnsupported: 'This browser has no speech recognition. Use Chrome, Edge or Safari.',
684
- subNeedsHttps: 'Subtitles need a secure (https) page.', subMicDenied: '๐ŸŽ™๏ธ Microphone access was blocked. Allow it in the site settings and try again.',
697
+ subNeedsHttps: 'Subtitles need a secure (https) page.', subMicDenied: '๐ŸŽค Microphone access is off. Click the ๐Ÿ”’ icon left of the address bar, set Microphone to โ€œAllowโ€, then try again.',
685
698
  subMicUnavailable: '๐ŸŽ™๏ธ No audio input available.', subNoMic: '๐ŸŽ™๏ธ No microphone found.', subServiceBlocked: 'The speech service is not available in this browser.',
686
699
  subNetworkFailed: 'Speech service unreachable. Check the connection and start again.', subLangUnsupported: 'This language is not supported for recognition.',
687
700
  subStalled: 'Speech recognition keeps failing. Please start again.', subWebAudioUnavailable: 'Video audio unavailable here โ€” using the microphone.',
@@ -694,7 +707,7 @@
694
707
  noVideo: 'โš ๏ธ No video detected', noPlayingVideo: 'โš ๏ธ No playing video found', pipUnsupported: 'โš ๏ธ Picture-in-Picture not supported', pipBlocked: 'โš ๏ธ Picture-in-Picture was blocked',
695
708
  mediaFound: 'โœ… Media detected', mediaNotFound: '๐Ÿ”Ž No media yet โ€” start the video and try again',
696
709
  canvasOn: '๐ŸŽจ Canvas ON', canvasOff: '๐ŸŽจ Canvas OFF', canvasViewOnly: '๐ŸŽจ Canvas (view only)', nothingToUndo: 'โ†ฉ๏ธ Nothing to undo', undo: 'Undo (Ctrl+Z)',
697
- pen: 'Pen', eraser: 'Eraser', clearCanvas: 'Clear canvas', watching: '{n} watching',
710
+ pen: 'Pen', eraser: 'Eraser', clearCanvas: 'Clear canvas', watching: '{n} watching', meTag: '(me)', whoViewer: 'watching only', whoAway: 'away (screen off or another tab)', whoOldVer: 'different version โ€” please update', whoTitle: 'Watching together',
698
711
  shieldTitle: 'Connected', shieldText: 'Tap to enable synchronized playback in this tab.', shieldButton: 'START SYNC โ–ถ๏ธ',
699
712
  menuCinema: 'Toggle cinema mode', menuSubtitles: 'Start / stop AI subtitles', menuShowButton: 'Show / hide the NexusSync button on this site'
700
713
  },
@@ -754,17 +767,30 @@
754
767
  subtitleLanguage: '์ž๋ง‰ ๋ฒˆ์—ญ ์–ธ์–ด', audioSource: '์˜ค๋””์˜ค ์ž…๋ ฅ', audioAuto: '์ž๋™ (๊ฐ€๋Šฅํ•˜๋ฉด ์˜์ƒ ์†Œ๋ฆฌ + ๋งˆ์ดํฌ)', audioMic: '๋งˆ์ดํฌ๋งŒ',
755
768
  audioMedia: '์˜์ƒ/ํƒญ ์†Œ๋ฆฌ๋งŒ', audioDual: '๋งˆ์ดํฌ + ์˜์ƒ ์†Œ๋ฆฌ',
756
769
  audioHelp: '์ž๋™์€ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ํ—ˆ์šฉํ•˜๋ฉด ํŽ˜์ด์ง€ ์˜์ƒ ์†Œ๋ฆฌ๋ฅผ ์ง์ ‘ ๋“ฃ๊ณ , ์•„๋‹ˆ๋ฉด ๋งˆ์ดํฌ๋กœ ๋“ฃ์Šต๋‹ˆ๋‹ค (์Šคํ”ผ์ปค ๋ณผ๋ฅจ์„ ๋†’์—ฌ ์ฃผ์„ธ์š”).',
770
+ heardSound: '๋“ค์„ ์†Œ๋ฆฌ', srcMedia: '๐ŸŽฌ ์˜์ƒ ์†Œ๋ฆฌ (๊ถŒ์žฅ)', srcMic: '๐ŸŽค ๋งˆ์ดํฌ',
771
+ srcMediaHelp: '์˜์ƒ ์†Œ๋ฆฌ๋ฅผ ์ง์ ‘ ๋“ค์–ด์š”. ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ๊ณต์œ ํ•  ํ™”๋ฉด์„ ๋ฌผ์œผ๋ฉด ์ด ํƒญ์„ ๊ณ ๋ฅด๊ณ  โ€œํƒญ ์˜ค๋””์˜ค ๊ณต์œ โ€๋ฅผ ์ผœ ์ฃผ์„ธ์š”.',
772
+ srcMicHelp: '๋งˆ์ดํฌ๋กœ ๋“ค์–ด์š”. ์˜์ƒ ์†Œ๋ฆฌ๋ฅผ ์ด์–ดํฐ์ด ์•„๋‹Œ ์Šคํ”ผ์ปค๋กœ ํฌ๊ฒŒ ํ‹€์–ด ์ฃผ์„ธ์š”.',
773
+ srcIosHelp: '์•„์ดํฐยท์•„์ดํŒจ๋“œ์˜ Safari๋Š” ๋งˆ์ดํฌ๋กœ๋งŒ ๋“ค์„ ์ˆ˜ ์žˆ์–ด์š”. ์˜์ƒ์„ ์Šคํ”ผ์ปค๋กœ ์žฌ์ƒํ•ด ์ฃผ์„ธ์š”.',
774
+ videoLanguage: '์˜์ƒ ์† ์–ธ์–ด', subtitleLanguageReq: '์ž๋ง‰ ์–ธ์–ด (ํ•„์ˆ˜)', chooseLanguage: 'โ€” ์–ธ์–ด๋ฅผ ์„ ํƒํ•˜์„ธ์š” โ€”',
775
+ subPickLanguage: '๋จผ์ € ์ž๋ง‰ ์–ธ์–ด๋ฅผ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.', subAskMic: '๐ŸŽค ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ๋งˆ์ดํฌ ๊ถŒํ•œ์„ ๋ฌผ์œผ๋ฉด โ€œํ—ˆ์šฉโ€์„ ๋ˆŒ๋Ÿฌ ์ฃผ์„ธ์š”.',
776
+ subAskTab: '๐ŸŽฌ ์ด ํƒญ์„ ๊ณ ๋ฅด๊ณ  โ€œํƒญ ์˜ค๋””์˜ค ๊ณต์œ โ€๋ฅผ ์ผ  ๋’ค ๊ณต์œ ๋ฅผ ๋ˆŒ๋Ÿฌ ์ฃผ์„ธ์š”.',
777
+ subMicBlockedSite: '์ด ์‚ฌ์ดํŠธ๋Š” ๋งˆ์ดํฌ ์‚ฌ์šฉ์„ ๋ง‰์•„ ๋‘์—ˆ์–ด์š”. ์˜์ƒ ์†Œ๋ฆฌ๋กœ ๋“ค์„๊ฒŒ์š”.',
778
+ subMicBlockedNoMedia: '์ด ์‚ฌ์ดํŠธ๋Š” ๋งˆ์ดํฌ ์‚ฌ์šฉ์„ ๋ง‰์•„ ๋‘์—ˆ๊ณ , ์˜์ƒ ์†Œ๋ฆฌ๋„ ๋ฐ›์„ ์ˆ˜ ์—†์–ด์š”.',
779
+ subUsingMicFallback: '์˜์ƒ ์†Œ๋ฆฌ๋ฅผ ์ง์ ‘ ๋“ค์„ ์ˆ˜ ์—†์–ด ๋งˆ์ดํฌ๋กœ ๋“ค์–ด์š”. ์Šคํ”ผ์ปค ์†Œ๋ฆฌ๋ฅผ ํ‚ค์›Œ ์ฃผ์„ธ์š”.',
780
+ subTabShareEnded: 'ํƒญ ์˜ค๋””์˜ค ๊ณต์œ ๊ฐ€ ๋๋‚˜์„œ ์ž๋ง‰์„ ๊ป์–ด์š”.',
781
+ subHearVideo: '๐ŸŽง ์˜์ƒ ์†Œ๋ฆฌ ๋“ฃ๋Š” ์ค‘', subHearMic: '๐ŸŽง ๋งˆ์ดํฌ๋กœ ๋“ฃ๋Š” ์ค‘', subVideoSilent: '๐Ÿ”‡ ์ด ์˜์ƒ์˜ ์†Œ๋ฆฌ๊ฐ€ ์ž๋ง‰์— ์ „๋‹ฌ๋˜์ง€ ์•Š์•„์š”',
782
+ subIssueNet: 'โš ๏ธ ์Œ์„ฑ ์ธ์‹ ์„œ๋ฒ„ ์—ฐ๊ฒฐ์ด ๋ถˆ์•ˆ์ •ํ•ด์š” โ€” ๋‹ค์‹œ ์‹œ๋„ ์ค‘', subShareTab: '๐ŸŽฌ ํƒญ ์†Œ๋ฆฌ ์—ฐ๊ฒฐ', subTabNotShared: 'ํƒญ ์˜ค๋””์˜ค๊ฐ€ ๊ณต์œ ๋˜์ง€ ์•Š์•˜์–ด์š”. ์ด ํƒญ์„ ๊ณ ๋ฅด๊ณ  โ€œํƒญ ์˜ค๋””์˜ค ๊ณต์œ โ€๋ฅผ ์ผœ ์ฃผ์„ธ์š”.',
757
783
  subPosition: '์ž๋ง‰ ์œ„์น˜', posVideo: '์˜์ƒ ์œ„', posScreen: 'ํ™”๋ฉด ํ•˜๋‹จ', subSize: 'ํฌ๊ธฐ', subOpacity: '๋ถˆํˆฌ๋ช…๋„',
758
784
  advanced: '๊ณ ๊ธ‰', translationEngine: '๋ฒˆ์—ญ ์—”์ง„', providerAuto: 'Google ์šฐ์„ , ๊ธฐ๊ธฐ ๋‚ด ๋ฒˆ์—ญ ๋ณด์กฐ (์ตœ๊ณ  ํ’ˆ์งˆ)', providerBrowser: '๊ธฐ๊ธฐ ๋‚ด ๋ฒˆ์—ญ๋งŒ (๊ฐœ์ธ์ •๋ณด ๋ณดํ˜ธ)',
759
785
  providerGoogle: 'Google๋งŒ', providerHelp: '๋ฌธ์žฅ ๋ฒˆ์—ญ ํ’ˆ์งˆ์€ ์˜จ๋ผ์ธ(Google)์ด ํ›จ์”ฌ ์ข‹์Šต๋‹ˆ๋‹ค. ๊ธฐ๊ธฐ ๋‚ด ๋ชจ๋ธ์€ ์‹ค์‹œ๊ฐ„ ์ž„์‹œ ์ค„๊ณผ ์˜คํ”„๋ผ์ธ ์ƒํ™ฉ์„ ๋งก์Šต๋‹ˆ๋‹ค.',
760
786
  localFirst: '๊ธฐ๊ธฐ ๋‚ด ์Œ์„ฑ ์ธ์‹ ์šฐ์„ ', localFirstHelp: '๋ธŒ๋ผ์šฐ์ €์— ์˜คํ”„๋ผ์ธ ์Œ์„ฑ ๋ชจ๋ธ์ด ์„ค์น˜๋˜์–ด ์žˆ์œผ๋ฉด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.',
761
787
  hotkeyHelp: '๋‹จ์ถ•ํ‚ค: Alt+Shift+T ์ž๋ง‰ ยท Alt+Shift+C ์‹œ๋„ค๋งˆ ยท Alt+Shift+N ๋ฉ”๋‰ด ยท ์‹œ๋„ค๋งˆ ์ค‘: Space, โ†/โ†’, โ†‘/โ†“, M, F',
762
- subStart: '์ž๋ง‰ ์‹œ์ž‘', subStop: '์ž๋ง‰ ์ค‘์ง€', subStarting: '์‹œ์ž‘ํ•˜๋Š” ์ค‘โ€ฆ', subStatusIdle: '์ค€๋น„๋จ. ์‹œ์ž‘์„ ๋ˆ„๋ฅด๊ณ , ์š”์ฒญ๋˜๋ฉด ๋งˆ์ดํฌ ๊ถŒํ•œ์„ ํ—ˆ์šฉํ•˜์„ธ์š”.',
788
+ subStart: '์ž๋ง‰ ์‹œ์ž‘', subStop: '์ž๋ง‰ ์ค‘์ง€', subStarting: '์‹œ์ž‘ํ•˜๋Š” ์ค‘โ€ฆ', subStatusIdle: '์ค€๋น„๋จ. ์–ธ์–ด๋ฅผ ๊ณ ๋ฅธ ๋’ค ์‹œ์ž‘์„ ๋ˆ„๋ฅด์„ธ์š”.',
763
789
  subStatusStarting: '์˜ค๋””์˜ค ์ž…๋ ฅ ์ค€๋น„ ์ค‘โ€ฆ', subListening: '๋“ฃ๋Š” ์ค‘', auto: '์ž๋™', inputMic: '๋งˆ์ดํฌ', inputMedia: '์˜์ƒ ์†Œ๋ฆฌ',
764
790
  engineLocal: '๊ธฐ๊ธฐ ๋‚ด', engineOnline: '์˜จ๋ผ์ธ', translation: '๋ฒˆ์—ญ', recognition: '์ธ์‹', speaker: 'ํ™”์ž', time: '์‹œ๊ฐ„', confidence: '์‹ ๋ขฐ๋„',
765
791
  speakerMic: '๋งˆ์ดํฌ', speakerMedia: '์˜์ƒ', speakerMixed: 'ํ˜ผํ•ฉ',
766
792
  subOn: '๐ŸŽ™๏ธ AI ์ž๋ง‰ ์ผœ์ง', subOff: '๐Ÿ”‡ AI ์ž๋ง‰ ๊บผ์ง', subUnsupported: '์ด ๋ธŒ๋ผ์šฐ์ €๋Š” ์Œ์„ฑ ์ธ์‹์„ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Chrome, Edge, Safari๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.',
767
- subNeedsHttps: '์ž๋ง‰์€ ๋ณด์•ˆ(https) ํŽ˜์ด์ง€์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.', subMicDenied: '๐ŸŽ™๏ธ ๋งˆ์ดํฌ ๊ถŒํ•œ์ด ์ฐจ๋‹จ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์ดํŠธ ์„ค์ •์—์„œ ํ—ˆ์šฉํ•œ ๋’ค ๋‹ค์‹œ ์‹œ๋„ํ•˜์„ธ์š”.',
793
+ subNeedsHttps: '์ž๋ง‰์€ ๋ณด์•ˆ(https) ํŽ˜์ด์ง€์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.', subMicDenied: '๐ŸŽค ๋งˆ์ดํฌ ๊ถŒํ•œ์ด ๊บผ์ ธ ์žˆ์–ด์š”. ์ฃผ์†Œ์ฐฝ ์™ผ์ชฝ ๐Ÿ”’(์‚ฌ์ดํŠธ ์ •๋ณด)์—์„œ ๋งˆ์ดํฌ๋ฅผ โ€œํ—ˆ์šฉโ€์œผ๋กœ ๋ฐ”๊พผ ๋’ค ๋‹ค์‹œ ๋ˆŒ๋Ÿฌ ์ฃผ์„ธ์š”.',
768
794
  subMicUnavailable: '๐ŸŽ™๏ธ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์˜ค๋””์˜ค ์ž…๋ ฅ์ด ์—†์Šต๋‹ˆ๋‹ค.', subNoMic: '๐ŸŽ™๏ธ ๋งˆ์ดํฌ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.', subServiceBlocked: '์ด ๋ธŒ๋ผ์šฐ์ €์—์„œ๋Š” ์Œ์„ฑ ์ธ์‹ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.',
769
795
  subNetworkFailed: '์Œ์„ฑ ์ธ์‹ ์„œ๋ฒ„์— ์—ฐ๊ฒฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์—ฐ๊ฒฐ์„ ํ™•์ธํ•˜๊ณ  ๋‹ค์‹œ ์‹œ์ž‘ํ•˜์„ธ์š”.', subLangUnsupported: '์ด ์–ธ์–ด๋Š” ์Œ์„ฑ ์ธ์‹์„ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.',
770
796
  subStalled: '์Œ์„ฑ ์ธ์‹์ด ๊ณ„์† ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์‹œ ์‹œ์ž‘ํ•ด ์ฃผ์„ธ์š”.', subWebAudioUnavailable: '์ด ํŽ˜์ด์ง€์—์„œ๋Š” ์˜์ƒ ์†Œ๋ฆฌ๋ฅผ ์ง์ ‘ ๋ฐ›์„ ์ˆ˜ ์—†์–ด ๋งˆ์ดํฌ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.',
@@ -777,7 +803,7 @@
777
803
  noVideo: 'โš ๏ธ ๊ฐ์ง€๋œ ์˜์ƒ์ด ์—†์Šต๋‹ˆ๋‹ค', noPlayingVideo: 'โš ๏ธ ์žฌ์ƒ ์ค‘์ธ ์˜์ƒ์ด ์—†์Šต๋‹ˆ๋‹ค', pipUnsupported: 'โš ๏ธ PiP๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค', pipBlocked: 'โš ๏ธ PiP๊ฐ€ ์ฐจ๋‹จ๋˜์—ˆ์Šต๋‹ˆ๋‹ค',
778
804
  mediaFound: 'โœ… ๋ฏธ๋””์–ด ๊ฐ์ง€๋จ', mediaNotFound: '๐Ÿ”Ž ์•„์ง ๋ฏธ๋””์–ด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค โ€” ์˜์ƒ์„ ์žฌ์ƒํ•œ ๋’ค ๋‹ค์‹œ ์‹œ๋„ํ•˜์„ธ์š”',
779
805
  canvasOn: '๐ŸŽจ ์บ”๋ฒ„์Šค ์ผœ์ง', canvasOff: '๐ŸŽจ ์บ”๋ฒ„์Šค ๊บผ์ง', canvasViewOnly: '๐ŸŽจ ์บ”๋ฒ„์Šค (๋ณด๊ธฐ ์ „์šฉ)', nothingToUndo: 'โ†ฉ๏ธ ๋˜๋Œ๋ฆด ๋‚ด์šฉ์ด ์—†์Šต๋‹ˆ๋‹ค', undo: '๋˜๋Œ๋ฆฌ๊ธฐ (Ctrl+Z)',
780
- pen: 'ํŽœ', eraser: '์ง€์šฐ๊ฐœ', clearCanvas: '๋ชจ๋‘ ์ง€์šฐ๊ธฐ', watching: '{n}๋ช… ์‹œ์ฒญ ์ค‘',
806
+ pen: 'ํŽœ', eraser: '์ง€์šฐ๊ฐœ', clearCanvas: '๋ชจ๋‘ ์ง€์šฐ๊ธฐ', watching: '{n}๋ช… ์‹œ์ฒญ ์ค‘', meTag: '(๋‚˜)', whoViewer: '๋ณด๊ธฐ ์ „์šฉ', whoAway: '์ž๋ฆฌ ๋น„์›€ (ํ™”๋ฉด ๊บผ์งยท๋‹ค๋ฅธ ํƒญ)', whoOldVer: '๋‹ค๋ฅธ ๋ฒ„์ „ โ€” ์—…๋ฐ์ดํŠธ๊ฐ€ ํ•„์š”ํ•ด์š”', whoTitle: 'ํ•จ๊ป˜ ๋ณด๋Š” ์‚ฌ๋žŒ',
781
807
  shieldTitle: '์—ฐ๊ฒฐ๋จ', shieldText: '๋ˆŒ๋Ÿฌ์„œ ์ด ํƒญ์˜ ๋™๊ธฐํ™” ์žฌ์ƒ์„ ํ™œ์„ฑํ™”ํ•˜์„ธ์š”.', shieldButton: '๋™๊ธฐํ™” ์‹œ์ž‘ โ–ถ๏ธ',
782
808
  menuCinema: '์‹œ๋„ค๋งˆ ๋ชจ๋“œ ์ผœ๊ธฐ/๋„๊ธฐ', menuSubtitles: 'AI ์ž๋ง‰ ์‹œ์ž‘/์ค‘์ง€', menuShowButton: '์ด ์‚ฌ์ดํŠธ์—์„œ NexusSync ๋ฒ„ํŠผ ํ‘œ์‹œ/์ˆจ๊ธฐ๊ธฐ'
783
809
  }
@@ -1104,6 +1130,7 @@
1104
1130
  [class*="mask" i], [class*="volume" i], [class*="settings" i], [class*="menu" i], [class*="tooltip" i], [class*="watermark" i], .jw-display, .xgplayer-start, .fp-ui, .art-layers, .art-notice):not(video):not(.nxu-cinema-fill):not(.nxu-keep):not([class*="caption" i]):not([class*="subtitle" i]):not([class*="text-track" i]):not([class*="cue" i]):not([class*="sub-" i]):not([class*="danmaku" i]) {
1105
1131
  visibility: hidden !important; pointer-events: none !important; transition: none !important; animation: none !important; }
1106
1132
  .nxu-site-ui-off :is([class*="caption" i], [class*="subtitle" i], [class*="text-track" i], [class*="cue" i], [class*="danmaku" i]) { visibility: visible !important; }
1133
+ .nxu-site-ui-off .nxu-site-hide { visibility: hidden !important; pointer-events: none !important; transition: none !important; animation: none !important; }
1107
1134
  .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;
1108
1135
  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;
1109
1136
  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; }
@@ -1361,6 +1388,7 @@
1361
1388
  for (let n = video.parentElement; n && n !== root; n = n.parentElement) n.classList.add('nxu-keep');
1362
1389
  }
1363
1390
  root.classList.toggle('nxu-site-ui-off', hide);
1391
+ this._structuralHide(root, video, hide);
1364
1392
  if (video) {
1365
1393
  if (hide && video.hasAttribute('controls')) { video.dataset.nxuControls = '1'; video.removeAttribute('controls'); }
1366
1394
  else if (!hide && video.dataset.nxuControls) { video.setAttribute('controls', ''); delete video.dataset.nxuControls; }
@@ -1374,7 +1402,53 @@
1374
1402
  } catch (_) { }
1375
1403
  }
1376
1404
  },
1405
+ // Players built from utility classes (Tailwind and the like) have no "control" in
1406
+ // their class names, so the site's bar stayed visible behind ours. Structurally: in the
1407
+ // player, everything beside the video's own chain of wrappers that holds controls
1408
+ // (buttons, sliders, icons, links) or is an empty overlay is hidden; text-only layers
1409
+ // (the site's subtitles) stay. Re-checked when the player redraws its controls.
1410
+ _structuralHide(root, video, hide) {
1411
+ const undo = () => {
1412
+ (this._hidden || []).forEach(n => n.classList.remove('nxu-site-hide'));
1413
+ this._hidden = [];
1414
+ this._hideObs?.disconnect();
1415
+ this._hideObs = null;
1416
+ };
1417
+ if (!hide || !root || !video || root === video) { undo(); return; }
1418
+ const run = () => {
1419
+ const chain = new Set();
1420
+ for (let n = video; n && n !== root; n = n.parentElement) chain.add(n);
1421
+ const hidden = [];
1422
+ const CTRL = 'button, input, select, [role="button"], [role="slider"], [role="menu"], [role="menuitem"], svg, a[href], [tabindex]';
1423
+ for (let n = video; n && n !== root; n = n.parentElement) {
1424
+ const parent = n.parentElement;
1425
+ if (!parent) break;
1426
+ for (const child of parent.children) {
1427
+ if (chain.has(child) || child === video || child.tagName === 'VIDEO' || child.tagName === 'CANVAS' && child.width > 200) continue;
1428
+ if (/^(nxu|nexus)/i.test(child.id || '') || [...child.classList].some(c => c.startsWith('nxu-') && c !== 'nxu-site-hide')) continue;
1429
+ if (child.tagName === 'TRACK' || child.tagName === 'SOURCE' || child.tagName === 'STYLE' || child.tagName === 'SCRIPT') continue;
1430
+ const interactive = child.matches(CTRL) || !!child.querySelector(CTRL);
1431
+ const text = (child.textContent || '').trim();
1432
+ // Text without any control: most likely the site's own subtitles.
1433
+ if (!interactive && text) continue;
1434
+ child.classList.add('nxu-site-hide');
1435
+ hidden.push(child);
1436
+ }
1437
+ }
1438
+ (this._hidden || []).forEach(n => { if (!hidden.includes(n)) n.classList.remove('nxu-site-hide'); });
1439
+ this._hidden = hidden;
1440
+ };
1441
+ run();
1442
+ if (!this._hideObs || this._hideObsRoot !== root) {
1443
+ this._hideObs?.disconnect();
1444
+ let timer = 0;
1445
+ this._hideObs = new MutationObserver(() => { if (!timer) timer = setTimeout(() => { timer = 0; if (root.classList.contains('nxu-site-ui-off')) run(); }, 250); });
1446
+ this._hideObs.observe(root, { childList: true, subtree: true });
1447
+ this._hideObsRoot = root;
1448
+ }
1449
+ },
1377
1450
  _releaseSiteUi(root, video) {
1451
+ this._structuralHide(root, video, false);
1378
1452
  root?.classList.remove('nxu-site-ui-off');
1379
1453
  try { root?.querySelectorAll('.nxu-keep').forEach(n => n.classList.remove('nxu-keep')); } catch (_) { }
1380
1454
  if (video?.dataset.nxuControls) { video.setAttribute('controls', ''); delete video.dataset.nxuControls; }
@@ -2225,14 +2299,21 @@
2225
2299
  // โ”€โ”€ settings & language helpers
2226
2300
  _settings() {
2227
2301
  return {
2228
- audioMode: STORE.get('nxu_audio_mode', 'auto'),
2302
+ audioMode: this._audioMode(),
2229
2303
  provider: STORE.get('nxu_translation_provider', 'auto'),
2230
2304
  localFirst: STORE.get('nxu_stt_local_first', true) !== false
2231
2305
  };
2232
2306
  },
2307
+ // Two sources only: the video's own sound (default) or the microphone. Older saved
2308
+ // values (auto / dual) mean "video sound". iPhone/iPad Safari can only use the mic.
2309
+ _audioMode() {
2310
+ if (this._isAppleMobile()) return 'mic';
2311
+ return STORE.get('nxu_audio_mode', 'media') === 'mic' ? 'mic' : 'media';
2312
+ },
2313
+ // The subtitle language is always chosen by the user (no guessing): empty until set.
2233
2314
  loadLanguageSettings() {
2234
- const out = baseLang(STORE.get('nxu_subtitle_language', '') || defaultOutputLanguage());
2235
- this.outLang = LANG_BY_CODE.has(out) ? out : defaultOutputLanguage();
2315
+ const out = baseLang(STORE.get('nxu_subtitle_language', '') || '');
2316
+ this.outLang = out && LANG_BY_CODE.has(out) ? out : '';
2236
2317
  const saved = STORE.get('nxu_speaker_language', '');
2237
2318
  this.inLang = this._localeFor(saved) || this._defaultSpeakerLocale();
2238
2319
  },
@@ -2377,11 +2458,73 @@
2377
2458
  if (!audio.length) throw new Error('no audio was shared');
2378
2459
  return new MediaStream(audio);
2379
2460
  },
2461
+ // Is the microphone switched off for this page by the site itself (Permissions-Policy)?
2462
+ // Then the browser refuses at once, without ever asking the user.
2463
+ _micBlockedByPolicy() {
2464
+ try {
2465
+ const pp = document.permissionsPolicy || document.featurePolicy;
2466
+ return !!(pp && typeof pp.allowsFeature === 'function' && !pp.allowsFeature('microphone'));
2467
+ } catch (_) { return false; }
2468
+ },
2469
+ async _micPermissionState() {
2470
+ try { return (await withTimeout(navigator.permissions.query({ name: 'microphone' }), 800)).state || 'unknown'; } catch (_) { return 'unknown'; }
2471
+ },
2472
+ // Does a captured stream carry any sound? Cross-origin or protected media gives a
2473
+ // track of pure digital silence. Only judged while the video is audibly playing.
2474
+ async _hasSignal(stream) {
2475
+ const v = STATE.video;
2476
+ if (!v || v.paused || v.muted || !(v.volume > 0) || typeof v.captureStream !== 'function') return true;
2477
+ const Ctx = window.AudioContext || window.webkitAudioContext;
2478
+ if (!Ctx) return true;
2479
+ let ctx = null;
2480
+ try {
2481
+ ctx = new Ctx();
2482
+ const src = ctx.createMediaStreamSource(stream);
2483
+ const an = ctx.createAnalyser();
2484
+ an.fftSize = 512;
2485
+ src.connect(an);
2486
+ if (ctx.state === 'suspended') { try { await ctx.resume(); } catch (_) { } }
2487
+ const buf = new Float32Array(an.fftSize);
2488
+ let peak = 0;
2489
+ for (let i = 0; i < 12 && peak < 0.0008; i++) {
2490
+ await new Promise(r => setTimeout(r, 120));
2491
+ an.getFloatTimeDomainData(buf);
2492
+ for (let j = 0; j < buf.length; j++) { const x = Math.abs(buf[j]); if (x > peak) peak = x; }
2493
+ }
2494
+ return peak >= 0.0008;
2495
+ } catch (_) { return true; } finally { try { ctx?.close(); } catch (_) { } }
2496
+ },
2497
+ // The video's own sound: the element itself when it gives real audio, otherwise (on a
2498
+ // computer) the tab's audio, which the browser lets the user share in one dialog.
2499
+ _liveTab() {
2500
+ const st = this._sharedTab;
2501
+ return st && st.getAudioTracks().some(tr => tr.readyState === 'live') ? st : null;
2502
+ },
2503
+ async _captureMediaAudio(token) {
2504
+ // A tab the user already shared keeps working across restarts (no new dialog).
2505
+ const tab = this._liveTab();
2506
+ if (tab) return tab;
2507
+ let web = this._captureElementAudio();
2508
+ if (web && !(await this._hasSignal(web))) {
2509
+ web.getTracks().forEach(tr => tr.stop());
2510
+ web = null;
2511
+ logDebug('AI Sub: the video element gives no sound here (protected or cross-origin media).', 'info');
2512
+ }
2513
+ if (web) { this._webFromElement = true; return web; }
2514
+ if (token !== this._startToken) return null;
2515
+ if (this._isAppleMobile() || this._isAndroid() || !navigator.mediaDevices?.getDisplayMedia) return null;
2516
+ showToast(t('subAskTab'));
2517
+ try { return (this._sharedTab = await this._captureDisplayAudio()); } catch (err) {
2518
+ logDebug('AI Sub: tab audio not shared: ' + (err.message || err.name), 'warn');
2519
+ return null;
2520
+ }
2521
+ },
2380
2522
  async _startAudioCapture(token) {
2381
2523
  this._stopAudioCapture();
2382
- const mode = this._settings().audioMode;
2524
+ const mode = this._audioMode();
2383
2525
  this.audioMode = mode;
2384
2526
  this._webFromElement = false;
2527
+ this._micMixed = false;
2385
2528
  this._mediaPeak = 0;
2386
2529
  this._trackSince = 0;
2387
2530
  this._levels = { mic: 0, media: 0 };
@@ -2392,36 +2535,39 @@
2392
2535
  this.captureMode = 'ios-mic';
2393
2536
  return;
2394
2537
  }
2538
+ const stopAll = (...streams) => streams.forEach(st => st?.getTracks().forEach(tr => tr.stop()));
2539
+ const policyBlocked = this._micBlockedByPolicy();
2395
2540
  let web = null, mic = null;
2396
- if (mode === 'auto' || mode === 'media' || mode === 'dual') {
2397
- web = this._captureElementAudio();
2398
- if (web) this._webFromElement = true;
2399
- else if (mode !== 'auto') {
2400
- try { web = await this._captureDisplayAudio(); } catch (err) {
2401
- logDebug('AI Sub: tab audio unavailable: ' + (err.message || err.name), 'warn');
2402
- if (mode === 'media') showToast(t('subWebAudioUnavailable'));
2403
- }
2541
+ if (mode === 'media' || policyBlocked) {
2542
+ if (policyBlocked && mode === 'mic') showToast(t('subMicBlockedSite'));
2543
+ web = await this._captureMediaAudio(token);
2544
+ if (token !== this._startToken) { stopAll(web); throw new Error('cancelled'); }
2545
+ if (!web && policyBlocked) { const e = new Error('microphone blocked by the site'); e.name = 'PolicyBlocked'; throw e; }
2546
+ }
2547
+ // The microphone is asked for explicitly (so the permission prompt shows up right
2548
+ // away): always in mic mode, as the fallback when the video sound is unavailable,
2549
+ // and alongside video sound for browser recognition, which may still need it.
2550
+ if (!policyBlocked && (!web || this._useWebSpeech)) {
2551
+ if (!web && (await this._micPermissionState()) === 'prompt') showToast(t('subAskMic'));
2552
+ try {
2553
+ // Echo cancellation would erase the very speaker sound we want to hear.
2554
+ mic = await this._requestMic(!web);
2555
+ // With the video sound in hand the microphone was only needed for the
2556
+ // permission; it is not kept open (no recording light, no audio ducking).
2557
+ if (web) { stopAll(mic); mic = null; this._micGranted = true; }
2558
+ } catch (err) {
2559
+ if (!web) throw err;
2560
+ logDebug('AI Sub: microphone unavailable, using the video sound only.', 'info');
2404
2561
  }
2405
2562
  }
2406
- if (token !== this._startToken) { web?.getTracks().forEach(tr => tr.stop()); throw new Error('cancelled'); }
2407
- const trackRecognition = !!web && this._supportsTrackInput();
2408
- try {
2409
- mic = await this._requestMic(!trackRecognition);
2410
- } catch (err) {
2411
- if (!web) throw err;
2412
- logDebug('AI Sub: microphone unavailable, using media audio only.', 'warn');
2413
- }
2414
- if (token !== this._startToken) {
2415
- [web, mic].forEach(s => s?.getTracks().forEach(tr => tr.stop()));
2416
- throw new Error('cancelled');
2417
- }
2563
+ if (token !== this._startToken) { stopAll(web, mic); throw new Error('cancelled'); }
2564
+ if (mode === 'media' && !web && mic) showToast(t('subUsingMicFallback'));
2418
2565
  this.mediaStream = mic;
2419
2566
  this.webMediaStream = web;
2420
- const prefix = mode === 'auto' ? 'auto-' : '';
2421
- this.captureMode = web && mic && mode !== 'media' ? prefix + 'dual' : web ? prefix + 'media' : 'mic';
2567
+ this.captureMode = web ? 'media' : 'mic';
2422
2568
 
2423
2569
  const AudioCtx = window.AudioContext || window.webkitAudioContext;
2424
- const micForMix = mode === 'media' && web ? null : mic;
2570
+ const micForMix = web ? null : mic;
2425
2571
  if (!AudioCtx || (!micForMix && !web)) return;
2426
2572
  try {
2427
2573
  let ctx;
@@ -2455,8 +2601,9 @@
2455
2601
  connect(web, 'media');
2456
2602
  this.audioContext = ctx;
2457
2603
  this.audioNodes = nodes;
2458
- this.recognitionAudioStream = web ? dest.stream : null;
2459
- this._levelTimer = setInterval(() => { if (!document.hidden) this._refreshLevels(); }, 400);
2604
+ // Recognition hears exactly this mix (video sound, or the echo-free microphone).
2605
+ this.recognitionAudioStream = dest.stream;
2606
+ this._levelTimer = setInterval(() => { if (!document.hidden) { this._refreshLevels(); this._updateListenChip(); } }, 400);
2460
2607
  } catch (err) {
2461
2608
  logDebug('AI Sub: audio analysis unavailable: ' + (err.message || err.name), 'info');
2462
2609
  }
@@ -2465,6 +2612,7 @@
2465
2612
  clearInterval(this._levelTimer);
2466
2613
  this._levelTimer = null;
2467
2614
  [this.mediaStream, this.webMediaStream, this.recognitionAudioStream].forEach(stream => {
2615
+ if (stream && stream === this._sharedTab) return; // released only on a real stop
2468
2616
  try { stream?.getTracks().forEach(tr => tr.stop()); } catch (_) { }
2469
2617
  });
2470
2618
  this.mediaStream = this.webMediaStream = this.recognitionAudioStream = null;
@@ -2601,8 +2749,12 @@
2601
2749
  },
2602
2750
  _touch() { this._lastEventAt = Date.now(); },
2603
2751
  _liveTrack() {
2604
- const track = this.recognitionAudioStream?.getAudioTracks?.()[0];
2605
- return track && track.readyState === 'live' ? track : null;
2752
+ const pick = s => { const tr = s?.getAudioTracks?.()[0]; return tr && tr.readyState === 'live' ? tr : null; };
2753
+ // The recognizer listens to the captured source track itself (the video's own
2754
+ // audio track, or the echo-free microphone), as browsers document and test it; the
2755
+ // mixed stream is used only once the microphone was added to a silent video sound.
2756
+ if (this._micMixed) return pick(this.recognitionAudioStream) || pick(this.mediaStream);
2757
+ return pick(this.webMediaStream) || pick(this.mediaStream) || pick(this.recognitionAudioStream);
2606
2758
  },
2607
2759
  _startSession(reason) {
2608
2760
  if (!this.active) return;
@@ -2652,6 +2804,9 @@
2652
2804
  if (!this.active) return;
2653
2805
  if (!document.hidden) this._checkAudio();
2654
2806
  if (!this.active) return;
2807
+ // The user stopped sharing the tab's audio from the browser's bar.
2808
+ const shared = this.webMediaStream && !this._webFromElement ? this.webMediaStream.getAudioTracks() : [];
2809
+ if (shared.length && shared.every(tr => tr.readyState === 'ended')) { this.stop(t('subTabShareEnded')); return; }
2655
2810
  if (!this._useWebSpeech) { updateAIBtnUX(); return; }
2656
2811
  const now = Date.now();
2657
2812
  if (!this._restartTimer && !this._waitOnline && now - this._lastEventAt > 25000) {
@@ -2663,18 +2818,111 @@
2663
2818
  this._scheduleRestart('watchdog', 100, true);
2664
2819
  } else if (this._recognitionInput === 'track' && !this._trackDisabled && this._trackSince && (
2665
2820
  // Captured video audio is silent (e.g. cross-origin media) while the video plays,
2666
- (now - this._trackSince > 6000 && this._mediaPeak < 0.003 && STATE.video && !STATE.video.paused && !STATE.video.muted && STATE.video.volume > 0) ||
2667
- // or sound is present but the engine never returns words from the track.
2668
- (now - this._trackSince > 12000 && this._lastResultAt < this._trackSince && Math.max(this._levels.media, this._levels.mic) >= SPEECH_LEVEL))) {
2821
+ (this._mediaSilent() && !this._micMixed) ||
2822
+ // or (microphone track only) sound is present but the engine never returns
2823
+ // words from the track. Never judged on the video sound: music, effects or a
2824
+ // long quiet scene are no reason to give up on it.
2825
+ (!this.webMediaStream && this.captureMode === 'mic' && now - this._trackSince > 40000 && this._lastResultAt < this._trackSince && this._levels.mic >= SPEECH_LEVEL))) {
2826
+ // Silent video sound: keep feeding the recognizer, from the echo-free microphone,
2827
+ // and offer the tab's sound (one tap) in the subtitle area.
2828
+ if (this.webMediaStream) { if (!this._micMixing) this._mixInMic(); updateAIBtnUX(); return; }
2669
2829
  this._trackDisabled = true;
2670
- logDebug('AI Sub: captured video audio unusable, switching to microphone input.', 'warn');
2830
+ logDebug('AI Sub: captured audio unusable, switching to the recognizerโ€™s own microphone.', 'warn');
2831
+ if (!this._micMixed) showToast(t('subUsingMicFallback'));
2671
2832
  this._preparePlaybackMic();
2672
2833
  this._destroyRecognizer();
2673
2834
  this._createRecognizer();
2674
2835
  this._scheduleRestart('track-fallback', 150, true);
2675
2836
  }
2837
+ this._updateListenChip();
2676
2838
  updateAIBtnUX();
2677
2839
  },
2840
+ // The video is audibly playing but the captured sound has stayed digitally silent.
2841
+ _mediaSilent() {
2842
+ const v = STATE.video;
2843
+ return !!(this.webMediaStream && this._trackSince && Date.now() - this._trackSince > 6000 && this._mediaPeak < 0.003
2844
+ && v && !v.paused && !v.muted && v.volume > 0);
2845
+ },
2846
+ async _mixInMic() {
2847
+ const ctx = this.audioContext, nodes = this.audioNodes;
2848
+ if (this._micMixed || this._micMixing || !ctx || !nodes?.mix) return false;
2849
+ this._micMixing = true;
2850
+ try {
2851
+ if (!this.mediaStream) {
2852
+ try { this.mediaStream = await this._requestMic(true); } catch (_) { return false; }
2853
+ if (!this.active || this.audioContext !== ctx) { this.mediaStream.getTracks().forEach(tr => tr.stop()); this.mediaStream = null; return false; }
2854
+ }
2855
+ const src = ctx.createMediaStreamSource(this.mediaStream);
2856
+ const an = ctx.createAnalyser();
2857
+ an.fftSize = 512;
2858
+ an.smoothingTimeConstant = 0.3;
2859
+ src.connect(an);
2860
+ src.connect(nodes.mix);
2861
+ nodes.list.push(src, an);
2862
+ nodes.analysers.mic = an;
2863
+ this._micMixed = true;
2864
+ this._preparePlaybackMic();
2865
+ this._trackSince = Date.now();
2866
+ this.captureMode = 'mic';
2867
+ if (this._useWebSpeech && this.active) {
2868
+ // Listen to the mix (video + microphone) from now on.
2869
+ this._destroyRecognizer();
2870
+ this._createRecognizer();
2871
+ this._scheduleRestart('mic-mixed', 150, true);
2872
+ }
2873
+ showToast(t('subUsingMicFallback'));
2874
+ logDebug('AI Sub: the video sound is silent here, listening through the microphone.', 'warn');
2875
+ return true;
2876
+ } catch (_) { return false; } finally { this._micMixing = false; }
2877
+ },
2878
+ // One tap in the subtitle area: listen to this tab's sound instead (needs the tap,
2879
+ // because the browser only opens its sharing dialog for a user action).
2880
+ async shareTabAudio() {
2881
+ if (!this.active || !navigator.mediaDevices?.getDisplayMedia) return;
2882
+ try {
2883
+ const st = await this._captureDisplayAudio();
2884
+ try { this._sharedTab?.getTracks().forEach(tr => tr.stop()); } catch (_) { }
2885
+ this._sharedTab = st;
2886
+ this._trackDisabled = false;
2887
+ await this.restart('tab audio shared');
2888
+ } catch (err) {
2889
+ logDebug('AI Sub: tab audio not shared: ' + (err.message || err.name), 'warn');
2890
+ showToast(t('subTabNotShared'));
2891
+ }
2892
+ },
2893
+ _canShareTab() {
2894
+ return !this._isAppleMobile() && !this._isAndroid() && !!navigator.mediaDevices?.getDisplayMedia && !this._liveTab();
2895
+ },
2896
+ // A small "listening" chip: shows that sound is arriving (level meter), and when the
2897
+ // video's sound cannot be heard, says so with a one-tap way to connect the tab sound.
2898
+ _updateListenChip() {
2899
+ const overlay = shadow?.getElementById('nxu-subtitle-overlay');
2900
+ if (!overlay) return;
2901
+ let chip = overlay.querySelector('.sub-listen');
2902
+ if (!this.active) { chip?.remove(); return; }
2903
+ if (!chip) {
2904
+ chip = createEl('div', 'sub-listen');
2905
+ const btn = createEl('button', 'sub-listen-btn', t('subShareTab'), { type: 'button' });
2906
+ btn.addEventListener('click', (e) => { e.stopPropagation(); this.shareTabAudio(); });
2907
+ const meter = createEl('span', 'sub-listen-meter');
2908
+ meter.appendChild(createEl('i'));
2909
+ chip.append(createEl('span', 'sub-listen-text'), meter, btn);
2910
+ overlay.prepend(chip);
2911
+ }
2912
+ const wantedVideo = this.audioMode === 'media' && this.captureMode !== 'ios-mic';
2913
+ const silent = this._mediaSilent();
2914
+ const fellBack = wantedVideo && !this.webMediaStream;
2915
+ const offer = (silent || fellBack) && this._canShareTab();
2916
+ const showing = !!(shadow.getElementById('nxu-final-slot')?.childElementCount || shadow.getElementById('nxu-interim-slot')?.childElementCount);
2917
+ chip.classList.toggle('hide', showing && !offer);
2918
+ chip.classList.toggle('warn', silent);
2919
+ chip.classList.toggle('warn', silent || !!this._issue);
2920
+ if (this._issue) chip.classList.remove('hide');
2921
+ chip.querySelector('.sub-listen-text').textContent = this._issue === 'net' ? t('subIssueNet') : silent ? t('subVideoSilent') : this.webMediaStream && !this._micMixed ? t('subHearVideo') : t('subHearMic');
2922
+ const level = Math.max(this._levels.media || 0, this._levels.mic || 0);
2923
+ chip.querySelector('.sub-listen-meter i').style.width = Math.min(100, Math.round(level * 400)) + '%';
2924
+ chip.querySelector('.sub-listen-btn').style.display = offer ? '' : 'none';
2925
+ },
2678
2926
  _preparePlaybackMic() {
2679
2927
  const track = this.mediaStream?.getAudioTracks?.()[0];
2680
2928
  if (!track || typeof track.applyConstraints !== 'function') return;
@@ -2695,6 +2943,7 @@
2695
2943
  this._networkErrors = 0;
2696
2944
  this._networkRetryMs = 0;
2697
2945
  this._audioCaptureErrors = 0;
2946
+ this._issue = '';
2698
2947
  const finals = [];
2699
2948
  const interim = [];
2700
2949
  let confidence = null;
@@ -2859,11 +3108,21 @@
2859
3108
  }
2860
3109
  return;
2861
3110
  case 'audio-capture':
3111
+ if (this._recognitionInput === 'track' && !this._trackDisabled) {
3112
+ // The engine could not read the captured track: let it use its own input.
3113
+ this._trackDisabled = true;
3114
+ logDebug('AI Sub: the speech engine could not read the captured audio, using its own input.', 'warn');
3115
+ this._destroyRecognizer();
3116
+ this._createRecognizer();
3117
+ this._scheduleRestart('track-capture-error', 200, true);
3118
+ return;
3119
+ }
2862
3120
  if (++this._audioCaptureErrors >= 3) { this.stop(t('subNoMic')); return; }
2863
3121
  this._networkRetryMs = 1000;
2864
3122
  return;
2865
3123
  case 'network': {
2866
3124
  this._networkErrors++;
3125
+ this._issue = this._networkErrors >= 2 ? 'net' : '';
2867
3126
  if (this._networkErrors >= 12) { this.stop(t('subNetworkFailed')); return; }
2868
3127
  if (navigator.onLine === false) { this._waitOnline = true; return; }
2869
3128
  this._networkRetryMs = Math.min(15000, Math.max(800, (this._networkRetryMs || 600) * 1.7));
@@ -3389,6 +3648,7 @@
3389
3648
  this._networkErrors = 0;
3390
3649
  this._networkRetryMs = 0;
3391
3650
  this._audioCaptureErrors = 0;
3651
+ this._issue = '';
3392
3652
  this._sessionFailures = 0;
3393
3653
  this._trackDisabled = false;
3394
3654
  this._waitOnline = false;
@@ -3412,6 +3672,8 @@
3412
3672
  },
3413
3673
  async start({ silent = false } = {}) {
3414
3674
  if (this.state !== 'idle') return;
3675
+ this.loadLanguageSettings();
3676
+ if (!this.outLang) { this._askLanguage(); return; }
3415
3677
  const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
3416
3678
  this._cloud = AI.asrProvider() !== 'browser' && !!(window.AudioContext || window.webkitAudioContext);
3417
3679
  // With cloud recognition on iPhone/iPad, Safari's own recognizer stays off
@@ -3421,7 +3683,6 @@
3421
3683
  if (window.isSecureContext === false) { showToast(t('subNeedsHttps')); return; }
3422
3684
  const token = ++this._startToken;
3423
3685
  this.state = 'starting';
3424
- this.loadLanguageSettings();
3425
3686
  this._resetRuntime();
3426
3687
  this._abortCtrl = new AbortController();
3427
3688
  this._syncUI();
@@ -3435,7 +3696,7 @@
3435
3696
  this._syncUI();
3436
3697
  const denied = err?.name === 'NotAllowedError' || err?.name === 'SecurityError';
3437
3698
  logDebug('AI Sub: audio input failed: ' + (err?.message || err?.name), 'error');
3438
- showToast(t(denied ? 'subMicDenied' : 'subMicUnavailable'));
3699
+ showToast(t(err?.name === 'PolicyBlocked' ? 'subMicBlockedNoMedia' : err?.name === 'NotFoundError' ? 'subNoMic' : denied ? 'subMicDenied' : 'subMicUnavailable'));
3439
3700
  return;
3440
3701
  }
3441
3702
  if (token !== this._startToken) return;
@@ -3458,6 +3719,7 @@
3458
3719
  clearInterval(this._watchdogTimer);
3459
3720
  this._watchdogTimer = setInterval(() => this._watchdog(), 4000);
3460
3721
  this.getOverlay();
3722
+ this._updateListenChip();
3461
3723
  SUB_LAYOUT.schedule();
3462
3724
  this._syncUI();
3463
3725
  if (!silent) showToast(t('subOn'));
@@ -3504,6 +3766,9 @@
3504
3766
  this._restoreAppleSession();
3505
3767
  this._resetRuntime();
3506
3768
  if (!keepOverlay) {
3769
+ try { this._sharedTab?.getTracks().forEach(tr => tr.stop()); } catch (_) { }
3770
+ this._sharedTab = null;
3771
+ shadow?.getElementById('nxu-subtitle-overlay')?.querySelector('.sub-listen')?.remove();
3507
3772
  const overlay = shadow?.getElementById('nxu-subtitle-overlay');
3508
3773
  if (overlay) {
3509
3774
  overlay.style.opacity = '0';
@@ -3516,6 +3781,19 @@
3516
3781
  if (wasActive && message) showToast(message);
3517
3782
  if (wasActive) logDebug('AI Sub stopped.', 'info');
3518
3783
  },
3784
+ // No subtitle language yet: open the settings with the language picker highlighted.
3785
+ _askLanguage() {
3786
+ showToast(t('subPickLanguage'));
3787
+ const modal = shadow?.getElementById('trans-modal');
3788
+ if (modal && modal.style.display !== 'flex') openPanel(modal);
3789
+ const sel = shadow?.getElementById('stt-out');
3790
+ if (sel) {
3791
+ sel.classList.remove('need');
3792
+ void sel.offsetWidth;
3793
+ sel.classList.add('need');
3794
+ try { sel.focus({ preventScroll: true }); } catch (_) { }
3795
+ }
3796
+ },
3519
3797
  toggle() {
3520
3798
  if (this.state === 'idle') this.start();
3521
3799
  else this.stop(t('subOff'));
@@ -3532,7 +3810,7 @@
3532
3810
  updateAIBtnUX();
3533
3811
  },
3534
3812
  setOutputLanguage(value) {
3535
- this.outLang = LANG_BY_CODE.has(value) ? value : 'en';
3813
+ this.outLang = value && LANG_BY_CODE.has(value) ? value : '';
3536
3814
  this._recentQueued = [];
3537
3815
  if (this.active) this._warmBrowserTranslator(baseLang(this._recognitionLanguage()), this.outLang);
3538
3816
  updateAIBtnUX();
@@ -5314,7 +5592,24 @@
5314
5592
  shieldUntil: 0,
5315
5593
  noteTap() { this.tapAt = Date.now(); },
5316
5594
  noteType() { this.typeAt = Date.now(); },
5317
- shield(ms = 650) { this.shieldUntil = Math.max(this.shieldUntil, Date.now() + ms); },
5595
+ shield(ms = 650) { this.shieldUntil = Math.max(this.shieldUntil, Date.now() + ms); this._arm(); },
5596
+ // The page-wide click swallower is attached only while the shield is up (a permanent
5597
+ // non-passive touch listener on the window slows every tap and scroll on phones).
5598
+ _types: ['click', 'dblclick', 'mousedown', 'mouseup', 'pointerdown', 'pointerup', 'touchstart', 'touchend'],
5599
+ _arm() {
5600
+ if (!this._swallow) return;
5601
+ if (!this._armed) {
5602
+ this._armed = true;
5603
+ this._types.forEach(type => window.addEventListener(type, this._swallow, { capture: true, passive: false }));
5604
+ }
5605
+ clearTimeout(this._disarmTimer);
5606
+ const left = this.shieldUntil - Date.now();
5607
+ this._disarmTimer = setTimeout(() => {
5608
+ if (Date.now() < this.shieldUntil) { this._arm(); return; }
5609
+ this._armed = false;
5610
+ this._types.forEach(type => window.removeEventListener(type, this._swallow, { capture: true }));
5611
+ }, Math.max(50, left + 60));
5612
+ },
5318
5613
  accidental() {
5319
5614
  const now = Date.now();
5320
5615
  if (now - (STATE._ownControlAt || 0) < 900) return false;
@@ -5332,7 +5627,8 @@
5332
5627
  if (e.cancelable) e.preventDefault();
5333
5628
  e.stopImmediatePropagation();
5334
5629
  };
5335
- ['click', 'dblclick', 'mousedown', 'mouseup', 'pointerdown', 'pointerup', 'touchstart', 'touchend'].forEach(type => window.addEventListener(type, swallow, { capture: true, passive: false }));
5630
+ this._swallow = swallow;
5631
+ if (Date.now() < this.shieldUntil) this._arm();
5336
5632
  }
5337
5633
  };
5338
5634
 
@@ -5671,19 +5967,61 @@
5671
5967
  hud._hideTimer = setTimeout(() => { hud.style.display = 'none'; }, 8000);
5672
5968
  }
5673
5969
 
5970
+ // Who is here, for display: me first, then by name, each with their own colour and a
5971
+ // small mark for "watching only", "away" (screen off / other tab) and an outdated version.
5972
+ function roomRoster() {
5973
+ const safeColor = c => (/^#[0-9a-f]{3,8}$/i.test(String(c || '')) ? c : '#7c4dff');
5974
+ const list = Object.entries(STATE.presenceMap || {}).map(([uid, p]) => {
5975
+ const self = uid === STATE.userId;
5976
+ return {
5977
+ uid, self,
5978
+ name: self ? (STATE.nickname || t('you')) : (p?.nick || 'ID:' + String(uid).slice(0, 3)),
5979
+ color: safeColor(self ? STATE.color : p?.color),
5980
+ viewer: self ? !!STATE.isViewer : !!p?.viewer,
5981
+ away: !self && !!p?.hid,
5982
+ oldVer: !self && !!(p?.v && p.v !== NXU_VERSION)
5983
+ };
5984
+ });
5985
+ list.sort((a, b) => (b.self - a.self) || a.name.localeCompare(b.name));
5986
+ return list;
5987
+ }
5988
+ function renderRoster(box, max = 4) {
5989
+ const list = roomRoster();
5990
+ const sig = max + '|' + list.map(m => [m.uid, m.name, m.color, m.viewer, m.away, m.oldVer].join(',')).join(';');
5991
+ if (box._rosterSig === sig) return list;
5992
+ box._rosterSig = sig;
5993
+ box.replaceChildren();
5994
+ list.slice(0, max).forEach(m => {
5995
+ const chip = createEl('span', 'nx-who' + (m.away ? ' away' : '') + (m.self ? ' me' : ''));
5996
+ const dot = createEl('i', 'nx-who-dot');
5997
+ dot.style.background = m.color;
5998
+ chip.append(dot, createEl('span', 'nx-who-name', m.name + (m.self && STATE.nickname ? ' ' + t('meTag') : '')));
5999
+ if (m.viewer) chip.append(createEl('span', 'nx-who-tag', '๐Ÿ‘€'));
6000
+ if (m.away) chip.append(createEl('span', 'nx-who-tag', '๐Ÿ’ค'));
6001
+ if (m.oldVer) chip.append(createEl('span', 'nx-who-tag', 'โš ๏ธ'));
6002
+ chip.title = [m.name, m.viewer && t('whoViewer'), m.away && t('whoAway'), m.oldVer && t('whoOldVer')].filter(Boolean).join(' ยท ');
6003
+ box.appendChild(chip);
6004
+ });
6005
+ if (list.length > max) box.appendChild(createEl('span', 'nx-who more', '+' + (list.length - max)));
6006
+ box.title = t('whoTitle') + ' (' + list.length + ')';
6007
+ return list;
6008
+ }
6009
+
5674
6010
  function updatePresenceUI() {
5675
6011
  if (!shadow) return;
5676
6012
  let pill = shadow.getElementById('nxu-presence-pill');
5677
6013
  if (!pill && uiElements.uiWrapper) {
5678
6014
  pill = createEl('div', 'presence-pill');
5679
6015
  pill.id = 'nxu-presence-pill';
6016
+ pill.setAttribute('role', 'button');
6017
+ // Tap: the full list (everyone, one per line) โ†” the short row of names.
6018
+ pill.addEventListener('click', (e) => { e.stopPropagation(); pill.classList.toggle('open'); updatePresenceUI(); });
5680
6019
  uiElements.uiWrapper.appendChild(pill);
5681
6020
  }
5682
6021
  if (!pill) return;
5683
6022
  const entries = Object.values(STATE.presenceMap);
5684
6023
  if (entries.length && STATE.role !== 'IDLE') {
5685
- pill.textContent = '๐Ÿ‘ฅ ' + t('watching', { n: entries.length });
5686
- pill.title = entries.map(e => e.nick || e.role || '').filter(Boolean).join(', ');
6024
+ renderRoster(pill, pill.classList.contains('open') ? 50 : 3);
5687
6025
  pill.style.display = '';
5688
6026
  } else {
5689
6027
  pill.style.display = 'none';
@@ -5698,11 +6036,11 @@
5698
6036
 
5699
6037
  function currentMediaInfo() {
5700
6038
  if (STATE.video) {
5701
- return { kind: 'video', el: STATE.video, time: STATE.video.currentTime, duration: STATE.video.duration, paused: STATE.video.paused };
6039
+ return { kind: 'video', el: STATE.video, time: STATE.video.currentTime, duration: STATE.video.duration, paused: STATE.video.paused, live: VIDEO_DETECTOR.isLive(STATE.video) };
5702
6040
  }
5703
6041
  if (STATE.cinemaIframe) {
5704
6042
  const rep = VIDEO_DETECTOR.frameReports.get(STATE.cinemaIframe) || {};
5705
- return { kind: 'iframe', el: STATE.cinemaIframe, time: STATE.lastCinemaTime || 0, duration: rep.duration, paused: rep.paused !== false };
6043
+ return { kind: 'iframe', el: STATE.cinemaIframe, time: STATE.lastCinemaTime || 0, duration: rep.duration, paused: rep.paused !== false, live: !!rep.live };
5706
6044
  }
5707
6045
  return null;
5708
6046
  }
@@ -6170,12 +6508,21 @@
6170
6508
  panel.style.top = Math.max(12, Math.min(initTop + dy, getH() - panel.offsetHeight - 12)) + 'px';
6171
6509
  };
6172
6510
  const onUp = () => { dragging = false; };
6173
- handle.addEventListener('mousedown', onDown);
6174
- handle.addEventListener('touchstart', onDown, { passive: true });
6175
- window.addEventListener('mousemove', onMove);
6176
- window.addEventListener('touchmove', onMove, { passive: false });
6177
- window.addEventListener('mouseup', onUp);
6178
- window.addEventListener('touchend', onUp);
6511
+ // Page-wide move/up listeners exist only while dragging: a permanent non-passive
6512
+ // touchmove on the window makes every scroll and tap on the page wait for script,
6513
+ // which felt sluggish on iPhone.
6514
+ const listen = (on) => {
6515
+ const m = on ? 'addEventListener' : 'removeEventListener';
6516
+ window[m]('mousemove', onMove);
6517
+ window[m]('touchmove', onMove, { passive: false });
6518
+ window[m]('mouseup', finish);
6519
+ window[m]('touchend', finish);
6520
+ window[m]('touchcancel', finish);
6521
+ };
6522
+ const finish = (e) => { listen(false); onUp(e); };
6523
+ const begin = (e) => { onDown(e); if (dragging) listen(true); };
6524
+ handle.addEventListener('mousedown', begin);
6525
+ handle.addEventListener('touchstart', begin, { passive: true });
6179
6526
  }
6180
6527
 
6181
6528
  function updateSmartPosition(wrapper, fab, dock, reactPill) {
@@ -6283,12 +6630,21 @@
6283
6630
  STORE.set('nxu_fab_pos', { x: parseFloat(wrapper.style.left) / Math.max(1, w - 48), y: parseFloat(wrapper.style.top) / Math.max(1, h - 48) });
6284
6631
  }
6285
6632
  };
6286
- handle.addEventListener('mousedown', onDown);
6287
- handle.addEventListener('touchstart', onDown, { passive: true });
6288
- window.addEventListener('mousemove', onMove);
6289
- window.addEventListener('touchmove', onMove, { passive: false });
6290
- window.addEventListener('mouseup', onUp);
6291
- window.addEventListener('touchend', onUp);
6633
+ // Page-wide move/up listeners exist only while dragging: a permanent non-passive
6634
+ // touchmove on the window makes every scroll and tap on the page wait for script,
6635
+ // which felt sluggish on iPhone.
6636
+ const listen = (on) => {
6637
+ const m = on ? 'addEventListener' : 'removeEventListener';
6638
+ window[m]('mousemove', onMove);
6639
+ window[m]('touchmove', onMove, { passive: false });
6640
+ window[m]('mouseup', finish);
6641
+ window[m]('touchend', finish);
6642
+ window[m]('touchcancel', finish);
6643
+ };
6644
+ const finish = (e) => { listen(false); onUp(e); };
6645
+ const begin = (e) => { onDown(e); if (dragging) listen(true); };
6646
+ handle.addEventListener('mousedown', begin);
6647
+ handle.addEventListener('touchstart', begin, { passive: true });
6292
6648
 
6293
6649
  const restore = () => {
6294
6650
  const saved = STORE.get('nxu_fab_pos', null);
@@ -6331,10 +6687,26 @@
6331
6687
  const label = text => createEl('div', 'field-label', text);
6332
6688
  const help = text => createEl('div', 'trans-help', text);
6333
6689
  const speakerSelect = createSelect('stt-in', LANGS.map(l => ({ value: l.locale, label: l.label })));
6334
- const subtitleSelect = createSelect('stt-out', LANGS.map(l => ({ value: l.code, label: l.label })));
6335
- const audioSelect = createSelect('stt-audio-mode', [
6336
- { value: 'auto', label: t('audioAuto') }, { value: 'mic', label: t('audioMic') },
6337
- { value: 'media', label: t('audioMedia') }, { value: 'dual', label: t('audioDual') }]);
6690
+ const subtitleSelect = createSelect('stt-out', [{ value: '', label: t('chooseLanguage') }, ...LANGS.map(l => ({ value: l.code, label: l.label }))]);
6691
+ // What to listen to: two clear choices instead of a list of capture modes.
6692
+ const ios = TRANSLATOR._isAppleMobile();
6693
+ const sourceRow = createEl('div', 'seg', '', { id: 'stt-source', role: 'radiogroup' });
6694
+ const srcMedia = createEl('button', 'seg-btn', t('srcMedia'), { type: 'button', 'data-mode': 'media', role: 'radio' });
6695
+ const srcMic = createEl('button', 'seg-btn', t('srcMic'), { type: 'button', 'data-mode': 'mic', role: 'radio' });
6696
+ const sourceHelp = help('');
6697
+ sourceRow.append(srcMedia, srcMic);
6698
+ const paintSource = () => {
6699
+ const mode = TRANSLATOR._audioMode();
6700
+ [srcMedia, srcMic].forEach(b => { const on = b.dataset.mode === mode; b.classList.toggle('on', on); b.setAttribute('aria-checked', String(on)); });
6701
+ srcMedia.disabled = ios;
6702
+ sourceHelp.textContent = ios ? t('srcIosHelp') : mode === 'mic' ? t('srcMicHelp') : t('srcMediaHelp');
6703
+ };
6704
+ [srcMedia, srcMic].forEach(b => b.addEventListener('click', () => {
6705
+ if (b.disabled || TRANSLATOR._audioMode() === b.dataset.mode) return;
6706
+ STORE.set('nxu_audio_mode', b.dataset.mode);
6707
+ paintSource();
6708
+ TRANSLATOR.restart('audio source changed');
6709
+ }));
6338
6710
  const positionSelect = createSelect('stt-position', [{ value: 'video', label: t('posVideo') }, { value: 'screen', label: t('posScreen') }]);
6339
6711
  const asrSelect = createSelect('stt-asr-provider', [
6340
6712
  { value: 'browser', label: t('asrBrowser') }, { value: 'openai', label: t('asrOpenAI') },
@@ -6411,17 +6783,17 @@
6411
6783
  const advanced = createEl('div', 'ai-advanced-body');
6412
6784
  const offlineBtn = createEl('button', 'btn subtle', 'โฌ‡๏ธ ' + t('offlineDownload'));
6413
6785
  offlineBtn.onclick = () => TRANSLATOR.downloadOfflineModels();
6414
- advanced.append(label(t('glossary')), glossaryInput, help(t('glossaryHelp')), label(t('aiKeys')), keyRows, help(t('aiKeysHelp')), modelRow('anthropic', 'claude-haiku-4-5'), modelRow('openai', 'gpt-4.1-mini'),
6786
+ advanced.append(label(t('translationEngine')), providerSelect, engineHint,
6787
+ label(t('asrEngine')), asrSelect,
6788
+ label(t('subPosition')), positionSelect,
6789
+ label(t('glossary')), glossaryInput, help(t('glossaryHelp')), label(t('aiKeys')), keyRows, help(t('aiKeysHelp')), modelRow('anthropic', 'claude-haiku-4-5'), modelRow('openai', 'gpt-4.1-mini'),
6415
6790
  help(t('modelHelp')), localRow, help(t('localFirstHelp')), offlineBtn, help(t('offlineHelp')));
6416
6791
  details.append(createEl('summary', '', t('advanced')), advanced);
6417
6792
 
6418
6793
  body.append(
6419
- label(t('speakerLanguage')), speakerSelect, help(t('speakerHelp')),
6420
- label(t('subtitleLanguage')), subtitleSelect,
6421
- label(t('audioSource')), audioSelect, help(t('audioHelp')),
6422
- label(t('asrEngine')), asrSelect,
6423
- label(t('translationEngine')), providerSelect, engineHint,
6424
- label(t('subPosition')), positionSelect,
6794
+ label(t('heardSound')), sourceRow, sourceHelp,
6795
+ label(t('videoLanguage')), speakerSelect,
6796
+ label(t('subtitleLanguageReq')), subtitleSelect,
6425
6797
  sizeRow, opacityRow,
6426
6798
  details,
6427
6799
  createEl('div', 'ai-status', t('subStatusIdle'), { id: 'nxu-ai-status' }),
@@ -6430,8 +6802,8 @@
6430
6802
  );
6431
6803
 
6432
6804
  speakerSelect.value = TRANSLATOR._recognitionLanguage();
6433
- subtitleSelect.value = TRANSLATOR.outLang;
6434
- audioSelect.value = STORE.get('nxu_audio_mode', 'auto');
6805
+ subtitleSelect.value = TRANSLATOR.outLang || '';
6806
+ paintSource();
6435
6807
  positionSelect.value = STORE.get('nxu_sub_position', 'video');
6436
6808
  providerSelect.value = STORE.get('nxu_translation_provider', 'auto');
6437
6809
  asrSelect.value = STORE.get('nxu_asr_provider', 'browser');
@@ -6441,8 +6813,12 @@
6441
6813
  opacitySlider.value = SUB_PREFS.opacity; opacityVal.textContent = SUB_PREFS.opacity + '%';
6442
6814
 
6443
6815
  speakerSelect.addEventListener('change', () => { STORE.set('nxu_speaker_language', speakerSelect.value); TRANSLATOR.setSpeakerLanguage(speakerSelect.value); });
6444
- subtitleSelect.addEventListener('change', () => { STORE.set('nxu_subtitle_language', subtitleSelect.value); TRANSLATOR.setOutputLanguage(subtitleSelect.value); });
6445
- audioSelect.addEventListener('change', () => { STORE.set('nxu_audio_mode', audioSelect.value); TRANSLATOR.restart('audio source changed'); });
6816
+ subtitleSelect.addEventListener('change', () => {
6817
+ if (!subtitleSelect.value) return;
6818
+ subtitleSelect.classList.remove('need');
6819
+ STORE.set('nxu_subtitle_language', subtitleSelect.value);
6820
+ TRANSLATOR.setOutputLanguage(subtitleSelect.value);
6821
+ });
6446
6822
  positionSelect.addEventListener('change', () => { STORE.set('nxu_sub_position', positionSelect.value); SUB_LAYOUT.schedule(); });
6447
6823
  providerSelect.addEventListener('change', () => { STORE.set('nxu_translation_provider', providerSelect.value); TRANSLATOR._cache.clear(); TRANSLATOR._llmHistory = []; refreshEngineHint(); });
6448
6824
  asrSelect.addEventListener('change', () => { STORE.set('nxu_asr_provider', asrSelect.value); refreshEngineHint(); TRANSLATOR.restart('recognition engine changed'); });
@@ -6503,6 +6879,13 @@
6503
6879
  #ui-wrapper.ui-idle.touch-peek .fab { pointer-events:auto !important; }
6504
6880
  #ui-wrapper.ui-idle.touch-peek > :not(.fab) { visibility:hidden !important; }
6505
6881
  button { font-family:inherit; }
6882
+ button, [role="button"], .seg-btn, .cc-btn, .react-btn { touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
6883
+ /* Touch devices: no backdrop blur. Blurring what lies behind a menu over a playing
6884
+ video is redone every frame and was the main cause of sluggish taps on iPhone. */
6885
+ @media (hover:none) and (pointer:coarse) {
6886
+ *, *::before, *::after { -webkit-backdrop-filter:none !important; backdrop-filter:none !important; }
6887
+ .nexus-container.nexus-container { --glass:rgba(20,25,30,0.5); --glass-strong:rgba(18,22,28,0.66); }
6888
+ }
6506
6889
  .fab { pointer-events:auto; position:absolute; width:48px; height:48px; border-radius:50%; background:var(--glass); border:1px solid rgba(255,255,255,0.22); color:#fff; cursor:grab; font-size:22px;
6507
6890
  backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px); box-shadow:0 4px 15px rgba(0,0,0,0.35); display:flex; align-items:center; justify-content:center; user-select:none; touch-action:none; z-index:101; padding:0; }
6508
6891
  .fab.menu-open { background:var(--glass-active); border-color:rgba(0,230,118,0.5); }
@@ -6529,7 +6912,16 @@
6529
6912
  .nx-spark { position:absolute; font-size:13px; pointer-events:none; transform:translate(-50%,-50%); opacity:0; animation:nxSpark .7s cubic-bezier(.2,.7,.3,1) both; z-index:2100; }
6530
6913
  @keyframes nxSpark { 0% { opacity:1; transform:translate(-50%,-50%) scale(.6); } 100% { opacity:0; transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.05) rotate(var(--rot)); } }
6531
6914
  @media (prefers-reduced-motion: reduce) { .react-btn.pop, .react-btn.pop::after, .nx-spark { animation:none !important; } }
6532
- .presence-pill { position:absolute; font-size:11px; padding:3px 8px; border-radius:99px; background:rgba(0,0,0,0.6); color:#e0e0e0; white-space:nowrap; pointer-events:auto; }
6915
+ .presence-pill { position:absolute; display:flex; gap:3px; align-items:center; font-size:11px; padding:3px 4px; border-radius:99px; background:rgba(0,0,0,0.45); color:#e0e0e0; white-space:nowrap; pointer-events:auto; cursor:pointer; max-width:min(78vw, 360px); overflow:hidden; }
6916
+ .presence-pill.open { flex-direction:column; align-items:stretch; border-radius:12px; padding:5px; max-height:50vh; overflow:auto; }
6917
+ .nx-who { display:inline-flex; align-items:center; gap:4px; padding:2px 7px 2px 5px; border-radius:99px; background:rgba(255,255,255,0.1); font-size:11.5px; font-weight:600; line-height:1.3; max-width:140px; color:rgba(255,255,255,0.92); text-shadow:0 1px 2px rgba(0,0,0,0.6); }
6918
+ .presence-pill.open .nx-who { max-width:none; }
6919
+ .nx-who.me { background:rgba(255,255,255,0.18); }
6920
+ .nx-who.away { opacity:0.55; }
6921
+ .nx-who.more { padding:2px 7px; }
6922
+ .nx-who-dot { flex:none; width:8px; height:8px; border-radius:50%; box-shadow:0 0 5px currentColor; }
6923
+ .nx-who-name { overflow:hidden; text-overflow:ellipsis; }
6924
+ .nx-who-tag { font-size:10px; }
6533
6925
  .dock { position:absolute; background:var(--glass-strong); border-radius:16px; padding:10px; display:flex; flex-direction:column; gap:6px; pointer-events:none; opacity:0; border:1px solid rgba(255,255,255,0.1);
6534
6926
  transition:opacity 0.25s ease, transform 0.25s ease; box-shadow:0 10px 30px rgba(0,0,0,0.35); backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px); z-index:90; overflow-y:auto; text-shadow:0 1px 2px rgba(0,0,0,0.8); overflow-x:hidden; width:clamp(150px, 40vw, 190px); width:clamp(150px, 40cqw, 190px); }
6535
6927
  .dock.open { opacity:1; pointer-events:auto; border-color:rgba(0,230,118,0.3); }
@@ -6597,6 +6989,12 @@
6597
6989
  .trans-check { width:18px; height:18px; accent-color:var(--accent); }
6598
6990
  .trans-help { font-size:11px; line-height:1.45; color:rgba(255,255,255,0.55); }
6599
6991
  .trans-help.center { text-align:center; margin-top:4px; }
6992
+ .seg { display:flex; gap:6px; }
6993
+ .seg-btn { flex:1; min-height:38px; padding:8px 6px; border-radius:10px; border:1px solid rgba(255,255,255,0.16); background:rgba(255,255,255,0.06); color:inherit; font:inherit; font-size:13px; font-weight:700; cursor:pointer; }
6994
+ .seg-btn.on { background:rgba(124,77,255,0.38); border-color:rgba(160,130,255,0.95); }
6995
+ .seg-btn:disabled { opacity:0.4; cursor:default; }
6996
+ .trans-select.need { outline:2px solid #ffca28; outline-offset:1px; animation:nxNeed 0.9s ease 3; }
6997
+ @keyframes nxNeed { 50% { outline-color:transparent; } }
6600
6998
  .range-row { display:flex; align-items:center; gap:8px; font-size:12px; margin-top:6px; }
6601
6999
  .range-row input { flex:1; accent-color:var(--accent); }
6602
7000
  .range-val { min-width:42px; text-align:right; color:rgba(255,255,255,0.7); }
@@ -6792,6 +7190,12 @@
6792
7190
  .shield-title { font-size:21px; font-weight:800; margin-bottom:12px; }
6793
7191
  .shield-text { opacity:0.8; margin-bottom:18px; line-height:1.45; font-size:14px; }
6794
7192
  .shield-btn { font-size:17px; padding:14px; }
7193
+ .sub-listen { display:flex; align-items:center; gap:7px; padding:4px 6px 4px 10px; border-radius:99px; background:rgba(0,0,0,0.45); color:rgba(255,255,255,0.88); font-size:12px; font-weight:600; text-shadow:0 1px 2px rgba(0,0,0,0.7); pointer-events:auto; transition:opacity 0.3s ease; }
7194
+ .sub-listen.hide { opacity:0; pointer-events:none; }
7195
+ .sub-listen.warn { background:rgba(120,60,0,0.6); }
7196
+ .sub-listen-meter { width:38px; height:5px; border-radius:3px; background:rgba(255,255,255,0.18); overflow:hidden; }
7197
+ .sub-listen-meter i { display:block; height:100%; width:0; background:#40c4ff; transition:width 0.35s ease; }
7198
+ .sub-listen-btn { border:0; border-radius:99px; padding:4px 10px; background:#7c4dff; color:#fff; font:inherit; font-size:12px; font-weight:700; cursor:pointer; }
6795
7199
  .sub-overlay-container { position:absolute; bottom:11%; left:50%; transform:translateX(-50%); width:clamp(280px, 90vw, 880px); width:clamp(280px, 90cqw, 880px); display:flex; flex-direction:column; align-items:center; gap:6px; transition:opacity 0.3s ease; z-index:70; user-select:none; }
6796
7200
  .sub-overlay-container.anchored { transition:opacity 0.3s ease; }
6797
7201
  .sub-slot { width:100%; display:flex; flex-direction:column; align-items:center; gap:6px; transition:opacity 0.25s ease; }
@@ -6857,7 +7261,7 @@
6857
7261
  .cc-title { color:#fff; font-size:15px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-shadow:0 1px 3px rgba(0,0,0,0.8); }
6858
7262
  .cc-room { display:none; align-items:center; gap:6px; font-size:12px; font-weight:600; color:rgba(255,255,255,0.85); text-shadow:0 1px 2px rgba(0,0,0,0.8); }
6859
7263
  .cc-room.show { display:flex; }
6860
- .cc-room::before { content:''; width:7px; height:7px; border-radius:50%; background:var(--cc-accent); box-shadow:0 0 6px var(--cc-accent); }
7264
+ .cc-room { flex-wrap:wrap; gap:4px; }
6861
7265
  .cc-bottom { bottom:0; padding:0 calc(14px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px)); }
6862
7266
  .cc-center { top:50%; display:none; justify-content:center; align-items:center; gap:clamp(28px, 10vw, 72px); transform:translateY(-50%); pointer-events:none; }
6863
7267
  .cinema-chrome.touch:not(.site-mode) .cc-center { display:flex; }
@@ -8024,6 +8428,10 @@
8024
8428
  this._canvas = createEl('canvas', 'nx-ink');
8025
8429
  container.appendChild(this._canvas);
8026
8430
  this._ctx = this._canvas.getContext('2d');
8431
+ if (!this._onResize) {
8432
+ this._onResize = () => { if (this.strokes.size) this._kick(); };
8433
+ window.addEventListener('resize', this._onResize, { passive: true });
8434
+ }
8027
8435
  }
8028
8436
  const dpr = Math.min(2, window.devicePixelRatio || 1);
8029
8437
  const w = container.clientWidth, h = container.clientHeight;
@@ -8041,6 +8449,10 @@
8041
8449
  ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
8042
8450
  const now = Date.now();
8043
8451
  const g = SOCIAL._picture();
8452
+ // Points are converted to screen positions once and reused while the picture's
8453
+ // geometry stays the same (before: every point of every stroke, every frame).
8454
+ const sig = (g ? [g.cx, g.cy, g.cw, g.ch, g.cos, g.sin].map(n => Math.round(n * 100)).join(',') : '') + '|' + window.innerWidth + 'x' + window.innerHeight + '|' + (typeof ROTATE !== 'undefined' ? ROTATE.deg || 0 : 0);
8455
+ let animate = false, wakeIn = Infinity;
8044
8456
  const toUi = ([u, v], ref) => {
8045
8457
  let x, y;
8046
8458
  if (ref === 'pic' && g) {
@@ -8054,7 +8466,11 @@
8054
8466
  const alpha = s.live ? 1 : age < this.HOLD_MS ? 1 : 1 - (age - this.HOLD_MS) / this.FADE_MS;
8055
8467
  if (alpha <= 0) { this.strokes.delete(id); continue; }
8056
8468
  if (s.pts.length < 1) continue;
8057
- const pts = s.pts.map(p => toUi(p, s.ref));
8469
+ if (s._sig !== sig) { s._sig = sig; s._ui = []; }
8470
+ while (s._ui.length < s.pts.length) s._ui.push(toUi(s.pts[s._ui.length], s.ref));
8471
+ const pts = s._ui;
8472
+ if (s.live || age < 400 || age >= this.HOLD_MS) animate = true;
8473
+ else wakeIn = Math.min(wakeIn, this.HOLD_MS - age);
8058
8474
  const path = () => {
8059
8475
  ctx.beginPath();
8060
8476
  ctx.moveTo(pts[0].x, pts[0].y);
@@ -8066,24 +8482,33 @@
8066
8482
  if (pts.length > 1) ctx.lineTo(pts[pts.length - 1].x, pts[pts.length - 1].y);
8067
8483
  };
8068
8484
  ctx.save();
8069
- ctx.globalAlpha = Math.max(0, Math.min(1, alpha));
8485
+ const a = Math.max(0, Math.min(1, alpha));
8070
8486
  ctx.lineCap = 'round'; ctx.lineJoin = 'round';
8071
- // Neon: a soft glow in the colour, then a bright core.
8072
- ctx.shadowColor = s.color; ctx.shadowBlur = 16;
8073
- ctx.strokeStyle = s.color; ctx.lineWidth = s.w + 3;
8487
+ // Neon look without shadowBlur (a blur per stroke per frame is what made quick
8488
+ // sketching lag): a wide translucent halo, the colour, then a bright core.
8489
+ ctx.globalAlpha = a * 0.28;
8490
+ ctx.strokeStyle = s.color; ctx.lineWidth = s.w + 10;
8491
+ path(); ctx.stroke();
8492
+ ctx.globalAlpha = a;
8493
+ ctx.lineWidth = s.w + 2.5;
8074
8494
  path(); ctx.stroke();
8075
- ctx.shadowBlur = 0;
8076
8495
  ctx.strokeStyle = 'rgba(255,255,255,0.85)'; ctx.lineWidth = Math.max(1.5, s.w * 0.4);
8077
8496
  path(); ctx.stroke();
8078
8497
  // A sparkle at the tip while it is being drawn.
8079
8498
  if (s.live || age < 400) {
8080
8499
  const tip = pts[pts.length - 1];
8081
- ctx.fillStyle = '#fff'; ctx.shadowColor = s.color; ctx.shadowBlur = 18;
8082
- ctx.beginPath(); ctx.arc(tip.x, tip.y, s.w * 0.9, 0, Math.PI * 2); ctx.fill();
8500
+ ctx.globalAlpha = a * 0.35; ctx.fillStyle = s.color;
8501
+ ctx.beginPath(); ctx.arc(tip.x, tip.y, s.w * 1.9, 0, Math.PI * 2); ctx.fill();
8502
+ ctx.globalAlpha = a; ctx.fillStyle = '#fff';
8503
+ ctx.beginPath(); ctx.arc(tip.x, tip.y, s.w * 0.8, 0, Math.PI * 2); ctx.fill();
8083
8504
  }
8084
8505
  ctx.restore();
8085
8506
  }
8086
- if (this.strokes.size) this._kick();
8507
+ // Redraw every frame only while something moves (drawing, the tip sparkle, fading);
8508
+ // finished strokes simply stay on the canvas until their fade begins.
8509
+ clearTimeout(this._wakeTimer);
8510
+ if (animate) this._kick();
8511
+ else if (wakeIn < Infinity) this._wakeTimer = setTimeout(() => this._kick(), wakeIn + 5);
8087
8512
  },
8088
8513
  active() { return !!this._catcher?.isConnected; },
8089
8514
  start() {
@@ -8380,7 +8805,8 @@
8380
8805
  if (!info) return false;
8381
8806
  const r = info.el.getBoundingClientRect();
8382
8807
  if (r.width < Math.min(420, window.innerWidth * 0.6)) return false;
8383
- return Number.isFinite(info.duration) && info.duration >= 90;
8808
+ // A movie or episode โ€” or a live channel (endless, or a short moving window).
8809
+ return !!info.live || (Number.isFinite(info.duration) && info.duration >= 90);
8384
8810
  },
8385
8811
  tick() {
8386
8812
  if (!IS_TOP || STATE.retired || STATE.isCinema || STATE.pendingCinema || document.hidden) return;
@@ -10348,9 +10774,9 @@
10348
10774
  e.spinnerLabel.textContent = roomWait
10349
10775
  ? (room.sourceDeviceId === STATE.userId ? t('ccWaitSelf') : t('ccWaitPeer', { name: participantName(room.sourceDeviceId) }))
10350
10776
  : '';
10351
- const peers = STATE.handshakeVerified ? Math.max(1, Object.keys(STATE.presenceMap || {}).length) : 0;
10777
+ const peers = STATE.handshakeVerified ? Object.keys(STATE.presenceMap || {}).length : 0;
10352
10778
  e.room.classList.toggle('show', peers > 0);
10353
- if (peers) e.room.textContent = t('ccWatching', { n: peers });
10779
+ if (peers) renderRoster(e.room, 4);
10354
10780
 
10355
10781
  e.seek.style.visibility = duration ? '' : 'hidden';
10356
10782
  if (!this._scrubbing) {
@@ -10643,7 +11069,7 @@
10643
11069
  if (!inUse && this.isClipLike(v)) return false;
10644
11070
  if (v === STATE.video && v.readyState >= 1) return true;
10645
11071
  const dur = v.duration;
10646
- if (Number.isFinite(dur) && dur > 0 && dur < 8) return false;
11072
+ if (Number.isFinite(dur) && dur > 0 && dur < 8 && !this.isLive(v)) return false;
10647
11073
  if (+style.opacity === 0) return false;
10648
11074
  const rect = v.getBoundingClientRect();
10649
11075
  // Parked off-page (preloaded ads, hidden players): left of / above the document.
@@ -10658,12 +11084,22 @@
10658
11084
  // video (gifv, ์›€์งค, hero backgrounds) or a short muted autoplay clip without controls
10659
11085
  // (feed previews, many video ads). Unmuting or adding controls makes it media again
10660
11086
  // (volumechange triggers a rescan).
11087
+ // A live stream: endless, or a moving window (HLS players report the window's few
11088
+ // seconds as the "duration", and the playable range no longer starts at 0).
11089
+ isLive(v) {
11090
+ try {
11091
+ if (!v) return false;
11092
+ if (v.duration === Infinity || v._nxuLive) return true;
11093
+ const s = v.seekable;
11094
+ return !!(s && s.length && s.start(0) > 0.5 && !v.loop);
11095
+ } catch (_) { return false; }
11096
+ },
10661
11097
  isClipLike(v) {
10662
11098
  const silent = v.muted || v.volume === 0;
10663
11099
  if (!silent || v.controls || v.hasAttribute('data-nxu-user-played')) return false;
10664
11100
  if (v.loop) return true;
10665
11101
  const dur = v.duration;
10666
- if (dur === Infinity) return false; // live stream
11102
+ if (this.isLive(v)) return false; // live stream (a TV channel)
10667
11103
  // Silent short clips without controls (previews, ads, animated clips) โ€” unless the
10668
11104
  // user started them; long silent videos (muted players) still count.
10669
11105
  return Number.isNaN(dur) || (dur > 0 && dur < 60);
@@ -10733,7 +11169,23 @@
10733
11169
  return score;
10734
11170
  },
10735
11171
 
11172
+ // HLS live players start the stream at 0 and grow the "duration" as segments arrive:
11173
+ // a duration that keeps growing while it plays marks a live channel.
11174
+ _watchLive(v) {
11175
+ if (v._nxuLiveWatch) return;
11176
+ v._nxuLiveWatch = true;
11177
+ let last = v.duration;
11178
+ v.addEventListener('durationchange', () => {
11179
+ const d = v.duration;
11180
+ if (Number.isFinite(d) && Number.isFinite(last) && d > last + 0.5 && d - last < 120 && !v._nxuLive) {
11181
+ v._nxuLive = true;
11182
+ this.scheduleScan(30);
11183
+ }
11184
+ last = d;
11185
+ });
11186
+ },
10736
11187
  _videoInfo(v) {
11188
+ this._watchLive(v);
10737
11189
  const playing = !!(v.isConnected && !v.paused && !v.ended && v.readyState >= 2);
10738
11190
  let score = this._scoreRect(rectInTop(v), playing);
10739
11191
  if (!v.ended) score += 500;
@@ -10885,11 +11337,11 @@
10885
11337
  msg = {
10886
11338
  type: 'NXU_VIDEO_FOUND', videoW: v.videoWidth || 0, videoH: v.videoHeight || 0,
10887
11339
  duration: Number.isFinite(v.duration) ? v.duration : null, paused: !!v.paused,
10888
- playing: !v.paused && !v.ended && v.readyState >= 2
11340
+ playing: !v.paused && !v.ended && v.readyState >= 2, live: this.isLive(v)
10889
11341
  };
10890
11342
  } else if (STATE.cinemaIframe) {
10891
11343
  const rep = this.frameReports.get(STATE.cinemaIframe) || {};
10892
- msg = { type: 'NXU_VIDEO_FOUND', videoW: rep.w || 0, videoH: rep.h || 0, duration: Number.isFinite(rep.duration) ? rep.duration : null, paused: rep.paused !== false, playing: !!rep.playing };
11344
+ msg = { type: 'NXU_VIDEO_FOUND', videoW: rep.w || 0, videoH: rep.h || 0, duration: Number.isFinite(rep.duration) ? rep.duration : null, paused: rep.paused !== false, playing: !!rep.playing, live: !!rep.live };
10893
11345
  }
10894
11346
  if (msg) {
10895
11347
  const sig = JSON.stringify(msg);
@@ -10927,7 +11379,7 @@
10927
11379
  FRAME.postToParent({
10928
11380
  type: 'NXU_VIDEO_EVENT', event: evt,
10929
11381
  currentTime: video.currentTime, paused: video.paused, playbackRate: RATE.base(video),
10930
- duration: Number.isFinite(video.duration) ? video.duration : null,
11382
+ duration: Number.isFinite(video.duration) ? video.duration : null, live: this.isLive(video),
10931
11383
  volume: video.volume, muted: video.muted, buffered: bufferedEnd(video),
10932
11384
  remoteEventId: Date.now() < (video._nxuRemoteUntil || 0) && String(video._nxuRemoteKinds || '').split(' ').includes(evt) ? video._nxuRemoteEventId : null,
10933
11385
  userGesture
@@ -11013,7 +11465,7 @@
11013
11465
  case 'NXU_VIDEO_FOUND':
11014
11466
  this._watchFrameBox(ifr);
11015
11467
  this.frameReports.set(ifr, {
11016
- w: data.videoW, h: data.videoH, duration: data.duration, paused: data.paused !== false,
11468
+ w: data.videoW, h: data.videoH, duration: data.duration, live: !!data.live, paused: data.paused !== false,
11017
11469
  playing: !!data.playing, currentTime: this.frameReports.get(ifr)?.currentTime || 0, ts: Date.now()
11018
11470
  });
11019
11471
  if (isTarget && !IS_TOP) this._reportUp();
@@ -11039,6 +11491,7 @@
11039
11491
  rep.playing = !data.paused && !rep.waiting;
11040
11492
  rep.currentTime = data.currentTime;
11041
11493
  if (Number.isFinite(data.duration)) rep.duration = data.duration;
11494
+ if (typeof data.live === 'boolean') rep.live = data.live;
11042
11495
  rep.ts = Date.now();
11043
11496
  this.frameReports.set(ifr, rep);
11044
11497
  // A frame we are not using yet started playing: it may be the real player.
@@ -11275,8 +11728,10 @@
11275
11728
  });
11276
11729
 
11277
11730
  // Genuine user gestures distinguish user playback from site auto-resume.
11731
+ // On window (capture): the earliest listener, so a page that stops the event in its own
11732
+ // handler (many players do for Space) cannot hide the gesture.
11278
11733
  ['pointerdown', 'mousedown', 'touchstart', 'keydown'].forEach(type => {
11279
- document.addEventListener(type, () => { if (!MEDIA_SAFE._simulatingKey) STATE._lastUserGestureTs = Date.now(); }, { capture: true, passive: true });
11734
+ window.addEventListener(type, (e) => { if (!MEDIA_SAFE._simulatingKey && e.isTrusted !== false) STATE._lastUserGestureTs = Date.now(); }, { capture: true, passive: true });
11280
11735
  });
11281
11736
  // What the user clicked/tapped (a scroll never produces a click): tells a video the user
11282
11737
  // started apart from autoplay previews that start while scrolling a feed.
@@ -11307,6 +11762,36 @@
11307
11762
  }
11308
11763
  };
11309
11764
 
11765
+ // Space bar = play / pause for the room's video, wherever the keyboard focus is.
11766
+ // Often the page itself cannot do it: the player sits in another site's frame (keys go
11767
+ // to the top page), or the focus stayed on a NexusSync button (Space would press that
11768
+ // button). The page gets the first chance; if the video did not change, we toggle it.
11769
+ const SPACE_KEY = {
11770
+ handle(e, target) {
11771
+ if (e.code !== 'Space' || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return false;
11772
+ const info = currentMediaInfo();
11773
+ if (!info) return false;
11774
+ const host = shadow?.host;
11775
+ const inUi = !!host && (typeof e.composedPath === 'function' ? e.composedPath().includes(host) : false);
11776
+ // A frame player cannot hear the key, and a focused NexusSync button must not be pressed.
11777
+ if (inUi || info.kind === 'iframe') {
11778
+ e.preventDefault();
11779
+ e.stopPropagation();
11780
+ if (!e.repeat) { applyMediaCommand('toggle'); STATE._ownControlAt = Date.now(); }
11781
+ try { if (inUi && target && typeof target.blur === 'function' && target.tagName === 'BUTTON') target.blur(); } catch (_) { }
11782
+ return true;
11783
+ }
11784
+ if (e.repeat || STATE.role === 'IDLE') return false;
11785
+ const before = info.paused, el = info.el;
11786
+ clearTimeout(this._timer);
11787
+ this._timer = setTimeout(() => {
11788
+ const now = currentMediaInfo();
11789
+ if (now && now.el === el && now.paused === before) applyMediaCommand('toggle');
11790
+ }, 320);
11791
+ return false;
11792
+ }
11793
+ };
11794
+
11310
11795
  document.addEventListener('keydown', (e) => {
11311
11796
  // Our own simulated key (player fallback) and page-generated keys are not shortcuts.
11312
11797
  if (STATE.retired || MEDIA_SAFE._simulatingKey || !e.isTrusted) return;
@@ -11324,6 +11809,7 @@
11324
11809
  }
11325
11810
  if (isEditableTarget(target) && !(isPlayerSlider(target) && STATE.isCinema)) return;
11326
11811
  if (STATE.isCinema && (IS_TOP || STATE.video) && CINEMA_UI.handleKey(e)) return;
11812
+ if (IS_TOP && SPACE_KEY.handle(e, target)) return;
11327
11813
  if (e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey && HOTKEYS.map[e.code]) {
11328
11814
  e.preventDefault();
11329
11815
  e.stopPropagation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kangsicj/nexussync",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "Watch-together userscript: media sync, cinema mode, live AI subtitles, chat bubbles and quick ink for Tampermonkey and iOS Userscripts.",
5
5
  "keywords": [
6
6
  "userscript",