Last active
September 2, 2024 20:33
-
-
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 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
javascript:(function getURLTime() { const params = (new URL(document.location)).searchParams; 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 alert(newUrl); })() |
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
(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; | |
})() |
To use with a bookmark link:
- create a new bookmark
- right-click on bookmarks bar
- click "Add Page"
- Give it a name
- paste the chrome-bookmark-code
- click Save
Then, when you're watching youtube video or livestream click on it and it will give you an alert with the current video timestamp link, which you can share.
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