mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 14:07:13 +03:00
Fix preview bar when video duration innacurate
This commit is contained in:
@@ -203,6 +203,13 @@ class PreviewBar {
|
|||||||
this.segments = segments ?? [];
|
this.segments = segments ?? [];
|
||||||
this.videoDuration = videoDuration ?? 0;
|
this.videoDuration = videoDuration ?? 0;
|
||||||
|
|
||||||
|
const progressBar = document.querySelector('.ytp-progress-bar') as HTMLElement;
|
||||||
|
// Sometimes video duration is inaccurate, pull from accessibility info
|
||||||
|
const ariaDuration = parseInt(progressBar?.getAttribute('aria-valuemax')) ?? 0;
|
||||||
|
if (ariaDuration && Math.abs(ariaDuration - this.videoDuration) > 3) {
|
||||||
|
this.videoDuration = ariaDuration;
|
||||||
|
}
|
||||||
|
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user