Skip to content

Instantly share code, notes, and snippets.

@paul-krohn
Last active April 20, 2025 04:09
Show Gist options
  • Save paul-krohn/1d8ff4adbd96a8e701b41e4d5ce7cf7b to your computer and use it in GitHub Desktop.
Save paul-krohn/1d8ff4adbd96a8e701b41e4d5ce7cf7b to your computer and use it in GitHub Desktop.
A bookmarklet to scrape YouTube timestamps from a Digital Pool tournament
javascript: (() => {
var match_rows = document.getElementsByClassName("streaming completed");
var output = "";
first_match_start = new Date(match_rows[0].childNodes[4].childNodes[0].textContent);
for (const match_row of match_rows) {
date_td = match_row.getElementsByTagName("td")[4];
date = date_td.getElementsByTagName("div")[0].getHTML();
match_start = new Date(date);
match_offset = (match_start - first_match_start) / 1000;
hours = Math.floor(match_offset / 3600);
minutes = Math.floor((match_offset - (hours * 3600)) / 60);
seconds = match_offset - (hours * 3600) - (minutes * 60);
match_offset_string = hours.toString().padStart(2, '0') + ':' +
minutes.toString().padStart(2, '0') + ':' +
seconds.toString().padStart(2, '0');
p1 = match_row.childNodes[1].childNodes[0].childNodes[0].childNodes[1].childNodes[0].textContent;
p2 = match_row.childNodes[2].childNodes[0].childNodes[2].childNodes[0].textContent;
output += `${match_offset_string} ${p1} vs ${p2}\n`;
}
navigator.clipboard.writeText(output);
window.alert("timestamps copied");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment