Created
January 29, 2017 02:46
-
-
Save pinkisemils/bb19d9c60c20aedb74f30126320afb56 to your computer and use it in GitHub Desktop.
Youtube history script
This file contains hidden or 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
// 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