mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 20:17:05 +03:00
Fixed getFormattedTime sometimes returning (NaN:NaN) (#643)
* Fixed getFormattedTime sometimes returning (NaN:NaN) getFormattedTime() with nothing passed into it and a couple other edge cases returned (NaN:NaN). This is a problem since on a slow machine getFormattedTime get called without anything passed into it around the time the computer is fetching the timing data. I haven't found the exact spot / place it is called wrongly, but this should fix it. I've have a slow machine so it's really been bugging me seeing (NaN:NaN) for a couple seconds before the page fully loads. Hopefully this should fix it.
This commit is contained in:
@@ -1646,6 +1646,8 @@ function showTimeWithoutSkips(skippedDuration: number): void {
|
|||||||
|
|
||||||
display.appendChild(duration);
|
display.appendChild(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const durationAfterSkips = utils.getFormattedTime(video.duration - skippedDuration)
|
||||||
|
|
||||||
duration.innerText = skippedDuration <= 0 ? "" : " (" + utils.getFormattedTime(video.duration - skippedDuration) + ")";
|
duration.innerText = (durationAfterSkips == null || skippedDuration <= 0) ? "" : " (" + durationAfterSkips + ")";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,6 +376,9 @@ class Utils {
|
|||||||
//add a zero
|
//add a zero
|
||||||
minutesDisplay = "0" + minutesDisplay;
|
minutesDisplay = "0" + minutesDisplay;
|
||||||
}
|
}
|
||||||
|
if (isNaN(hours) || isNaN(minutes)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const formatted = (hours ? hours + ":" : "") + minutesDisplay + ":" + secondsDisplay;
|
const formatted = (hours ? hours + ":" : "") + minutesDisplay + ":" + secondsDisplay;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user