Timestamp fix'

This commit is contained in:
goodtube4u
2025-09-23 09:20:37 +10:00
parent 18cb08ed81
commit e4ed5ede81

View File

@@ -413,16 +413,22 @@
// For each link
timestampLinks.forEach((element) => {
// Make sure we've not touched it yet, this stops doubling up on event listeners
if (!element.classList.contains('goodTube_timestampLink') && element.getAttribute('href') && element.getAttribute('href').indexOf(goodTube_getParams['v']) !== -1 && element.getAttribute('href').indexOf('t=') !== -1) {
if (!element.classList.contains('goodTube_timestampLink') && element.getAttribute('href') && element.getAttribute('href').indexOf(goodTube_getParams['v']) !== -1) {
element.classList.add('goodTube_timestampLink');
// Add the event listener to send our player to the correct time
element.addEventListener('click', function () {
// Define the time to skip to
let time = 0;
// Get the time from the link (if it exstis)
let bits = element.getAttribute('href').split('t=');
if (typeof bits[1] !== 'undefined') {
let time = bits[1].replace('s', '');
goodTube_player_skipTo(time);
time = parseFloat(bits[1].replace('s', ''));
}
// Skip to the time
goodTube_player_skipTo(time);
});
}
});