-
Notifications
You must be signed in to change notification settings - Fork 577
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
(Bug): Dislikes count on the userscript are not correct on some locales #520
Comments
A better fix would probably be to not set the rounding until it reaches a million, just like what happens for likes, so the code would be kept as-is with just that first check: function numberFormat(numberState) {
let userLocales;
if (numberState < 1000000)
return numberState.toLocaleString();
try {
userLocales = new URL(
Array.from(document.querySelectorAll("head > link[rel='search']"))
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
?.getAttribute("href")
)?.searchParams?.get("locale");
} catch {}
const formatter = Intl.NumberFormat(
document.documentElement.lang || userLocales || navigator.language,
{
notation: "compact",
}
);
return formatter.format(roundDown(numberState));
} |
It is a known issue. Youtube uses a different number format than the current standard. Unfortunately it's Youtube making things harder for everyone, not us. This issue happens for certain locales, and even differently for some other locales. We try to accommodate all user's needs while maintaining consistency. See issues #364 #201 #407 I guess we can do something similar to Userscript, but this time we need a way to let users choose without using GUI. One thing we want to avoid is to implement a formatter that works for one locale but breaks for another. For now the extension's implementation seems to be an acceptable workaround -- let the users have full control. What is your locale string?
|
My locale is 'es-ES'. The workaround for the extension seems to be acceptable considering the issues you mentioned, as for the userscript, one simple way to do the same would be to just set a constant at the start of the script letting them choose which of those 3 ways that the extension already offers should be used. Maybe adding some comment at the start of the script like // EDITABLE SECTION START
/* This variable changes how the dislikes are shown. Acceptable values are:
- "rounded" -> K for a thousand, M for a million
- "rounded-locale" -> Uses the numbering of your machine language
- "exact" -> Sets the dislikes as the actual number of them, without rounding */
const dislikesCounterDisplay = "rounded-locale";
// EDITABLE SECTION END I think people using userscripts should at least check the code they are installing, so it would at least be seen there (or at least, the option will exist for those that look for it). Another option would be to insert an element with the option inputs that is only shown on hover of the 10px of the bottom/side of the window, or some dialog that shows when you press a specific keyboard shortcut, the problem with that would be that it could affect extensions that also do that, so the constant approach would probably be the best option. |
I like the simple approach, since it's a one-time set up and you use the same settings forever.
All the above three combinations are "locale", while you could see different results if you enable round-down, which changes the number before sending it to the formatter. Your "rounded" option sounds like the old way before Another thing is are you seeing like count numbers as exact numbers? Because I haven't figured out why it's happening. At least one other user using the Spanish version had the same problem. See #364 (comment) After logging in the like counter changes. I didn't ask that user's locale string but judging from the number's appearance it looks like 'es-es' |
Yeah, it was just an example, the naming should be whatever is easier to implement, or what you think best represents each thing. And yep, I'm seeing them as full numbers when it's a small count: Even when it's over 100k like in this video it's shown in full number: When it's a bigger number (over 1M) like in this video it shows with the shortening: It happens the same on Vivaldi as well, but the userscript doesn't change the likes for what I see (although it does have a setLikes function declared that isn't used anywhere), so I assume that Youtube just sets things different depending on the region, since the |
using user options Anarios#539 resolves Anarios#520
using user options Anarios#520
Userscript custom colors using user options Anarios#539 Userscript user options introduce user options to userscript. Using existing options available in extension for now, plus showing update popup. Part of Anarios#539 userscript custom number formats using user options Anarios#539 resolves Anarios#520
Userscript custom colors using user options Anarios#539 Userscript user options introduce user options to userscript. Using existing options available in extension for now, plus showing update popup. Part of Anarios#539 userscript custom number formats using user options Anarios#539 resolves Anarios#520
Userscript custom colors using user options Anarios#539 Userscript user options introduce user options to userscript. Using existing options available in extension for now, plus showing update popup. Part of Anarios#539 userscript custom number formats using user options Anarios#539 resolves Anarios#520
Browser
Firefox, Vivaldi
Browser Version
Firefox Stable 98.0.2, Vivaldi 5.1.2567.66 (Stable channel)
Extension or Userscript?
Userscript
Extension/Userscript Version
0.9.0
Video link where you see the problem
https://www.youtube.com/watch?v=VgfIxCsg8xY
What happened?
The dislike returned by the api was 1412, but the dislikes count showed 1,4M.
The issue seems to be on the numberFormat function of the userscript, most specifically the locale part of it, since just replacing all the contents of the function with this makes it work as it should:
That is without using the roundDown function, but using it works all the same, I just prefered to see the actual number instead of the rounding.
How to reproduce/recreate?
Install userscript on violentmonkey, use spanish locale, and go to the video link of the problem.
Happens on both Firefox and Vivaldi (Vivaldi uses the rendering engine of chrome 98 at the point of testing)
The text was updated successfully, but these errors were encountered: