Skip to content

fix: YouTube autoplay fails after track #400 (#3541)#3584

Merged
ImprovedTube merged 1 commit intocode-charity:masterfrom
suryaprakash0010:fix/youtube-autoplay-after-400-3541
Feb 1, 2026
Merged

fix: YouTube autoplay fails after track #400 (#3541)#3584
ImprovedTube merged 1 commit intocode-charity:masterfrom
suryaprakash0010:fix/youtube-autoplay-after-400-3541

Conversation

@suryaprakash0010
Copy link
Contributor

Fix: YouTube Autoplay Fails After Track 400

๐ŸŽฏ Issue Summary

Fixes #3541 - YouTube fails to autoplay next track for all tracks past 400 in large playlists.

๐Ÿ” Root Cause

The playlistUpNextAutoplay function was incorrectly setting currentIndex = totalVideos when playlist_up_next_autoplay was disabled, forcing playlists to end and breaking autoplay for large playlists beyond YouTube's ~200 video pagination limit.

๐Ÿ› ๏ธ Solution

Core Fix

  • Before: Forced playlist termination by setting currentIndex = totalVideos
  • After: Proper synchronization between currentIndex and localCurrentIndex to maintain playlist continuity

Enhanced Features

  • Large Playlist Handler: Monitors video changes and ensures proper index synchronization
  • Observer Pattern: Detects playlist data updates when YouTube loads new segments
  • Memory Management: Proper cleanup of observers and event listeners
  • Navigation Support: Handles navigation between playlist and non-playlist pages

๐Ÿ“ Files Changed

๐Ÿ“ js&css\web-accessible\www.youtube.com\playlist.js

  • Fixed playlistUpNextAutoplay() logic
  • Added playlistLargePlaylistHandler() function
  • Added cleanupPlaylistHandlers() function

๐Ÿ“ js&css\web-accessible\functions.js

  • Integrated large playlist handler into videoPageUpdate()
  • Added cleanup logic for non-playlist pages

๐Ÿ“ js&css\web-accessible\init.js

  • Added handler to playlist initialization in yt-page-data-updated
  • Added cleanup in yt-navigate-finish for navigation

๐Ÿงช test-large-playlist-fix.js (New)

  • Comprehensive test script for verification
  • Manual testing instructions

๐Ÿ”„ How It Works

  1. YouTube's Limitation: Loads playlists in chunks (~200 videos)
  2. Our Solution: Continuously monitors and synchronizes playlist indices
  3. Result: Seamless autoplay beyond track 400

๐Ÿงช Testing

Automated Test

// Run in browser console on any YouTube playlist
testLargePlaylistFix();

Manual Testing

  1. Find a playlist with 400+ videos
  2. Start playing from video 200 or later
  3. Enable/disable autoplay settings
  4. Verify autoplay continues seamlessly

โœ… Verification

  • โœ… Fixes autoplay failure after track 400
  • โœ… Maintains backward compatibility
  • โœ… Proper memory management
  • โœ… Handles navigation correctly
  • โœ… Works with existing playlist features

๐Ÿ“Š Impact

  • Files Modified: 3 core files + 1 test file
  • Lines Added: ~200 lines
  • Breaking Changes: None
  • Performance: Minimal impact

๐ŸŽ‰ Result

Users can now autoplay through large playlists without interruption after track 400, resolving the long-standing issue reported in #3541.

@ImprovedTube ImprovedTube merged commit ff9d942 into code-charity:master Feb 1, 2026
1 check passed
@ImprovedTube
Copy link
Member

thank you so much! @suryaprakash0010

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

๐Ÿžfail after track #400

2 participants