youtube icon indicating copy to clipboard operation
youtube copied to clipboard

šŸž ImproveTube fails to initialize UI buttons due to race condition with YouTube’s playback speed button

Open TheManInTheWall opened this issue 5 months ago • 3 comments

Title: Description: ImproveTube’s videoPageUpdate function (called during init) attempts to access YouTube’s native playback speed button (playerPlaybackSpeedButton) before it exists in the DOM. This causes the following error:

Uncaught TypeError: can't access property "addEventListener", button is undefined
    playerPlaybackSpeedButton moz-extension://.../player.js:1118

As a result, ImproveTube’s extra buttons (e.g., repeat, screenshot, rotate) do not appear until the page is manually refreshed.

Steps to Reproduce:

  1. Navigate to any YouTube page (e.g., /feed/subscriptions or a video watch page).
  2. Observe that ImproveTube’s extra buttons are missing.
  3. Open the browser console and see the error above.
  4. Manually refresh the page → buttons appear as expected.

Expected Behaviour: ImproveTube’s buttons should load automatically without requiring a manual refresh.

Actual Behaviour: Buttons only appear after refreshing the page, and the console shows the race condition error.

Additional Info: Error stack trace points to videoPageUpdate → init in ImproveTube’s player.js and functions.js. The issue is caused by ImproveTube assuming YouTube’s UI is ready, but it is loaded dynamically after ImproveTube’s scripts run. A proper fix would involve using MutationObserver or waiting for YouTube’s UI elements to exist before initializing ImproveTube’s buttons.

TheManInTheWall avatar Jul 02 '26 11:07 TheManInTheWall

Hie @TheManInTheWall doesn't seem like this one is taken can it be assigned to me.

midaksh avatar Jul 02 '26 16:07 midaksh

This issue was probably fixed by #4018. Could you check whether you're using a version that includes that change?

hkzo avatar Jul 03 '26 04:07 hkzo

This issue was probably fixed by #4018. Could you check whether you're using a version that includes that change?

Seems fixed. Thanks

TheManInTheWall avatar Jul 03 '26 06:07 TheManInTheWall