blob: 105cb08110175a89eadc8112b52306510130bdbc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)
|