Skip to content

Commit

Permalink
fix issue with large like counts
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Mar 1, 2020
1 parent 090850c commit 140f5f7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 140f5f7

Please sign in to comment.