HI all,
Firstly, thanks so much for all the great features provided by YT Center!
I'd like to request the addition of an "Add to Playlist" button next to the videos that show up in the "My Subscriptions" page, similar to the "Add To" button that appears in each individual video page. The Android App already has this implemented, so it's somewhat ridiculous that the desktop version does not. As far as I'm aware, implementation should be fairly simple, as I even simply adding the Add To button to each video element would totally work.
Thanks in advance!
Very similar to #2107
Video thumbnails should definitely have an add to playlist button (not just on subscription page).
Frustratingly YouTube used to have this, until in 2012 they replaced the add-to-playlist button with the watch-later button in the bottom right of video thumbnails.
So it looks like we only need to make a single ajax post request, which will return the HTML of the Add To menu (well, it returns XML, but the root->html_content
element contains the HTML of the menu).
The request is to https://www.youtube.com/addto_ajax?action_get_dropdown=1&hide_watch_later=false
, and the body should be x-www-form-urlencoded
with video_ids
, session_token
(and possibly src_playlist_id
).
Ok, looks like session_token
and src_playlist
aren't needed.
The following request worked fine for me:
function getAddMenu(video, domElement) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function readyStateChange() {
if (this.readyState == 4 && this.status == 200) {
var html = xhttp.responseXML.getElementsByTagName('html_content')[0].textContent;
domElement.innerHTML = html;
}
};
xhttp.open('POST', '/addto_ajax?action_get_dropdown=1&hide_watch_later=false', true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send('video_ids=' + video);
}
getAddMenu('rh7kpkwXnwA', document.getElementById('foo'))