How to Bulk “Add to Queue” Videos from a Youtube Playlist in JavaScript
The Queue feature on YouTube allows users to add videos to a list that will play back-to-back. This is a great way to save time when watching videos because you don’t have to search for each video yourself. You can add as many videos to the Queue as you want, and they will all play in order.
Adding videos to your queue one at a time can be a bit tedious, especially if you have a lot of them. If you have a YouTube playlist that you want to watch, there is a quick way to add all of the videos in the playlist to your Queue. This can be done without having to open each video individually and add it to the Queue.
To bulk add videos from a YouTube playlist to your Queue, follow these steps
- Open a Youtube Playlist on Chrome.
- Open Google Chrome’s DevTool by pressing Ctrl+Shift+I or F12.
- Switch to the Console tab.
- Copy and paste the script below to the console window
var itemIndex = 0; const maxToAdd = 50; const delay = 500; //0.5 second if(itemIndex < maxToAdd){ setInterval(function() { document.querySelectorAll('#primary button[aria-label="Action menu"]')[itemIndex].click(); var items = document.evaluate('//yt-formatted-string[contains(text(),"Add to queue")]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); for (var i = 0; i < items.snapshotLength; i++) { items.snapshotItem(i).click(); } itemIndex++; }, delay); }
![](https://tleapps.com/wp-content/uploads/2022/05/add-to-queue.jpg)
There are 2 variables you can change:
- maxToAdd: the number of videos you want to add to your Queue.
- delay: the period the script need to wait to add the next video.