Created
February 15, 2022 23:00
-
-
Save danthemango/03f11546fc4082446ab55a7a27853d63 to your computer and use it in GitHub Desktop.
quick javascript function to fetch youtube timestamp from livestream, for pasting into devtools
This file contains 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
(function getURLTime() { | |
const params = (new URL(document.location)).searchParams | |
if(params.has('v')) { | |
const v = params.get('v'); | |
const ytplayer = document.getElementById("movie_player"); | |
const t = Math.round(ytplayer.getCurrentTime()) | |
const newUrl = `https://youtu.be/${v}?t=${t}`; | |
return newUrl; | |
} | |
return document.location; | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prepend with "javascript:" in the URL section of a chrome bookmark. This script allows me to fetch the current timestamp of a youtube livestream while it is broadcasting