fix(watch): support PeerTube v8 /w/:slug URLs in transcript and continue watching

This commit is contained in:
Enes Yakıştır
2026-12-01 18:51:24 +03:00
parent d4b7da078a
commit 89c42e2d74
+28 -6
View File
@@ -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) {