From 7009ea576cb0ba55bd1494a0b33967bba86e850d Mon Sep 17 00:00:00 2001 From: Ewy~ Date: Tue, 23 Dec 2025 15:25:48 +0100 Subject: add user.js to filename --- script.js | 47 ---------------------------------------- youtube-auto-timestamper.user.js | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 47 deletions(-) delete mode 100644 script.js create mode 100644 youtube-auto-timestamper.user.js diff --git a/script.js b/script.js deleted file mode 100644 index 105cb08..0000000 --- a/script.js +++ /dev/null @@ -1,47 +0,0 @@ -// ==UserScript== -// @name YouTube auto-timestamper -// @namespace Violentmonkey Scripts -// @match *://www.youtube.com/* -// @grant none -// @version 1.0 -// @author - -// @description 12/17/2025, 5:12:31 PM -// ==/UserScript== - -// interval in seconds -const interval = 1000; -const startDelay = 10000; -const timeRegex = /(([&?])t=[0-9]+)/ -const timeDelay = 0; - -const tick = () => { - const ytplayer = document.getElementById("movie_player"); - if (!ytplayer) { - return - } - - let time = ytplayer.getCurrentTime(); - time = Math.floor(time) - - time -= timeDelay - - if (time <= 0) { - return - } - - let currentUrl = window.location.href - - if (currentUrl.includes("t=")) { - const match = currentUrl.match(timeRegex, "t=") - currentUrl = currentUrl.replace(timeRegex, match[2] + "t=" + time) - } else { - currentUrl = currentUrl + "&t=" + time - } - history.replaceState(currentUrl, "", currentUrl) -} - -const script = -setTimeout(() => { - setInterval(tick, interval) - console.debug("autotimestamper initialized") -}, startDelay) diff --git a/youtube-auto-timestamper.user.js b/youtube-auto-timestamper.user.js new file mode 100644 index 0000000..105cb08 --- /dev/null +++ b/youtube-auto-timestamper.user.js @@ -0,0 +1,47 @@ +// ==UserScript== +// @name YouTube auto-timestamper +// @namespace Violentmonkey Scripts +// @match *://www.youtube.com/* +// @grant none +// @version 1.0 +// @author - +// @description 12/17/2025, 5:12:31 PM +// ==/UserScript== + +// interval in seconds +const interval = 1000; +const startDelay = 10000; +const timeRegex = /(([&?])t=[0-9]+)/ +const timeDelay = 0; + +const tick = () => { + const ytplayer = document.getElementById("movie_player"); + if (!ytplayer) { + return + } + + let time = ytplayer.getCurrentTime(); + time = Math.floor(time) + + time -= timeDelay + + if (time <= 0) { + return + } + + let currentUrl = window.location.href + + if (currentUrl.includes("t=")) { + const match = currentUrl.match(timeRegex, "t=") + currentUrl = currentUrl.replace(timeRegex, match[2] + "t=" + time) + } else { + currentUrl = currentUrl + "&t=" + time + } + history.replaceState(currentUrl, "", currentUrl) +} + +const script = +setTimeout(() => { + setInterval(tick, interval) + console.debug("autotimestamper initialized") +}, startDelay) -- cgit v1.3