diff --git a/Extensions/UserScript/Return Youtube Dislike.user.js b/Extensions/UserScript/Return Youtube Dislike.user.js index bca1d51..47ddaac 100644 --- a/Extensions/UserScript/Return Youtube Dislike.user.js +++ b/Extensions/UserScript/Return Youtube Dislike.user.js @@ -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) { diff --git a/Extensions/chrome/return-youtube-dislike.script.js b/Extensions/chrome/return-youtube-dislike.script.js index 6a148f7..5ec0172 100644 --- a/Extensions/chrome/return-youtube-dislike.script.js +++ b/Extensions/chrome/return-youtube-dislike.script.js @@ -137,10 +137,23 @@ ); } + 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', ''); } var jsInitChecktimer = null; diff --git a/Extensions/firefox/return-youtube-dislike.script.js b/Extensions/firefox/return-youtube-dislike.script.js index 058a38b..2597ee2 100644 --- a/Extensions/firefox/return-youtube-dislike.script.js +++ b/Extensions/firefox/return-youtube-dislike.script.js @@ -133,10 +133,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) {