From 140f5f7994d51664a4ac62974962dcee231af4c3 Mon Sep 17 00:00:00 2001 From: Daniel Morgenstern Date: Sun, 1 Mar 2020 11:38:59 +0100 Subject: [PATCH] fix issue with large like counts --- src/script.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/script.js b/src/script.js index 50361f74a..4c33dff99 100644 --- a/src/script.js +++ b/src/script.js @@ -110,7 +110,22 @@ function closePopup(popup, scrollList) { function addBlockButton() { tryToAccessDOM(likesCountElement => { - likesCount = likesCountElement.textContent; + likesCountText = likesCountElement.textContent; + var lastCharacter = likesCountText.slice(-1); + + var multiplyer = 1; + if (lastCharacter === "K") { + multiplyer = 1000; + } else if (multiplyer === "M") { + multiplyer = 1000000; + } + + likesCount = + multiplyer === 1 + ? // german number format: + likesCountText.replace(".", "") + : // english number format: + parseFloat(likesCountText) * multiplyer; }, "a[href$=likes] > div > span > span"); tryToAccessDOM(followButton => {