mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-21 22:03:01 +01:00
Merge pull request #63 from j14-c/main
modified numberFormat to round down and include decimals
This commit is contained in:
3 files changed
+44
-6
No files matched your search
@@ -192,11 +192,23 @@ function isVideoLoaded() {
|
||||
);
|
||||
}
|
||||
|
||||
function roundDown(num) {
|
||||
if (num < 1000) return num;
|
||||
const decimal = Math.floor(Math.log10(num) - 1);
|
||||
const value = Math.floor(num / 10 ** decimal);
|
||||
return value * (10 ** decimal);
|
||||
}
|
||||
|
||||
function numberFormat(numberState) {
|
||||
const userLocales = navigator.language;
|
||||
const formatter = Intl.NumberFormat(userLocales, { notation: "compact" });
|
||||
|
||||
return formatter.format(numberState);
|
||||
const formatter = Intl.NumberFormat(userLocales, {
|
||||
notation: 'compact',
|
||||
minimumFractionDigits: 1,
|
||||
maximumFractionDigits: 1
|
||||
});
|
||||
|
||||
return formatter.format(roundDown(numberState)).replace('.0', '');
|
||||
}
|
||||
|
||||
function setEventListeners(evt) {
|
||||
|
||||
Reference in new issue
Block a user