Skip to content

Instantly share code, notes, and snippets.

@RoootTheFox
Last active June 10, 2025 11:38
Show Gist options
  • Save RoootTheFox/7e83ecba5074c3985f3a5572e0b5eb80 to your computer and use it in GitHub Desktop.
Save RoootTheFox/7e83ecba5074c3985f3a5572e0b5eb80 to your computer and use it in GitHub Desktop.
youtube live stream timestamp
// ==UserScript==
// @name youtube live timestamp
// @namespace https://rooot.gay/
// @version 2025-06-10
// @description adds a timestamp next to the LIVE indicator for streams
// @author rooot
// @updateURL https://gist.github.com/RoootTheFox/7e83ecba5074c3985f3a5572e0b5eb80/raw/49a0eff2f3098489b419844b31af0682c82a153a/yt-live-timstamp.user.js
// @downloadURL https://gist.github.com/RoootTheFox/7e83ecba5074c3985f3a5572e0b5eb80/raw/49a0eff2f3098489b419844b31af0682c82a153a/yt-live-timstamp.user.js
// @match https://www.youtube.com/watch?v=*
// @icon https://www.youtube.com/s/desktop/d36f30a8/img/logos/favicon_144x144.png
// @grant none
// ==/UserScript==
(function() {
'use strict';
let _injected = false;
function tryInject() {
let video = document.querySelector("video");
if (video && !_injected) {
console.log("INJECTING LIVE TIMESTAMP")
_injected = true;
document.querySelector("video").addEventListener("timeupdate", function(e) {
let time = Math.round(e.target.currentTime);
let d = new Date(null);
d.setSeconds(Math.round(time));
document.querySelector(".ytp-time-display>button.ytp-live-badge").innerHTML = `Live (${d.toISOString().slice(11, 19)})`;
})
}
if (!video) _injected = false;
}
setInterval(tryInject, 1000);
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment