Skip to content

fix(subtitles): stabilize YouTube subtitle navigation and popup mounting#1345

Open
taiiiyang wants to merge 2 commits intomainfrom
fix/youtube-subtitles-navigation-lifecycle
Open

fix(subtitles): stabilize YouTube subtitle navigation and popup mounting#1345
taiiiyang wants to merge 2 commits intomainfrom
fix/youtube-subtitles-navigation-lifecycle

Conversation

@taiiiyang
Copy link
Copy Markdown
Collaborator

@taiiiyang taiiiyang commented Apr 15, 2026

Type of Changes

  • ✨ New feature (feat)
  • πŸ› Bug fix (fix)
  • πŸ“ Documentation change (docs)
  • πŸ’„ UI/style change (style)
  • ♻️ Code refactoring (refactor)
  • ⚑ Performance improvement (perf)
  • βœ… Test related (test)
  • πŸ”§ Build or dependencies update (build)
  • πŸ”„ CI/CD related (ci)
  • 🌐 Internationalization (i18n)
  • 🧠 AI model related (ai)
  • πŸ”„ Revert a previous commit (revert)
  • πŸ“¦ Other changes that do not modify src or test files (chore)

Description

  • Clear stale subtitle state when YouTube SPA navigation starts and rebuild subtitle state after navigation finishes.
  • Remount the subtitles UI when returning from the YouTube home page to a watch page so the popup can be opened again.
  • Restrict the subtitle UI and translate button mounting target to the active #movie_player container so the popup stays attached to the correct player.

Related Issue

Closes #

How Has This Been Tested?

  • Added unit tests
  • Verified through manual testing

Screenshots

Checklist

  • I have tested these changes locally
  • I have updated the documentation accordingly if necessary
  • My code follows the code style of this project
  • My changes do not break existing functionality
  • If my code was generated by AI, I have proofread and improved it as necessary.

Additional Information


Summary by cubic

Stabilizes YouTube subtitles across SPA navigation and ensures the popup mounts to the active player so it reliably opens after moving between videos or returning from Home.

  • Bug Fixes
    • Split navigation handling into yt-navigate-start (clear visible state) and yt-navigate-finish (re-init with delay) to prevent stale subtitles and stuck UI.
    • Persist a single adapter instance and remount the UI; dedupe the React shadow host and move it under the current #movie_player.
    • Scope selectors to #movie_player for the player and controls so the popup attaches to the correct video.
    • Update platform config to navigateStart/navigateFinish and add constants for both events; reset schedulers/pipelines on start and rebuild after finish.

Written for commit 1b45d6c. Summary will update on new commits.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

πŸ¦‹ Changeset detected

Latest commit: 0a21470

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@read-frog/extension Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added fix contrib-trust:trusted PR author trust score is 60-79. labels Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Contributor trust score

73/100 β€” Trusted

This score estimates contributor familiarity with mengxi-ream/read-frog using public GitHub signals. It is advisory only and does not block merges automatically.

Outcome

Score breakdown

Dimension Score Signals
Repo familiarity 35/35 commits in repo, merged PRs, reviews
Community standing 17/25 account age, followers, repo role
OSS influence 3/20 stars on owned non-fork repositories
PR track record 18/20 merge rate across resolved PRs in this repo

Signals used

  • Repo commits: 72 (author commits reachable from the repository default branch)
  • Repo PR history: merged 81, open 1, closed-unmerged 6
  • Repo reviews: 11
  • PR changed lines: 181 (+124 / -57)
  • Repo permission: write
  • Followers: 15
  • Account age: 78 months
  • Owned non-fork repos considered: max 2, total 2 (taiiiyang/oss-stamp (2), taiiiyang/homepage (0), taiiiyang/gsap_cocktail (0), taiiiyang/visactor-image (0), taiiiyang/react-components (0), taiiiyang/TinyVis (0), taiiiyang/taiiiyang (0), taiiiyang/toolbox (0), taiiiyang/find_txt (0), taiiiyang/rustlings_answer (0), taiiiyang/vue-mini (0))

Policy

  • Low-score review threshold: < 30
  • Auto-close: score < 20 and changed lines > 1000
  • Policy version: v1.1

Updated automatically when the PR changes or when a maintainer reruns the workflow.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b45d6c7aa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

export const youtubeConfig: PlatformConfig = {
selectors: {
video: "video.html5-main-video",
playerContainer: "#movie_player.html5-video-player",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Target the video selector to #movie_player

This change narrows playerContainer to #movie_player... but leaves video as the global video.html5-main-video, and initializeScheduler() relies on waitForElement() validation that only checks the first document.querySelector match. On pages where another YouTube player video appears earlier in DOM order (e.g., preview/miniplayer instances), validation against #movie_player keeps failing until timeout, so scheduler initialization never happens and subtitles cannot start. Please scope the video selector itself to the active player (or make element lookup iterate all matches) so the active watch player is always discovered.

Useful? React with πŸ‘Β / πŸ‘Ž.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contrib-trust:trusted PR author trust score is 60-79. fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants