Last active
April 27, 2024 04:40
-
-
Save senthilmpro/85980f65192b9d9a2b5128fe50dab980 to your computer and use it in GitHub Desktop.
youtube channel play all videos as playlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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