mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 05:57:07 +03:00
Added time the user saved others from plus better time formatting.
This commit is contained in:
@@ -308,5 +308,11 @@
|
|||||||
},
|
},
|
||||||
"hoursLower": {
|
"hoursLower": {
|
||||||
"message": "hours"
|
"message": "hours"
|
||||||
|
},
|
||||||
|
"youHaveSavedTime": {
|
||||||
|
"message": "You have saved people"
|
||||||
|
},
|
||||||
|
"youHaveSavedTimeEnd": {
|
||||||
|
"message": " of their lives."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
popup.html
10
popup.html
@@ -130,6 +130,16 @@
|
|||||||
<span id="sponsorTimesViewsDisplayEndWord" class="popupElement">__MSG_Segments__</span>.
|
<span id="sponsorTimesViewsDisplayEndWord" class="popupElement">__MSG_Segments__</span>.
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
<span id="sponsorTimesOthersTimeSavedContainer" class="popupElement" style="display: none">
|
||||||
|
__MSG_youHaveSavedTime__
|
||||||
|
<span id="sponsorTimesOthersTimeSavedDisplay" class="popupElement">
|
||||||
|
0
|
||||||
|
</span>
|
||||||
|
<span id="sponsorTimesOthersTimeSavedEndWord" class="popupElement">__MSG_minsLower__</span>
|
||||||
|
|
||||||
|
<span class="popupElement">__MSG_youHaveSavedTimeEnd__</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|||||||
35
popup.js
35
popup.js
@@ -56,6 +56,10 @@ function runThePopup() {
|
|||||||
"sponsorTimesViewsContainer",
|
"sponsorTimesViewsContainer",
|
||||||
"sponsorTimesViewsDisplay",
|
"sponsorTimesViewsDisplay",
|
||||||
"sponsorTimesViewsDisplayEndWord",
|
"sponsorTimesViewsDisplayEndWord",
|
||||||
|
// sponsorTimesOthersTimeSaved
|
||||||
|
"sponsorTimesOthersTimeSavedContainer",
|
||||||
|
"sponsorTimesOthersTimeSavedDisplay",
|
||||||
|
"sponsorTimesOthersTimeSavedEndWord",
|
||||||
// sponsorTimesSkipsDone
|
// sponsorTimesSkipsDone
|
||||||
"sponsorTimesSkipsDoneContainer",
|
"sponsorTimesSkipsDoneContainer",
|
||||||
"sponsorTimesSkipsDoneDisplay",
|
"sponsorTimesSkipsDoneDisplay",
|
||||||
@@ -244,6 +248,23 @@ function runThePopup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//get this time in minutes
|
||||||
|
sendRequestToServer("GET", "/api/getSavedTimeForUser?userID=" + userID, function(xmlhttp) {
|
||||||
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
|
let minutesSaved = JSON.parse(xmlhttp.responseText).timeSaved;
|
||||||
|
if (minutesSaved != 0) {
|
||||||
|
if (minutesSaved != 1) {
|
||||||
|
SB.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
|
||||||
|
} else {
|
||||||
|
SB.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
|
||||||
|
}
|
||||||
|
|
||||||
|
SB.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved);
|
||||||
|
SB.sponsorTimesOthersTimeSavedContainer.style.display = "unset";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -272,7 +293,7 @@ function runThePopup() {
|
|||||||
SB.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
|
SB.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
|
||||||
}
|
}
|
||||||
|
|
||||||
SB.sponsorTimeSavedDisplay.innerText = result.minutesSaved.toFixed(2);
|
SB.sponsorTimeSavedDisplay.innerText = getFormattedHours(result.minutesSaved);
|
||||||
SB.sponsorTimeSavedContainer.style.display = "unset";
|
SB.sponsorTimeSavedContainer.style.display = "unset";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1413,6 +1434,18 @@ function runThePopup() {
|
|||||||
//submit this request
|
//submit this request
|
||||||
xmlhttp.send();
|
xmlhttp.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts time in hours to 5h 25.1
|
||||||
|
* If less than 1 hour, just returns minutes
|
||||||
|
*
|
||||||
|
* @param {float} seconds
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function getFormattedHours(minues) {
|
||||||
|
let hours = Math.floor(minues / 60);
|
||||||
|
return (hours > 0 ? hours + "h " : "") + (minues % 60).toFixed(1);
|
||||||
|
}
|
||||||
|
|
||||||
//end of function
|
//end of function
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user