Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(Feature Request): Only display an approximate value of dislikes if YouTube also returns likes as an approximate value. #364

Closed
1 of 2 tasks
ghost opened this issue Dec 23, 2021 · 12 comments · Fixed by #435
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Dec 23, 2021

Extension or Userscript?

Extension

Request or suggest a new feature!

I don't know if I'm explaining this right, but here's the thing: for me, dislikes are displayed as "1,7 MIL" (as an example), while likes are displayed as an "exact value" (150.749).

Here's an example:
image

I can even see the exact amount of dislikes that the video has, so it shouldn't be that hard to implement it:
image

In case this couldn't be done; the extension could also modify the like count to an approximate value (just like the dislike count) if the user wanted to, but I don't see why wouldn't it be possible.

Ways to implement this!

A way to implement this is checking if the like count is an exact value or an approximate one. Then, change the dislike button based to a different value using the like button.

Can you work on this?

  • Yes
  • No
@ghost ghost added the enhancement New feature or request label Dec 23, 2021
@ghost ghost changed the title (Feature Request): Only display an approximate value if YouTube also returns likes as an approximate value. (Feature Request): Only display an approximate value of dislikes if YouTube also returns likes as an approximate value. Dec 23, 2021
@cyrildtm
Copy link
Contributor

Could you provide a link to the video you used for screenshots?
I looked at Youtube Rewind 2018, it tells me "3M" likes besides the thumbs up (yay), and "20M" dislikes besides thumbs down. I can't find a good example to replicate your case.

Also, why does your screenshot says 1.7 million dislikes while the exact number is 1752? It doesn't seem to add up to me.

Anyway, the code related to writing dislike count in "compact" format is here:

@Eleiber
Copy link

Eleiber commented Dec 28, 2021

I know this isn't really important, but he probably uses the Spanish version of YouTube, in Spanish, "Mil" means thousand.

@ghost
Copy link
Author

ghost commented Dec 29, 2021

Also, why does your screenshot says 1.7 million dislikes while the exact number is 1752? It doesn't seem to add up to me.

That's because I'm using the Spanish version of YouTube, as someone already said. Anyways, I don't think this is video-specific since I can click any video and it will be displayed just like the one I used as an example:

image

I've also discovered that if the like counter is higher than 1 million it will be displayed with a compact format too:

image

@cyrildtm
Copy link
Contributor

tbh I remember watching this video a while ago. Here's what I see, with the abbreviation:

Capture

What extensions have you installed? I've just tried with incognito once and I didn't see the exact number.

@ghost
Copy link
Author

ghost commented Dec 29, 2021

What extensions have you installed? I've just tried with incognito once and I didn't see the exact number.

Return YouTube Dislike, GitHub Red Issues, uBlock Origin, UniversalBypass and GNOME Shell Integration

I've enabled the extension to be able to run in private mode (firefox), and without signing in, this is what I see:

image

However, if I #, it goes back to the same thing as before:

image

@cyrildtm
Copy link
Contributor

cyrildtm commented Dec 29, 2021

So when you # with firefox private mode, it shows up with six figures?
Then it's not with the plugins, but your youtube / google account settings, right? Do you remember if you have changed any settings, or does it come with your locale?

If it's a thing with locale's default, then probably the dislike formatting can include a detection.

Also, I actually want to know how you got this. I miss the old time being able to see the exact numbers lol.

@ghost
Copy link
Author

ghost commented Dec 29, 2021

I haven't changed any settings on my Google account, so it seems to be locale related

@cyrildtm
Copy link
Contributor

To see the exact number, these lines will need to be modified:

Leaving the curly bracket empty works fine for me.

Also, the function numberFormat() returns a rounded down number:

return formatter.format(roundDown(numberState));

using function roundDown() defined a few lines above.

That's what I can see from the source code. But it's still strange to me that your default settings gives you exact numbers below one million, but rounds up for bigger ones. The cut-off line for me is one thousand. I'm still trying to understand this, but perhaps other people more fluent with web programming can explain. To me, it seems that Youtube is using some customized version of number-shortening mechanism that is obviously doing differently for you. If that happens on the server side, there is probably nothing we can do, unless we implement an awkward way to visually check how the like counter is displayed.

Plus on the programming side, correct me if I'm wrong, but why do we need to evaluate userLocales and formatter each time we need a number? It seems inefficient, and people don't seem to change their primary browser language between watching two videos.

@cyrildtm
Copy link
Contributor

Here's a quick fix, just to make the like and dislike counters have the same style, but I don't like how I overwrite the youtube's like counter with the plugin's data --- is it always accurate and the same as yt's official data?

Before this line, insert:

        setLikes(numberFormat(likes));

btw in function definitions for setLikes() and setDislikes() the buttons could have been assigned using wrapper functions getLikeButton() and getDislikeButton() it's not a big deal but I just can't unsee it.

@ghost
Copy link
Author

ghost commented Dec 30, 2021

is it always accurate and the same as yt's official data?

If you open up inspect element you can see the exact amount of likes is not hidden, although you can't see it normally:

image

@cyrildtm
Copy link
Contributor

You are right. Then this should work:

        setLikes(numberFormat( getLikeButton().querySelector("#text").getAttribute("aria-label").replace(/\D/g, '') ));

@cyrildtm
Copy link
Contributor

cyrildtm commented Dec 30, 2021

On a second thought, we could have a toggling switch to say whether or not we want exact numbers on both buttons. The function numberFormat() will adhere to the user's preference. It's always consistent.

I can't think of an easy way to detect how your like button counter is being displayed; perhaps when others see this post can help. If that is possible, then your original idea can be done, make the dislike counter follow whatever is offered by youtube's like counter.

Here's a possible way to detect if the like counter number is being shortened:

likebuttontextdom = getLikeButton().querySelector("#text");
if likebuttontextdom.getAttribute('aria-label').replace(/\D/g, '') === likebuttontextdom.innerText { // displayed like number is exact
  setDislikes(numberFormatExact(dislikes));
} else {
  setDislikes(numberFormat(dislikes));
}

A new function numberFormatExact() returns formatterExact.format(numberState); (without round down) and the new formatterExact is defined without notation: "compact"

cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 11, 2022
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 12, 2022
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 13, 2022
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 13, 2022
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 18, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants