Browse Source

Merge pull request #1 from bstka/main

Update script.js: formatted dislike counter
Dmitrii Selivanov 3 năm trước cách đây
mục cha
commit
5dfc8f11ae
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  1. 7 0
      script.js

+ 7 - 0
script.js

@@ -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()) {