Skip to content

Instantly share code, notes, and snippets.

@tiborsaas
Last active November 19, 2018 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiborsaas/c89c44941447443168a0 to your computer and use it in GitHub Desktop.
Save tiborsaas/c89c44941447443168a0 to your computer and use it in GitHub Desktop.
Export YouTube favorites
var saveHTML = function(fileName, html){
var link = document.createElement("a");
link.download = fileName;
link.href = "data:text/plain,"+html;
link.click();
};
var links = document.querySelectorAll('a.ytd-playlist-video-renderer');
var collection = '';
for( i=0; i<links.length; i++){
collection += '<tr><td>https://www.youtube.com/watch?v=' + links[i].href.split('v=')[1].split('&')[0] + '</td><td>' + links[i].querySelector('#video-title').textContent + '</td></tr>';
}
saveHTML("export.html", "<html><meta charset='utf-8'><title>YouTube exports</title><body><table>"+collection+"</table></body></html>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment