i watch a lot of youtube while working and the tab management is a nightmare. open a video, it plays, then sits there as a dead tab until i manually close it and click the next one. zen browser has workspaces which helps keep things organized, but it doesn't solve the actual queue problem — there's no native way to say "play this, then this, then this" and have it just work. so i built an extension that does exactly that.
the core loop is simple: you add videos to a queue panel in the sidebar, and when the current video ends, the extension closes that tab, opens the next one, and hits play. the tricky part was detecting the end of a video reliably. youtube's player state api works most of the time but there are edge cases — ads, autoplay countdowns, the video overlays at the end that block the state change event. ended up polling the video duration and current time through a content script and firing a custom event when current time equals duration within a small tolerance. also added a picture-in-picture attempt on tab switch so the video pops out before the new tab steals focus. pip api is a bit finicky in zen because it's based on firefox and the api permissions are stricter than chromium's, but it works most of the time after requesting the right permissions in the manifest.
the queue panel itself is just a simple html list with drag-to-reorder using the built-in sortable api. you can paste youtube urls directly or right-click any video link in your normal browser tabs and send it to the queue. also added a save/restore feature that persists the queue to localstorage so if the browser crashes or you restart, the list doesn't vanish. it's not polished enough to publish as a real extension yet — the pip timing is still janky and there's no way to set a default queue per workspace — but for my daily workflow it already saves a ridiculous amount of clicking. might clean it up and put it on the zen browser addons page at some point.