Update script.js: Adding formatted dislike counter

Before this dislike showed raw data from fetched counter, eg: 100000.
After little tweaking, it show formatted number, eg: 1000 -> 1k, 1000000 -> 1M.
This commit is contained in:
Bismantaka Aldila authored and GitHub committed 2021-11-15 12:38:54 +07:00
1 parent f547adf87f
commit eb11342658
1 file changed
+7
+7
View File
@@ -55,6 +55,7 @@ function setState() {
},
function (response) {
if (response != undefined) {
const formattedDislike = numberFormat(response.dislikes);
// setLikes(response.likes);
console.log(response);
setDislikes(response.dislikes);
@@ -91,6 +92,12 @@ function isVideoLoaded() {
);
}
function numberFormat(numberState) {
const userLocales = navigator.language;
const formatter = Intl.NumberFormat(userLocales, { notation: 'compact' })
return formatter.format(numberState)
}
function setEventListeners(evt) {
function checkForJS_Finish() {
if (getButtons()?.offsetParent && isVideoLoaded()) {