Files
KoalaSync/shared
Timo 55c2d4ed0d feat: Auto-Sync Next Episode v1.2.0
Adds a new toggleable feature that detects episode transitions via
mediaTitle mutation (loadeddata/MutationObserver), pauses the video,
and waits for all room peers to load the same episode before
executing a coordinated Force Sync play at 0:00.

Protocol:
- Add EPISODE_LOBBY and EPISODE_READY events to shared/constants.js
- Add EPISODE_LOBBY_TIMEOUT (60s) constant
- Relay both new events in server/index.js

Content Script (content.js):
- Layered detection: loadeddata + MutationObserver src-change + heartbeat
- Debounced onEpisodeTransition() sends signal ONLY; no eager pause
- PAUSE_FOR_LOBBY handler pauses only after background confirms feature enabled
- startLobbyPoll() polls title match without premature pause for non-initiators
- checkAndReportLobbyReady() pauses and sends EPISODE_READY_LOCAL on match
- CONTENT_BOOT recovery for re-injection after hard navigation

Background (background.js):
- Episode lobby state persisted in chrome.storage.session with recovery
- EPISODE_CHANGED: checks setting, creates lobby, sends PAUSE_FOR_LOBBY to tab
- EPISODE_LOBBY/READY server event handlers with dedup logic
- 60s timeout cancels lobby (Option B) with Chrome failure notification
- Peer departure handled: removes from readyPeers, re-checks completion
- executeEpisodeLobby() reuses existing Force Sync pipeline at targetTime 0.0
- Lobby cleared on LEAVE_ROOM; status exposed in GET_STATUS

Popup:
- Auto-Sync Next Episode toggle in Settings tab (default: off, opt-in)
- Episode Lobby status card in Sync tab with peer readiness display
- LOBBY_UPDATE message handler for real-time UI updates

Bumps APP_VERSION and manifest to 1.2.0
2026-04-25 16:43:10 +02:00
..

KoalaSync Shared Constants

This directory contains constants and protocol definitions used by both the extension and the server.

Syncing with the Extension

Important

Every time this file is modified, you must run scripts/sync-constants.sh to keep the extension's copy up to date.

Because Chrome Extensions cannot load files outside their root directory, constants.js must be copied to extension/shared/constants.js whenever it is modified.

Security & Versioning Constants

  • OFFICIAL_SERVER_TOKEN: A 32-byte hex token required to connect to the official relay server.
  • APP_VERSION: The current version of the extension. Used by the server to enforce minimum version requirements (Revocation). This must always be in sync with manifest.json.
  • OFFICIAL_SERVER_URL: The default endpoint for the official KoalaSync relay.
  • ROOM_DATA: Server response with current room state (peers).
  • PLAY: Sync command to start playback.
  • PAUSE: Sync command to pause playback.
  • SEEK: Sync command to change the current time.
  • PEER_STATUS: Heartbeat or join/leave notification for peers.
  • FORCE_SYNC_PREPARE: Phase 1 of Force Sync (Pause & Seek).
  • FORCE_SYNC_ACK: Peer confirmation of Phase 1 readiness.
  • FORCE_SYNC_EXECUTE: Phase 2 of Force Sync (Start Playback).
  • ERROR: Generic error message from the server.