fix(extension): harden target frame recovery and switching

This commit is contained in:
Timo
2026-08-17 23:06:46 +02:00
parent 3c99efe4e4
commit e1daeecab1
25 changed files with 537 additions and 179 deletions
+29 -17
View File
@@ -867,19 +867,30 @@
if (wasDesynced) {
runtimeMessage({ type: 'HCM_DESYNC_STATE', desynced: false }).catch(() => {});
}
// Resync to the host's current position (retries if host state not yet known).
hcmRequestHostSyncWithRetry();
reportLog('Host-only: resynced with the host', 'info');
}
// Resync to the host's current position (retries if host state not yet known).
hcmRequestHostSyncWithRetry();
reportLog('Host-only: resynced with the host', 'info');
}
function hcmShowBadge() {
function hcmShowBadge() {
if (hcmBadgeHost) return;
if (!document.body) {
// Body not ready yet (very early injection). Defer until DOMReady,
// otherwise the desynced user silently never sees the badge (L-4).
if (!hcmBadgePending) {
hcmBadgePending = true;
const retry = () => {
@@ -907,8 +918,9 @@
const b = hcmEl('div', 'position:fixed;z-index:2147483646;right:16px;bottom:16px;background:#c96736;color:#fff;font:13px/1.3 system-ui,sans-serif;padding:8px 12px;border-radius:10px;box-shadow:0 6px 20px rgba(0,0,0,.4);cursor:pointer;display:flex;align-items:center;gap:8px');
return;
b.append(hcmEl('span', null, '● ' + hcmStrings.badge), hcmEl('span', 'text-decoration:underline', hcmStrings.resync));
b.addEventListener('click', hcmExitDesync);
root.appendChild(b);
@@ -1238,7 +1250,7 @@
bestRank = rank;
}
for (const video of candidates) {
}
return best;
@@ -2062,7 +2074,7 @@
if (action === EVENTS.FORCE_SYNC_PREPARE) {
// force-sync flow actually waits on. Skipping CMD_ACKs for PLAY/PAUSE/SEEK
runtimeMessage({ type: 'FORCE_SYNC_ACK' }).catch(() => {});
}
return;
@@ -2117,7 +2129,7 @@
} else if (action === EVENTS.PAUSE) {
tryMediaAction(EVENTS.PAUSE);
runtimeMessage({ type: 'CMD_ACK', actionTimestamp: message.actionTimestamp, commandSenderId: message.commandSenderId });
actionCompleted = true;