Skip to content

Instantly share code, notes, and snippets.

@pinkisemils
Created January 29, 2017 02:46
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 pinkisemils/bb19d9c60c20aedb74f30126320afb56 to your computer and use it in GitHub Desktop.
Save pinkisemils/bb19d9c60c20aedb74f30126320afb56 to your computer and use it in GitHub Desktop.
Youtube history script
// paste this into the console when looking at your youtube history page and you'll get a somewhat long stringified json out
// youtube deprecated the history API altogether, so now we get to dig through EICH TEE EMMMERGHERD ELLLLLLLLLLLLLLLLLLLLLLL
var container_tag = "yt-lockup-content";
var user_data_tag = "yt-lockup-byline";
var containers = document.getElementsByClassName(container_tag);
function get_data_from_container(container) {
var data = {};
data.title = container.getElementsByTagName('h3')[0].getElementsByTagName('a')[0].title;
data.url = container.getElementsByTagName('h3')[0].getElementsByTagName('a')[0].href;
data.user = container.getElementsByClassName(user_data_tag)[0].getElementsByTagName('a')[0].href;
return data;
}
var total = 0;
var videos = [];
Array.from(containers).forEach( function (container) {
total += 1;
try{
videos.push(get_data_from_container(container))
} catch (e){};
} );
console.log("Successfuly got " + videos.length.toString() + " out of " + total.toString());
JSON.stringify(videos);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment