mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 05:27:03 +03:00
Made the time appear more nicely formatted.
This commit is contained in:
11
popup.js
11
popup.js
@@ -142,7 +142,7 @@ function getVideoTimesMessage(sponsorTimes) {
|
|||||||
|
|
||||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||||
for (let s = 0; s < sponsorTimes[i].length; s++) {
|
for (let s = 0; s < sponsorTimes[i].length; s++) {
|
||||||
let timeMessage = sponsorTimes[i][s].toFixed(1) + "s";
|
let timeMessage = getFormattedTime(sponsorTimes[i][s]);
|
||||||
//if this is an end time
|
//if this is an end time
|
||||||
if (s == 1) {
|
if (s == 1) {
|
||||||
timeMessage = " to " + timeMessage;
|
timeMessage = " to " + timeMessage;
|
||||||
@@ -176,6 +176,15 @@ function submitTimes() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//converts time in seconds to minutes:seconds
|
||||||
|
function getFormattedTime(seconds) {
|
||||||
|
let minutes = Math.floor(seconds / 60);
|
||||||
|
let secondsDisplay = Math.round(seconds - minutes * 60);
|
||||||
|
let formatted = minutes+ ":" + secondsDisplay;
|
||||||
|
|
||||||
|
return formatted;
|
||||||
|
}
|
||||||
|
|
||||||
function getYouTubeVideoID(url) { // Return video id or false
|
function getYouTubeVideoID(url) { // Return video id or false
|
||||||
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
|
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
|
||||||
var match = url.match(regExp);
|
var match = url.match(regExp);
|
||||||
|
|||||||
Reference in New Issue
Block a user