Skip to content

Instantly share code, notes, and snippets.

@senthilmpro
Last active April 27, 2024 04:40
Show Gist options
  • Save senthilmpro/85980f65192b9d9a2b5128fe50dab980 to your computer and use it in GitHub Desktop.
Save senthilmpro/85980f65192b9d9a2b5128fe50dab980 to your computer and use it in GitHub Desktop.
youtube channel play all videos as playlist
let cId = document.querySelector('[itemprop="identifier"]').content;
const getPlaylistId = () => {
let cId = document.querySelector('[itemprop="identifier"]').content;
if(cId?.startsWith('UC')) return 'UU' + cId.slice(2);
else return null;
}
const getPlaylistUrl = () => {
let channelId = getPlaylistId();
if(!channelId) {
console.error("ERROR getting playlist ID.")
return null;
}
return 'https://www.youtube.com/playlist?list=' + channelId
}
const playlistUrl = getPlaylistUrl();
// open in new tab.
if(playlistUrl) {
console.log(playlistUrl);
window.open(playlistUrl, '_blank');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment