Skip to content

Instantly share code, notes, and snippets.

@pax
Created June 4, 2026 10:22
Show Gist options
  • Select an option

  • Save pax/93f6889870180abfd5f1ecc3b8d56778 to your computer and use it in GitHub Desktop.

Select an option

Save pax/93f6889870180abfd5f1ecc3b8d56778 to your computer and use it in GitHub Desktop.
Bookmarklet: YouTube playlist to CSV
javascript:(function(){const items=document.querySelectorAll('ytd-playlist-panel-video-renderer, ytd-playlist-video-renderer');if(items.length===0){alert('No playlist videos found. Make sure the panel is visible.');return;}let pTitle='youtube_playlist';const pt1=document.querySelector('.title.ytd-playlist-panel-renderer');const pt2=document.querySelector('ytd-playlist-header-renderer yt-formatted-string, ytd-playlist-header-renderer h1');if(pt1&&pt1.textContent)pTitle=pt1.textContent.trim();else if(pt2&&pt2.textContent)pTitle=pt2.textContent.trim();else pTitle=document.title.replace(' - YouTube','');let safeName=pTitle.replace(/[\/\\?%*:|"<>]/g,%27_%27).substring(0,50)+%27.yt-plist.csv%27;let csv=%27Index,Titlu,Canal,Durata,URL\n%27;items.forEach((item,index)=>{let title=%27Fără titlu%27,channel=%27%27,time=%27%27,url=%27%27;const tEl=item.querySelector(%27#video-title');if(tEl)title=tEl.textContent.trim().replace(/"/g,'""');const cEl=item.querySelector('#byline');if(cEl)channel=cEl.textContent.trim().replace(/"/g,'""');const timeEl=item.querySelector('ytd-thumbnail-overlay-time-status-renderer');if(timeEl){let rTime=timeEl.innerText||timeEl.textContent;time=rTime.trim().split(/[\s\n]+/)[0];}const lEl=item.querySelector('a[href^="/watch"]');if(lEl){try{const u=new URL(lEl.href);url=u.origin+u.pathname+'?v='+u.searchParams.get('v');}catch(e){url=lEl.href;}}csv+='"'+(index+1)+'","'+title+'","'+channel+'","'+time+'","'+url+'"\n';});const blob=new Blob(["\uFEFF"+csv],{type:'text/csv;charset=utf-8;'});const a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download=safeName;document.body.appendChild(a);a.click();document.body.removeChild(a);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment