@kangsicj/nexussync 1.6.4 → 1.6.6
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/dist/NexusSync.meta.js +1 -1
- package/dist/NexusSync.user.js +168 -24
- package/package.json +1 -1
package/dist/NexusSync.meta.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// @icon https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/assets/icon.svg
|
|
9
9
|
// @updateURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.meta.js
|
|
10
10
|
// @downloadURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js
|
|
11
|
-
// @version 1.6.
|
|
11
|
+
// @version 1.6.6
|
|
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 *://*/*
|
package/dist/NexusSync.user.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// @icon https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/assets/icon.svg
|
|
9
9
|
// @updateURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.meta.js
|
|
10
10
|
// @downloadURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js
|
|
11
|
-
// @version 1.6.
|
|
11
|
+
// @version 1.6.6
|
|
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.
|
|
49
|
+
const NXU_VERSION = '1.6.6';
|
|
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.
|
|
54
|
+
const NXU_RANK = '11.6.6';
|
|
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=';
|
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
return ['snap', 'env'].includes(data.op) && str(data.rid) && (data.img === undefined || data.img === null || (typeof data.img === 'string' && data.img.length < 90000 && data.img.startsWith('data:image/'))) && num(data.t) && arr(data.a) && arr(data.l) && arr(data.ts);
|
|
354
354
|
}
|
|
355
355
|
case 'NXU_CAPTION':
|
|
356
|
-
return ['final', 'interim', 'clear'].includes(data.mode) && str(data.text) && str(data.original) && str(data.color) && num(data.size);
|
|
356
|
+
return ['final', 'interim', 'clear', 'sub'].includes(data.mode) && str(data.text) && str(data.original) && str(data.color) && num(data.size);
|
|
357
357
|
default:
|
|
358
358
|
return false;
|
|
359
359
|
}
|
|
@@ -660,7 +660,7 @@
|
|
|
660
660
|
inkClosing: 'Closing soon — move or tap to keep drawing',
|
|
661
661
|
modeSitePlayer: 'Site player in use', modeNexusPlayer: 'NexusSync player in use', modeSiteHint: 'Change subtitles or the server in the site’s player, then switch.', modeSiteHintAuto: 'Cinema started by itself. Pick subtitles or a server in the site’s player first if needed, then switch.', modeNexusHint: 'Everything is controlled by NexusSync. The site’s own settings are one tap away.', modeUseNexus: 'Use NexusSync player', modeUseSite: 'Use site player', autoCinemaStopSite: 'No auto-cinema on this site', autoCinemaOnSite: 'Auto-cinema on for {site}', autoCinemaOffSite: 'Auto-cinema off for {site}', autoCinemaBtnOn: 'Auto-cinema: on (this site)', autoCinemaBtnOff: 'Auto-cinema: off (this site)', adGuardOn: 'Ad guard: on', adGuardOff: 'Ad guard: off', adGuardHid: 'Hid an ad / link laid over the video', adGuardPopup: 'Stopped an ad pop-up', ccPip: 'Picture-in-Picture (keep watching in a small window)', nextEpTitle: 'Up next', nextEpGo: 'Next episode', nextEpCancel: 'Stay on this episode', nextEpGoing: 'Next episode…', talkMenu: 'Chat', inkMenu: 'Quick sketch', quickEdit: 'Edit quick replies', quickEditHint: 'Separate with |', quickReset: 'Back to the default replies', save: 'Save',
|
|
662
662
|
talkTitle: 'Chat bubble', talkPlaceholder: 'Say something…', talkReplyTo: '↩ Reply to {name}', talkClose: 'Close', talkSend: 'Send', talkFull: 'Open the chat history (every message so far)', talkHistory: 'History',
|
|
663
|
-
inkTitle: 'Quick sketch (fades
|
|
663
|
+
inkTitle: 'Quick sketch (fades when you stop)', inkHint: 'Draw on the screen — it fades 10 seconds after you stop', inkDone: 'Done', inkBubble: 'is sketching on the screen — tap to draw back',
|
|
664
664
|
you: 'You', roomBuffering: '⏳ {name} is loading… everyone waits', roomResume: '▶️ Everyone is ready — playing together', roomRate: '⏩ Speed {rate}x synced',
|
|
665
665
|
youBuffering: '⏳ Your video is loading — the room waits for you', shieldResumeTitle: 'Tap to rejoin playback', shieldResumeText: 'The browser paused this video. Tap once to continue in sync with the room.',
|
|
666
666
|
shieldResumeButton: 'RESUME ▶️', rateTitle: 'Playback speed (shared with the room)', rateSet: '⏩ Speed {rate}x', resynced: 'Re-synced with the room',
|
|
@@ -714,6 +714,7 @@
|
|
|
714
714
|
subUsingMicFallback: 'The video sound could not be heard directly — listening through the microphone (turn the speakers up).',
|
|
715
715
|
subTabShareEnded: 'Tab audio sharing stopped, so subtitles were turned off.',
|
|
716
716
|
subHearVideo: '🎧 Listening to the video', subHearMic: '🎧 Listening through the microphone', subVideoSilent: '🔇 No sound reaches the subtitles from this video',
|
|
717
|
+
subNoWords: '⚠️ The speech engine hears sound but returns no words here. Add a free Groq key in AI Sub → Advanced to use AI recognition instead.', subNoWordsEdge: '⚠️ Edge’s speech engine hears the video but returns no words. Use Chrome, or add a free Groq key in AI Sub → Advanced (works in Edge).', subNoWordsKey: '⚠️ The browser’s speech engine returns no words here — switching to AI recognition with your key.',
|
|
717
718
|
subDiagCopy: 'Copy a problem report', subDiagCopied: '🔬 Report copied — paste it in your message', subDiagInDebug: '🔬 Report written to the debug console (Settings → Advanced → Debug)',
|
|
718
719
|
subNoTrackInput: '⚠️ This browser’s speech engine cannot listen to the video sound directly — it only hears the microphone (play the sound through speakers, not headphones), or add a free Groq key in AI Sub → Advanced.', subIssueNoTrack: 'The speech engine only hears the microphone here', subNoService: '⚠️ This browser has no working speech recognition service (it works in Chrome). Add a free Groq or an OpenAI key in AI Sub → Advanced to use AI recognition instead.', subNoServiceKey: '⚠️ This browser has no working speech recognition service — switching to AI recognition with your key.',
|
|
719
720
|
subIssueNet: '⚠️ Speech service connection is unstable — retrying', subIssueNoResult: '⚠️ Sound arrives but no words are recognised', subSiteBlocksSpeech: 'This site does not allow the browser’s speech recognition. Add an OpenAI or Groq key (AI subtitles → Advanced) to use AI subtitles here.', subSiteBlocksSpeechKey: 'This site blocks the browser’s speech recognition — switching to cloud recognition with your key.', subTryMic: '🎤 Listen through the mic', subTryKey: '🔑 Use an AI recognition key', subShareTab: '🎬 Connect tab sound', subTabNotShared: 'Tab audio was not shared. Choose this tab and turn on “Share tab audio”.',
|
|
@@ -778,7 +779,7 @@
|
|
|
778
779
|
inkClosing: '곧 닫혀요 — 계속 그리려면 움직이거나 눌러 주세요',
|
|
779
780
|
modeSitePlayer: '사이트 플레이어 사용 중', modeNexusPlayer: 'NexusSync 플레이어 사용 중', modeSiteHint: '자막이나 서버는 사이트 플레이어에서 바꾼 뒤 전환하세요.', modeSiteHintAuto: '시네마 모드가 자동으로 켜졌어요. 필요하면 사이트 플레이어에서 자막·서버를 먼저 고른 뒤 전환하세요.', modeNexusHint: 'NexusSync가 모든 조작을 맡아요. 사이트 설정은 한 번 탭으로 돌아갈 수 있어요.', modeUseNexus: 'NexusSync 플레이어로', modeUseSite: '사이트 플레이어로', autoCinemaStopSite: '이 사이트는 자동 시네마 끄기', autoCinemaOnSite: '{site}에서 자동 시네마 켜짐', autoCinemaOffSite: '{site}에서 자동 시네마 꺼짐', autoCinemaBtnOn: '자동 시네마: 켬 (이 사이트)', autoCinemaBtnOff: '자동 시네마: 끔 (이 사이트)', adGuardOn: '광고 가리기: 켬', adGuardOff: '광고 가리기: 끔', adGuardHid: '영상 위에 덮인 광고·링크를 숨겼어요', adGuardPopup: '광고 팝업을 막았어요', ccPip: 'PiP (작은 창으로 계속 보기)', nextEpTitle: '다음 화', nextEpGo: '다음 화 보기', nextEpCancel: '이번 화에 머물기', nextEpGoing: '다음 화로 이동하는 중…', talkMenu: '말풍선 채팅', inkMenu: '잠깐 그리기', quickEdit: '빠른 답장 편집', quickEditHint: '| 로 구분', quickReset: '기본 답장으로', save: '저장',
|
|
780
781
|
talkTitle: '말풍선 채팅', talkPlaceholder: '메시지 보내기…', talkReplyTo: '↩ {name} 님에게 답장', talkClose: '닫기', talkSend: '보내기', talkFull: '지금까지의 대화 기록 전체 보기', talkHistory: '대화 기록',
|
|
781
|
-
inkTitle: '잠깐 그리기 (
|
|
782
|
+
inkTitle: '잠깐 그리기 (멈추면 잠시 뒤 사라짐)', inkHint: '화면에 그려 보세요 — 그리기를 멈추고 10초 뒤 사라져요', inkDone: '완료', inkBubble: '님이 화면에 그리고 있어요 — 탭해서 같이 그리기',
|
|
782
783
|
you: '나', roomBuffering: '⏳ {name} 기기 로딩 중… 모두 잠시 대기', roomResume: '▶️ 모두 준비됨 — 함께 재생합니다', roomRate: '⏩ {rate}배속 동기화',
|
|
783
784
|
youBuffering: '⏳ 이 기기 영상 로딩 중 — 방이 기다려 줍니다', shieldResumeTitle: '탭해서 다시 재생', shieldResumeText: '브라우저가 이 영상을 멈췄습니다. 한 번 탭하면 방과 맞춰 이어서 재생합니다.',
|
|
784
785
|
shieldResumeButton: '이어서 재생 ▶️', rateTitle: '재생 속도 (방 전체와 공유)', rateSet: '⏩ {rate}배속', resynced: '방과 다시 맞췄습니다',
|
|
@@ -832,6 +833,7 @@
|
|
|
832
833
|
subUsingMicFallback: '영상 소리를 직접 들을 수 없어 마이크로 들어요. 스피커 소리를 키워 주세요.',
|
|
833
834
|
subTabShareEnded: '탭 오디오 공유가 끝나서 자막을 껐어요.',
|
|
834
835
|
subHearVideo: '🎧 영상 소리 듣는 중', subHearMic: '🎧 마이크로 듣는 중', subVideoSilent: '🔇 이 영상의 소리가 자막에 전달되지 않아요',
|
|
836
|
+
subNoWords: '⚠️ 음성 인식이 소리는 듣지만 말을 알아듣지 못하고 있어요. AI 자막 → 고급에서 무료 Groq 키를 넣으면 AI 인식으로 쓸 수 있어요.', subNoWordsEdge: '⚠️ Edge의 음성 인식이 영상 소리를 받지만 말을 알아듣지 못하고 있어요. Chrome을 쓰거나, AI 자막 → 고급에서 무료 Groq 키를 넣어 주세요 (Edge에서도 동작해요).', subNoWordsKey: '⚠️ 브라우저 음성 인식이 말을 알아듣지 못해 입력한 키로 AI 인식을 시작해요.',
|
|
835
837
|
subDiagCopy: '문제 진단 보고서 복사', subDiagCopied: '🔬 진단 보고서를 복사했어요 — 메시지에 붙여 넣어 주세요', subDiagInDebug: '🔬 진단 보고서를 디버그 콘솔에 남겼어요 (설정 → 고급 → 디버그)',
|
|
836
838
|
subNoTrackInput: '⚠️ 이 브라우저의 음성 인식은 영상 소리를 직접 듣지 못하고 마이크로만 들어요. 이어폰 대신 스피커로 소리를 내거나, AI 자막 → 고급에서 무료 Groq 키를 넣어 주세요.', subIssueNoTrack: '이 브라우저는 마이크로만 들을 수 있어요', subNoService: '⚠️ 이 브라우저에는 동작하는 음성 인식 서비스가 없어요 (Chrome에서는 동작해요). AI 자막 → 고급에서 무료 Groq 키나 OpenAI 키를 넣으면 AI 인식으로 쓸 수 있어요.', subNoServiceKey: '⚠️ 이 브라우저에는 동작하는 음성 인식 서비스가 없어 입력한 키로 AI 인식을 시작해요.',
|
|
837
839
|
subIssueNet: '⚠️ 음성 인식 서버 연결이 불안정해요 — 다시 시도 중', subIssueNoResult: '⚠️ 소리는 들어오는데 말이 인식되지 않아요', subSiteBlocksSpeech: '이 사이트는 브라우저 음성 인식을 막아 두었어요. AI 자막 → 고급에서 OpenAI 또는 Groq 키를 넣으면 여기서도 쓸 수 있어요.', subSiteBlocksSpeechKey: '이 사이트는 브라우저 음성 인식을 막아 두어서, 넣어 둔 키로 클라우드 인식으로 바꿀게요.', subTryMic: '🎤 마이크로 듣기', subTryKey: '🔑 AI 인식 키 사용', subShareTab: '🎬 탭 소리 연결', subTabNotShared: '탭 오디오가 공유되지 않았어요. 이 탭을 고르고 “탭 오디오 공유”를 켜 주세요.',
|
|
@@ -1803,13 +1805,20 @@
|
|
|
1803
1805
|
},
|
|
1804
1806
|
_isSub(tr) { return tr && (tr.kind === 'subtitles' || tr.kind === 'captions'); },
|
|
1805
1807
|
// Take over every subtitle track the browser is drawing; forget tracks the site turned off.
|
|
1808
|
+
nativeFullscreen(v, on) {
|
|
1809
|
+
if (v !== this.video) return;
|
|
1810
|
+
this._nativeFs = on;
|
|
1811
|
+
const showOwn = on && !(typeof SUBS !== 'undefined' && SUBS.active());
|
|
1812
|
+
for (const tr of this.owned) { try { tr.mode = showOwn ? 'showing' : 'hidden'; this._ours++; } catch (_) { } }
|
|
1813
|
+
if (!on) this.render();
|
|
1814
|
+
},
|
|
1806
1815
|
_claim() {
|
|
1807
1816
|
const v = this.video;
|
|
1808
|
-
if (!v) return;
|
|
1817
|
+
if (!v || this._nativeFs) return;
|
|
1809
1818
|
let list;
|
|
1810
1819
|
try { list = [...v.textTracks]; } catch (_) { return; }
|
|
1811
1820
|
for (const tr of list) {
|
|
1812
|
-
if (!this._isSub(tr)) continue;
|
|
1821
|
+
if (!this._isSub(tr) || tr === v._nxuFsTrack) continue;
|
|
1813
1822
|
if (tr.mode === 'showing') {
|
|
1814
1823
|
try { tr.mode = 'hidden'; this._ours++; } catch (_) { continue; }
|
|
1815
1824
|
if (!this.owned.has(tr)) { this.owned.add(tr); tr.addEventListener('cuechange', this._onCue); }
|
|
@@ -2155,6 +2164,77 @@
|
|
|
2155
2164
|
// ───────────────────────── Caption mirror (child frames in element fullscreen)
|
|
2156
2165
|
// When an embedded player is fullscreen, the top document cannot paint over it,
|
|
2157
2166
|
// so the top frame forwards captions and this renders them inside the frame.
|
|
2167
|
+
// When the <video> element itself goes fullscreen (the site's or the browser's own
|
|
2168
|
+
// fullscreen button, a double-click on native controls, the iPhone's player), the browser
|
|
2169
|
+
// paints nothing but the video: no page layer can show text there. Whatever subtitles are
|
|
2170
|
+
// on screen then go into a text track of that video, which the browser does draw, and the
|
|
2171
|
+
// video's own tracks NexusSync had taken over are handed back while it lasts.
|
|
2172
|
+
const FS_SUBS = {
|
|
2173
|
+
video: null, _text: '', _ios: null,
|
|
2174
|
+
_fsVideo() {
|
|
2175
|
+
const fse = document.fullscreenElement || document.webkitFullscreenElement;
|
|
2176
|
+
if (fse && fse.tagName === 'VIDEO') return fse;
|
|
2177
|
+
return this._ios && this._ios.isConnected && this._ios.webkitDisplayingFullscreen !== false ? this._ios : null;
|
|
2178
|
+
},
|
|
2179
|
+
update() {
|
|
2180
|
+
const v = this._fsVideo();
|
|
2181
|
+
if (v === this.video) return;
|
|
2182
|
+
if (this.video) this._leave(this.video);
|
|
2183
|
+
this.video = v;
|
|
2184
|
+
if (v) {
|
|
2185
|
+
logDebug('Video fullscreen: subtitles move into a track of the video.', 'info');
|
|
2186
|
+
try { CUE_MIRROR.nativeFullscreen(v, true); } catch (_) { }
|
|
2187
|
+
this._show(this._text);
|
|
2188
|
+
}
|
|
2189
|
+
},
|
|
2190
|
+
// What NexusSync is showing right now ('' = nothing).
|
|
2191
|
+
feed(text) {
|
|
2192
|
+
text = String(text || '').trim();
|
|
2193
|
+
if (text === this._text && (!this.video || this._shown === text)) return;
|
|
2194
|
+
this._text = text;
|
|
2195
|
+
if (this.video) this._show(text);
|
|
2196
|
+
else if (IS_TOP && SUB_LAYOUT.mirrorFrame?.isConnected) {
|
|
2197
|
+
// The player sits in a frame that is fullscreen: the frame shows the lines itself.
|
|
2198
|
+
FRAME.postToFrame(SUB_LAYOUT.mirrorFrame, { type: 'NXU_CAPTION', mode: text ? 'sub' : 'clear', text, original: '', color: '', size: Math.round(22 * (typeof SUBS !== 'undefined' ? SUBS.size() : 1)) });
|
|
2199
|
+
}
|
|
2200
|
+
},
|
|
2201
|
+
showOn(v, text) { if (v !== this.video) { if (this.video) this._leave(this.video); this.video = v; } this._text = String(text || '').trim(); this._show(this._text); },
|
|
2202
|
+
_track(v) {
|
|
2203
|
+
if (v._nxuFsTrack) return v._nxuFsTrack;
|
|
2204
|
+
try { v._nxuFsTrack = v.addTextTrack('subtitles', 'NexusSync', (STORE.get('nxu_subtitle_language', '') || navigator.language || 'en').slice(0, 2)); } catch (_) { return null; }
|
|
2205
|
+
return v._nxuFsTrack;
|
|
2206
|
+
},
|
|
2207
|
+
_clear(tr) { try { [...(tr.cues || [])].forEach(c => tr.removeCue(c)); } catch (_) { } },
|
|
2208
|
+
_show(text) {
|
|
2209
|
+
const v = this.video;
|
|
2210
|
+
if (!v) return;
|
|
2211
|
+
const tr = this._track(v);
|
|
2212
|
+
if (!tr) return;
|
|
2213
|
+
this._shown = text;
|
|
2214
|
+
try { tr.mode = 'showing'; } catch (_) { }
|
|
2215
|
+
this._clear(tr);
|
|
2216
|
+
if (!text) return;
|
|
2217
|
+
const Cue = window.VTTCue || window.TextTrackCue;
|
|
2218
|
+
if (!Cue) return;
|
|
2219
|
+
try {
|
|
2220
|
+
const at = Number.isFinite(v.currentTime) ? v.currentTime : 0;
|
|
2221
|
+
// One cue that lasts until the text changes (replaced on every change).
|
|
2222
|
+
tr.addCue(new Cue(Math.max(0, at - 0.25), at + 6 * 3600, text));
|
|
2223
|
+
} catch (_) { }
|
|
2224
|
+
},
|
|
2225
|
+
_leave(v) {
|
|
2226
|
+
const tr = v._nxuFsTrack;
|
|
2227
|
+
if (tr) { this._clear(tr); try { tr.mode = 'disabled'; } catch (_) { } }
|
|
2228
|
+
this._shown = null;
|
|
2229
|
+
try { CUE_MIRROR.nativeFullscreen(v, false); } catch (_) { }
|
|
2230
|
+
}
|
|
2231
|
+
};
|
|
2232
|
+
document.addEventListener('fullscreenchange', () => FS_SUBS.update());
|
|
2233
|
+
document.addEventListener('webkitfullscreenchange', () => FS_SUBS.update());
|
|
2234
|
+
// iPhone/iPad native player: these events are sent to the <video> only.
|
|
2235
|
+
document.addEventListener('webkitbeginfullscreen', (ev) => { if (ev.target?.tagName === 'VIDEO') { FS_SUBS._ios = ev.target; FS_SUBS.update(); } }, true);
|
|
2236
|
+
document.addEventListener('webkitendfullscreen', (ev) => { if (ev.target === FS_SUBS._ios) { FS_SUBS._ios = null; FS_SUBS.update(); } }, true);
|
|
2237
|
+
|
|
2158
2238
|
const CAPTION_MIRROR = {
|
|
2159
2239
|
host: null,
|
|
2160
2240
|
root: null,
|
|
@@ -2180,7 +2260,9 @@
|
|
|
2180
2260
|
return this.root.querySelector('.box');
|
|
2181
2261
|
},
|
|
2182
2262
|
render(data) {
|
|
2183
|
-
|
|
2263
|
+
const fsv = document.fullscreenElement || document.webkitFullscreenElement;
|
|
2264
|
+
if ((fsv && fsv.tagName === 'VIDEO') || FS_SUBS._ios) { FS_SUBS.showOn(fsv && fsv.tagName === 'VIDEO' ? fsv : FS_SUBS._ios, data.mode === 'clear' ? '' : data.text); return; }
|
|
2265
|
+
if (data.mode === 'clear' || (data.mode === 'sub' && !data.text)) { this.remove(); return; }
|
|
2184
2266
|
const box = this._ensure();
|
|
2185
2267
|
if (!box) return;
|
|
2186
2268
|
const size = Math.max(12, Math.min(48, data.size || 22));
|
|
@@ -2205,7 +2287,8 @@
|
|
|
2205
2287
|
box.replaceChildren(card);
|
|
2206
2288
|
}
|
|
2207
2289
|
clearTimeout(this.timer);
|
|
2208
|
-
|
|
2290
|
+
// Subtitles of a file or track stay until the next line; AI lines fade after 15 s.
|
|
2291
|
+
if (data.mode !== 'sub') this.timer = setTimeout(() => this.remove(), 15000);
|
|
2209
2292
|
},
|
|
2210
2293
|
remove() {
|
|
2211
2294
|
clearTimeout(this.timer);
|
|
@@ -2716,8 +2799,14 @@
|
|
|
2716
2799
|
const mixGain = ctx.createGain();
|
|
2717
2800
|
mixGain.gain.value = micForMix && web ? 0.75 : 1;
|
|
2718
2801
|
const dest = ctx.createMediaStreamDestination();
|
|
2719
|
-
|
|
2720
|
-
|
|
2802
|
+
// The copy the engine may listen to: quiet speech (a low player volume, a
|
|
2803
|
+
// shared tab) is evened out and raised, loud effects are held back.
|
|
2804
|
+
const comp = ctx.createDynamicsCompressor();
|
|
2805
|
+
try { comp.threshold.value = -42; comp.knee.value = 18; comp.ratio.value = 6; comp.attack.value = 0.005; comp.release.value = 0.25; } catch (_) { }
|
|
2806
|
+
const makeup = ctx.createGain();
|
|
2807
|
+
makeup.gain.value = 3;
|
|
2808
|
+
mixGain.connect(comp); comp.connect(makeup); makeup.connect(dest);
|
|
2809
|
+
const nodes = { list: [mixGain, comp, makeup], analysers: {}, mix: mixGain };
|
|
2721
2810
|
const connect = (stream, label) => {
|
|
2722
2811
|
if (!stream) return;
|
|
2723
2812
|
const source = ctx.createMediaStreamSource(stream);
|
|
@@ -2975,7 +3064,19 @@
|
|
|
2975
3064
|
// Plenty of sound but not a single word back: try the other ways of feeding the
|
|
2976
3065
|
// engine on its own first, then say so, with a one-tap way out.
|
|
2977
3066
|
if (this._useWebSpeech && !this._cloud && this._rescueNoWords()) { updateAIBtnUX(); return; }
|
|
2978
|
-
if (this._useWebSpeech && !this._issue && this._soundMs > 15000 && (this._lastResultAt || 0) < (this._startedAt || 0) && (this._cloud || this._rescueStage >= 3))
|
|
3067
|
+
if (this._useWebSpeech && !this._issue && (this._soundMs > 15000 || (this._diag.empty || 0) >= 10) && (this._lastResultAt || 0) < (this._startedAt || 0) && (this._cloud || this._rescueStage >= 3)) {
|
|
3068
|
+
this._issue = 'noresult';
|
|
3069
|
+
if (!this._cloud && !this._toldNoWords) {
|
|
3070
|
+
this._toldNoWords = true;
|
|
3071
|
+
const key = AI.key('groq') || AI.key('openai');
|
|
3072
|
+
logDebug('AI Sub: the speech engine returns no words here (' + (this._diag.empty || 0) + ' empty results).', 'error');
|
|
3073
|
+
if (key && STORE.get('nxu_asr_provider', 'browser') === 'browser') {
|
|
3074
|
+
showToast(t('subNoWordsKey'));
|
|
3075
|
+
STORE.set('nxu_asr_provider', AI.key('groq') ? 'groq' : 'openai');
|
|
3076
|
+
this.restart('no words from the browser engine');
|
|
3077
|
+
} else showToast(t(/\bEdg\//.test(navigator.userAgent) ? 'subNoWordsEdge' : 'subNoWords'));
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
2979
3080
|
this._updateListenChip();
|
|
2980
3081
|
updateAIBtnUX();
|
|
2981
3082
|
},
|
|
@@ -2985,8 +3086,11 @@
|
|
|
2985
3086
|
// the on-device model → the Web Audio copy of the sound → the engine's own microphone.
|
|
2986
3087
|
_rescueNoWords() {
|
|
2987
3088
|
if (this.captureMode === 'ios-mic' || (this._lastResultAt || 0) >= (this._stageAt || 0)) return false;
|
|
2988
|
-
|
|
2989
|
-
|
|
3089
|
+
// Evidence of "hears but no words": ten seconds of speech-level sound, or a run of
|
|
3090
|
+
// empty results from the engine itself (it is hearing something, but no words).
|
|
3091
|
+
const emptyRun = (this._diag.empty || 0) - (this._stageEmpty || 0);
|
|
3092
|
+
if (((this._stageSoundMs || 0) < 10000 && emptyRun < 6) || Date.now() - (this._stageAt || 0) < 8000) return false;
|
|
3093
|
+
const next = () => { this._rescueStage++; this._stageAt = Date.now(); this._stageSoundMs = 0; this._stageEmpty = this._diag.empty || 0; };
|
|
2990
3094
|
const rebuild = (why) => { this._commitInterim('rescue', 0); this._resetSegment(); this._destroyRecognizer(); this._createRecognizer(); this._scheduleRestart(why, 150, true); };
|
|
2991
3095
|
if (this._rescueStage === 0) {
|
|
2992
3096
|
next();
|
|
@@ -3132,6 +3236,18 @@
|
|
|
3132
3236
|
},
|
|
3133
3237
|
_onResult(event) {
|
|
3134
3238
|
this._touch();
|
|
3239
|
+
// Some engines (seen with Edge listening to a captured track) send result events
|
|
3240
|
+
// that carry no words at all. Those are not a sign of success: counting them as
|
|
3241
|
+
// results kept every rescue step and every warning from ever starting.
|
|
3242
|
+
let anyWords = false;
|
|
3243
|
+
try {
|
|
3244
|
+
for (let i = event.resultIndex || 0; i < event.results.length; i++) {
|
|
3245
|
+
const tx = event.results[i]?.[0]?.transcript;
|
|
3246
|
+
if (tx && String(tx).trim()) { anyWords = true; this._diag.lastText = String(tx).trim().slice(-60); break; }
|
|
3247
|
+
}
|
|
3248
|
+
} catch (_) { }
|
|
3249
|
+
if (!anyWords) { this._diag.empty = (this._diag.empty || 0) + 1; return; }
|
|
3250
|
+
this._diag.words = (this._diag.words || 0) + 1;
|
|
3135
3251
|
this._lastResultAt = Date.now();
|
|
3136
3252
|
this._networkErrors = 0;
|
|
3137
3253
|
this._networkRetryMs = 0;
|
|
@@ -3767,6 +3883,7 @@
|
|
|
3767
3883
|
if (slot) { slot.style.opacity = '0'; slot.replaceChildren(); }
|
|
3768
3884
|
},
|
|
3769
3885
|
_mirror(payload) {
|
|
3886
|
+
if (FS_SUBS.video && !SUBS.active()) { FS_SUBS.showOn(FS_SUBS.video, payload.mode === 'clear' ? '' : (payload.text || '') + (payload.original && payload.original !== payload.text ? '\n' + payload.original : '')); return; }
|
|
3770
3887
|
const frame = SUB_LAYOUT.mirrorFrame;
|
|
3771
3888
|
if (!frame || !frame.isConnected) return;
|
|
3772
3889
|
FRAME.postToFrame(frame, { type: 'NXU_CAPTION', size: SUB_PREFS.size, text: '', original: '', color: '#00e676', ...payload });
|
|
@@ -3877,6 +3994,7 @@
|
|
|
3877
3994
|
this._rescueStage = 0;
|
|
3878
3995
|
this._stageAt = Date.now();
|
|
3879
3996
|
this._stageSoundMs = 0;
|
|
3997
|
+
this._stageEmpty = 0;
|
|
3880
3998
|
this._waitOnline = false;
|
|
3881
3999
|
this._googleBackoffUntil = 0;
|
|
3882
4000
|
this._providerStatus = '';
|
|
@@ -3939,6 +4057,7 @@
|
|
|
3939
4057
|
this.state = 'running';
|
|
3940
4058
|
this._diag = { sound: 0, results: 0, err: '' };
|
|
3941
4059
|
this._toldNoTrack = false;
|
|
4060
|
+
this._toldNoWords = false;
|
|
3942
4061
|
this._startedAt = Date.now();
|
|
3943
4062
|
this._soundMs = 0;
|
|
3944
4063
|
this._stageAt = Date.now();
|
|
@@ -3972,9 +4091,9 @@
|
|
|
3972
4091
|
'microphone blocked by site: ' + (this._micBlockedByPolicy() ? 'YES' : 'no') + ' · permission: ' + (await this._micPermissionState()),
|
|
3973
4092
|
'recognition: ' + (this._cloud ? 'cloud ' + AI.asrModel() : (this._useWebSpeech ? this._sttProvider || 'web-speech' : '-')) + ' · state: ' + this.state,
|
|
3974
4093
|
'wanted sound: ' + (this.audioMode || this._audioMode()) + ' · capturing: ' + (this.captureMode || '-') + ' · engine input: ' + (this._recognitionInput || '-') + (this._trackDisabled ? ' (track refused)' : '') + (this._micMixed ? ' · mic mixed in' : '') + (this._useMixTrack ? ' · web-audio track' : '') + ' · rescue step ' + (this._rescueStage || 0),
|
|
3975
|
-
'video: ' + (v ? (v.paused ? 'paused' : 'playing') + (v.muted ? ', muted' : '') + ', volume ' + Math.round((v.volume || 0) * 100) + '%' : 'none') + ' · video sound peak: ' + (this._mediaPeak || 0).toFixed(4),
|
|
4094
|
+
'video: ' + (v ? (v.paused ? 'paused' : 'playing') + (v.muted ? ', muted' : '') + ', volume ' + Math.round((v.volume || 0) * 100) + '%' : (STATE.cinemaIframe || STATE.frameMedia ? 'in a frame' : 'none')) + ' · sound from: ' + (this._sharedTab && this.webMediaStream === this._sharedTab ? 'shared tab' : this._webFromElement ? 'video element' : this.captureMode) + ' · video sound peak: ' + (this._mediaPeak || 0).toFixed(4),
|
|
3976
4095
|
'levels: video ' + Math.round((this._levels?.media || 0) * 400) + ' · mic ' + Math.round((this._levels?.mic || 0) * 400),
|
|
3977
|
-
'engine events: sound ' + this._diag.sound + ' · results ' + this._diag.results + ' · last error ' + (this._diag.err || '-') + ' · network errors ' + (this._networkErrors || 0),
|
|
4096
|
+
'engine events: sound ' + this._diag.sound + ' · results ' + this._diag.results + ' (with words ' + (this._diag.words || 0) + ', empty ' + (this._diag.empty || 0) + ')' + (this._diag.lastText ? ' · last heard "' + this._diag.lastText + '"' : '') + ' · last error ' + (this._diag.err || '-') + ' · network errors ' + (this._networkErrors || 0),
|
|
3978
4097
|
'issue: ' + (this._issue || '-')
|
|
3979
4098
|
];
|
|
3980
4099
|
return lines.join('\n');
|
|
@@ -7663,7 +7782,20 @@
|
|
|
7663
7782
|
};
|
|
7664
7783
|
const emojiInput = (ph, onEmoji) => {
|
|
7665
7784
|
const inp = createEl('input', 'nx-compose-input nx-emoji-input', '', { type: 'text', maxlength: '16', placeholder: ph, autocomplete: 'off', enterkeyhint: 'done' });
|
|
7666
|
-
|
|
7785
|
+
// Emoji keyboards with a search box (phones, Windows' emoji panel) are still in the
|
|
7786
|
+
// middle of composing when the emoji lands: taking it then and clearing the box made
|
|
7787
|
+
// the keyboard commit it a second time (two of the same emoji). Wait for the keyboard
|
|
7788
|
+
// to finish, and ignore the same emoji arriving again right away.
|
|
7789
|
+
let lastEm = '', lastAt = 0;
|
|
7790
|
+
const take = () => {
|
|
7791
|
+
const em = safeEmoji(inp.value);
|
|
7792
|
+
if (!em) return;
|
|
7793
|
+
if (em === lastEm && Date.now() - lastAt < 1200) { inp.value = ''; return; }
|
|
7794
|
+
if (onEmoji(em)) { lastEm = em; lastAt = Date.now(); inp.value = ''; }
|
|
7795
|
+
};
|
|
7796
|
+
inp.addEventListener('input', (ev) => { if (ev.isComposing || inp._composing) return; take(); });
|
|
7797
|
+
inp.addEventListener('compositionstart', () => { inp._composing = true; });
|
|
7798
|
+
inp.addEventListener('compositionend', () => { inp._composing = false; setTimeout(take, 0); });
|
|
7667
7799
|
inp.addEventListener('keydown', (ev) => ev.stopPropagation());
|
|
7668
7800
|
return inp;
|
|
7669
7801
|
};
|
|
@@ -9724,8 +9856,12 @@
|
|
|
9724
9856
|
// live on everyone's screen (on the same spot of the picture, whatever the device) and
|
|
9725
9857
|
// fade out by themselves. Nothing is kept — the shared canvas (✏️) is for keeps.
|
|
9726
9858
|
const INK = {
|
|
9727
|
-
|
|
9728
|
-
|
|
9859
|
+
// A drawing stays as a whole while its author keeps drawing, and fades only when they
|
|
9860
|
+
// have stopped for a while (each stroke used to fade 3.5 s after it was drawn, so the
|
|
9861
|
+
// start of a picture vanished before it was finished).
|
|
9862
|
+
HOLD_MS: 10000,
|
|
9863
|
+
FADE_MS: 2000,
|
|
9864
|
+
MAX_PTS: 2000,
|
|
9729
9865
|
strokes: new Map(), // id → { color, w, ref, pts: [[u,v]...], last }
|
|
9730
9866
|
_canvas: null,
|
|
9731
9867
|
_ctx: null,
|
|
@@ -9780,8 +9916,14 @@
|
|
|
9780
9916
|
} else { x = u * window.innerWidth; y = v * window.innerHeight; }
|
|
9781
9917
|
return clientToUi(x, y);
|
|
9782
9918
|
};
|
|
9919
|
+
// Everyone's latest stroke activity: their whole drawing lives until then + HOLD.
|
|
9920
|
+
const lastBy = new Map();
|
|
9921
|
+
for (const [id, s] of this.strokes) {
|
|
9922
|
+
const who = id.split('-')[0];
|
|
9923
|
+
lastBy.set(who, Math.max(lastBy.get(who) || 0, s.live ? now : s.last));
|
|
9924
|
+
}
|
|
9783
9925
|
for (const [id, s] of this.strokes) {
|
|
9784
|
-
const age = now - s.last;
|
|
9926
|
+
const age = now - (lastBy.get(id.split('-')[0]) || s.last);
|
|
9785
9927
|
const alpha = s.live ? 1 : age < this.HOLD_MS ? 1 : 1 - (age - this.HOLD_MS) / this.FADE_MS;
|
|
9786
9928
|
if (alpha <= 0) { this.strokes.delete(id); continue; }
|
|
9787
9929
|
if (s.pts.length < 1) continue;
|
|
@@ -9915,7 +10057,7 @@
|
|
|
9915
10057
|
const p = this._norm(e.clientX, e.clientY, cur.ref);
|
|
9916
10058
|
const q = s.pts[s.pts.length - 1];
|
|
9917
10059
|
if (q && Math.abs(p[0] - q[0]) < 0.003 && Math.abs(p[1] - q[1]) < 0.003) return;
|
|
9918
|
-
if (s.pts.length >=
|
|
10060
|
+
if (s.pts.length >= this.MAX_PTS) return;
|
|
9919
10061
|
s.pts.push(p);
|
|
9920
10062
|
s.last = Date.now();
|
|
9921
10063
|
this._kick();
|
|
@@ -9960,7 +10102,7 @@
|
|
|
9960
10102
|
}
|
|
9961
10103
|
}
|
|
9962
10104
|
if (d.append && s.pts.length) pts.shift();
|
|
9963
|
-
for (const p of pts) if (s.pts.length <
|
|
10105
|
+
for (const p of pts) if (s.pts.length < this.MAX_PTS) s.pts.push(p);
|
|
9964
10106
|
s.last = Date.now();
|
|
9965
10107
|
s.live = !d.end;
|
|
9966
10108
|
if (!d.end) { clearTimeout(s.stale); s.stale = setTimeout(() => { s.live = false; s.last = Date.now(); this._kick(); }, 1500); }
|
|
@@ -10000,7 +10142,7 @@
|
|
|
10000
10142
|
tracks() {
|
|
10001
10143
|
const v = STATE.video;
|
|
10002
10144
|
if (!v || !v.textTracks) return [];
|
|
10003
|
-
return [...v.textTracks].filter(tr => tr.kind === 'subtitles' || tr.kind === 'captions');
|
|
10145
|
+
return [...v.textTracks].filter(tr => (tr.kind === 'subtitles' || tr.kind === 'captions') && tr !== v._nxuFsTrack);
|
|
10004
10146
|
},
|
|
10005
10147
|
active() { return this.layers.length > 0; },
|
|
10006
10148
|
hasTrack(tr) { return this.layers.some(l => l.track === tr); },
|
|
@@ -10080,6 +10222,7 @@
|
|
|
10080
10222
|
if (!force && sig === this._last && this._box?.isConnected) return;
|
|
10081
10223
|
this._last = sig;
|
|
10082
10224
|
const any = groups.some(g => g.text);
|
|
10225
|
+
FS_SUBS.feed(groups.filter(g => g.text).map(g => g.text.split('\n').filter(Boolean).slice(0, 3).join('\n')).join('\n'));
|
|
10083
10226
|
const box = any ? this._ensureBox() : this._box;
|
|
10084
10227
|
if (!box) return;
|
|
10085
10228
|
const kids = [];
|
|
@@ -10092,6 +10235,7 @@
|
|
|
10092
10235
|
_render(text) {
|
|
10093
10236
|
if (text === this._last && this._box?.isConnected) return;
|
|
10094
10237
|
this._last = text;
|
|
10238
|
+
FS_SUBS.feed(text);
|
|
10095
10239
|
const box = text ? this._ensureBox() : this._box;
|
|
10096
10240
|
if (!box) return;
|
|
10097
10241
|
box.replaceChildren(...(text ? text.split('\n').filter(Boolean).slice(0, 4).map(line => createEl('span', 'nx-xsub-line', line)) : []));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kangsicj/nexussync",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
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",
|