From 89c42e2d74d245ccc7395101d3ee94a0848cdcfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Yak=C4=B1=C5=9Ft=C4=B1r?= Date: Tue, 1 Dec 2026 18:51:24 +0300 Subject: [PATCH] fix(watch): support PeerTube v8 /w/:slug URLs in transcript and continue watching --- client.js | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/client.js b/client.js index a68a8e7..6ac4db1 100644 --- a/client.js +++ b/client.js @@ -1767,7 +1767,9 @@ try { var isTranscriptPanelOpen = false; function getActiveWatchVideoSlug() { - var m = window.location.pathname.match(/\/videos\/watch\/([a-zA-Z0-9_-]+)/); + var m = + window.location.pathname.match(/\/videos\/watch\/([a-zA-Z0-9_-]+)/) || + window.location.pathname.match(/\/w\/([a-zA-Z0-9_-]+)/); return m ? m[1] : null; } @@ -2325,6 +2327,8 @@ try { modal.querySelector('#yaktube-queue-clear').addEventListener('click', function () { savePlayQueue([]); renderDrawer(); + var closeEl = modal.querySelector('#yaktube-queue-close'); + if (closeEl) closeEl.focus(); announce('Çalma sırası tamamen temizlendi.'); }); modal.querySelectorAll('.yaktube-queue-play-one').forEach(function (b) { @@ -8970,13 +8974,25 @@ try { videoState.hasPlayed = false; videoState.explicitlyPausedByClick = true; try { - recordContinueWatchingProgress(video, true); + recordContinueWatchingProgress(video, true, true); } catch (e) {} try { showPostVideoUpNextOverlay(); } catch (e) {} }); + video.addEventListener('pause', function () { + try { + recordContinueWatchingProgress(video, false, true); + } catch (e) {} + }); + + video.addEventListener('seeked', function () { + try { + recordContinueWatchingProgress(video, false, true); + } catch (e) {} + }); + video.addEventListener('timeupdate', function () { updateMediaSessionPosition(video); if ( @@ -8988,7 +9004,7 @@ try { video.currentTime = abLoopState.a; } try { - recordContinueWatchingProgress(video, false); + recordContinueWatchingProgress(video, false, false); } catch (e) {} try { checkSmartPrefetchOnTimeUpdate(video); @@ -9159,13 +9175,13 @@ try { } catch (e) {} } - function recordContinueWatchingProgress(video, isEnded) { + function recordContinueWatchingProgress(video, isEnded, forceSave) { if (!video || !isWatchUrl() || isEmbedUrl()) return; var slug = getActiveWatchVideoSlug(); if (!slug) return; var now = Date.now(); - if (!isEnded && now - lastContinueSaveTs < 4000) return; + if (!isEnded && !forceSave && now - lastContinueSaveTs < 4000) return; var dur = Number(video.duration || 0); var cur = Number(video.currentTime || 0); @@ -9199,7 +9215,7 @@ try { var entry = { slug: slug, - url: '/videos/watch/' + slug, + url: '/w/' + slug, startTime: Math.floor(cur), duration: Math.floor(dur), pct: Math.min(99, Math.max(2, Math.round(ratio * 100))), @@ -9260,6 +9276,12 @@ try { .join('|'); var shelf = document.getElementById('yaktube-continue-watching-shelf'); + if (shelf && (!shelf.isConnected || !document.body.contains(shelf))) { + try { + shelf.remove(); + } catch (e) {} + shelf = null; + } if (shelf) { var curSig = shelf.getAttribute('data-render-sig'); if (chipsBar && shelf.previousElementSibling !== chipsBar && chipsBar.parentElement) {