Skip to content

Instantly share code, notes, and snippets.

@jejkukany
Created October 30, 2025 16:36
Show Gist options
  • Select an option

  • Save jejkukany/4d57227c5b85d0dee92fbff47c0627f8 to your computer and use it in GitHub Desktop.

Select an option

Save jejkukany/4d57227c5b85d0dee92fbff47c0627f8 to your computer and use it in GitHub Desktop.
Updates URL to current Youtube timestamp
// ==UserScript==
// @name YouTube URL Timestamp Updater
// @namespace http://tampermonkey.net/
// @version 2025-10-30
// @description Updates the URL with the current video time without creating duplicates.
// @author You
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// @author Daniel Young
// ==/UserScript==
(function () {
"use strict";
setInterval(function () {
const player = document.querySelector("#movie_player");
if (player && typeof player.getCurrentTime === "function") {
const currentTime = Math.floor(player.getCurrentTime());
const url = new URL(window.location.href);
url.searchParams.set("t", currentTime + "s");
if (window.location.href !== url.href) {
window.history.pushState({}, "", url.href);
}
}
}, 2500);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment