elliotwaite / thumbnail-rating-bar-for-youtube

A Chrome and Firefox extension for YouTube that adds a rating bar (likes/dislikes ratio) to the bottom of every thumbnail.
https://chrome.google.com/webstore/detail/youtube-thumbnail-rating/cmlddjbnoehmihdmfhaacemlpgfbpoeb
MIT License
249 stars 17 forks source link

Incorrect percentage on a video player page #45

Closed ESKEY4IK closed 1 year ago

ESKEY4IK commented 3 years ago

The percentage of the rating bar below the video is always incorrect if a video has more than 1000 likes/dislikes (example is shown in the attachment). I assume that this issue exists because in the attachment 11 and 154 are separated and putting them together will probably solve this.

Снимок экрана 2021-08-01 в 08 16 14
elliotwaite commented 3 years ago

Thank you for reporting this. This is very helpful since I have not been testing the extension in languages other than English, which uses a comma for the thousands separator. And yes, you are correct, the issue was related to the space being used for the thousands separator. I just released an update in version 1.3.8 that should fix this issue. Can you confirm that the update has fixed the issue for you?

ESKEY4IK commented 3 years ago

Yes, I've received this update and the issue has been fixed! Thank you so much!

elliotwaite commented 3 years ago

Great! Thanks again for reporting this.

Puppytine commented 1 year ago

Hi! Even though this issue is marked as "Closed", I do experience this bug. It has been present for me for a long time. Ratio of likes/dislikes on a page of a video is displayed incorrectly, both graphically and by digits, if numbers of likes exceeds 1000. If number of likes is less than 1000, the extension works as intended. It only happens when the language of a browser is set to Russian. Bug does not occur if the language is set to English, so I suspect it's related to a thousand separator (space for Russian locale). On the search results page it's always displayed properly, no matter of language or likes' count. This behavior occurs 100% of the time. I have tested it on Firefox on Windows 10, Manjaro and Mint, and on Edge on Windows 10.

2023-07-30 130408 Sophie Ellis-Bextor - Murder On The Dancefloor (Remastered 4K) - YouTube — Mozil

elliotwaite commented 1 year ago

@Puppytine, thanks for reporting this issue! You are correct, this bug had not been properly fixed. I just submitted an updated version (v1.8.8) that should resolve this issue. The Firefox version is already available and the Chrome version should be approved and released soon (the review process usually doesn't take more than 24 hours). If the update does not resolve this issue for you, please let me know. And thanks again!

Puppytine commented 1 year ago

Thank you for a rapid reply. However, I'm sorry to inform you, that even with a new version of the extension the issue isn't fixed yet. I tested it on Firefox on Windows 10 and on Manjaro. I made sure that the extension is updated, I restarted the browser and refreshed the page a few times. I also want to point out that on Edge store, version of Thumbnail Rating Bar for YouTube is still 1.8.6, not even 1.8.7.

2023-07-30 211313 Lady Gaga - Just Dance (Official Music Video) ft  Colby O'Donis - YouTube — Mozi 2023-07-30 211322 Управление дополнениями — Mozilla Firefox

elliotwaite commented 1 year ago

Ah, okay, I'll have to try a different solution. Thanks for testing out the Firefox version. It seems like the issue is related to the likes/dislikes numbers using spaces for the thousands separator instead of a comma or period. I haven't figured out how to get the numbers to display like that on my setup but I think figuring that out will help me debug the issue. Do you know what setting you changed to make the numbers display like that? What language setting are you using in YouTube? If you change the YouTube language setting to "English (US)", does that make the thousands separator a comma? And if so does that make it so the rating is correct in that mode? Is there a different browser or OS setting that changes the numbers to display like that?

Also, thanks for the note about the Edge store not having the latest version. I forget why I didn't submit 1.8.7 there, but I submitted the 1.8.8 version there, and I'll make sure to submit 1.8.9 there too once I get the fix working, however, they are usually slower to approve updates.

Puppytine commented 1 year ago

I haven't figured out how to get the numbers to display like that on my setup but I think figuring that out will help me debug the issue.

You should be able to reproduce this behavior by switching to Russian in Firefox settings. Changing language on the site seems to have no effect.

2023-07-31 064035 Settings — Mozilla Firefox 2023-07-31 064424 Анна Щербакова, произвольная программа _ Пекин-2022 - YouTube — Mozilla Firefox 2023-07-31 064410 Анна Щербакова, произвольная программа _ Пекин-2022 - YouTube — Приватный просмо

elliotwaite commented 1 year ago

Okay, thanks. For some reason changing my browser language didn't change the number format, but I think I figured out the issue anyway. I experimented with using JavaScript's .toLocaleString("ru-RU") method and it turns out the thousands separator is a non-breaking space, instead of a normal space, which makes sense. So I updated the code to work with non-breaking spaces and released it as version 1.8.9. It's available for Firefox and in review for Chrome and Edge. If this update doesn't resolve the issue for you, let me know.

Puppytine commented 1 year ago

For some reason changing my browser language didn't change the number format

hm... that is weird.

But anyway, you aren't going to believe it, but... It still doesn't work! Additionally, I found some strange thing: I downloaded (via Edge) youtube_thumbnail_rating_bar-1.8.9.xpi from Firefox addon store, opened it with WinRAR, then opened "content-script.js", but I couldn't find there changes from your last commit. I'm not only talking about that RegExp that was changed, but also a commentary line, "zero width" => "zero-width". It looks like an older version. Are you sure you correctly deployed updated extension to Firefox addon store?

Update: content-script.js in 1.8.8.xpi is seems to be from 1.8.7.xpi as well. I managed to run actual 1.8.8 and 1.8.9 from GitHub on my own. 1.8.9 works correctly, 1.8.8 doesn't (because normal spaces).

2023-07-31 195057 Greenshot

elliotwaite commented 1 year ago

Oh, right, thanks. When I upgraded the extension to use Manifest v3 for Chrome, I split the content-script.js into two versions, one for Chrome which uses Manifest version 3, and another for Firefox and Edge which uses Manifest v2. I had forgotten to also make the changes to the Manifest v2 one (oops). I just released v1.8.10 which should fix this issue. Let me know if this update does the trick. And thanks for helping me debug this.

Puppytine commented 1 year ago

Now the extension works properly. Thank you! I tested it on Firefox on Windows 10 and Manjaro. Edge's version is still on moderation, I guess, it shows me that 1.8.6 is latest one.

Not sure if you want to go deeper with this bug, but I noticed that switching to Arabic produces incorrect results, similar to what it was for Russian before 1.8.10 (fine on a search page and the main page, broken on a video's page). This is because they do their own thing both with thousand separator and digits, I guess.

elliotwaite commented 1 year ago

Great. I'm glad to hear the Russian version is working now.

That's a good suggestion to add support for other numbering systems (Arabic, etc.). I just submitted an update (v1.8.11) that should add support for all possible JavaScript numbering systems. It's hard for me to test it though since I'm not sure how to get my browser to switch to printing Arabic numbers. But if this update doesn't fix the issue with Arabic numbers for you, feel free to let me know.

Puppytine commented 1 year ago

That's a good suggestion to add support for other numbering systems (Arabic, etc.).

Well, I mentioned Arabic mostly to mess with you, and to be unnecessarily pedantic tbh :) I don't know Arabic, I have nothing to do with Arabic (but my concerns about Russian were legit). With v1.8.11, Arabic seems to be fine, as far as I can tell (though percentage is displayed as normal numbers, and other numbers uses Arabic; but I don't know either, should it be fixed or can it be fixed).

It's hard for me to test it though since I'm not sure how to get my browser to switch to printing Arabic numbers.

That is weird, since I can just choose any other language in Firefox settings, and it will be instantly applied in browser's GUI (switching to/from RTL languages like Arabic requires restarting the browser though), and JS functions like .toLocaleString() are affected after reloading a page. It works both on Windows and on Linux. Make sure that 'Use your operating system settings for \<Language> to format dates, times, numbers, and measurements' box is not checked.

Anyway, just another little thing to mention: on Edge store, the extension isn't yet updated. But I've installed it on Edge from Chrome store, and it works fine.

Thank you for all fixes, and for creating this extension.

2023-08-02 223055 Nightwish - Wishmaster  Live  - YouTube — Mozilla Firefox

elliotwaite commented 1 year ago

Ah, thanks for the tips. I finally got Firefox to display numbers using the selected language. However, I'm not sure how I fixed it. I had changed some configs using the about:config page (but I thought I had reset them back to what they were originally), and I had also restarted Firefox a few times and tried using several different languages, and somehow in that process, it started working as expected. So I should be able to better debug these issues in the future. Thanks for helping me figure this out and for testing the previous updates.

I just submitted v1.8.12 updates the rating percent to now also be displayed using the current locale numbering system. Thanks for noticing that.

In the future, perhaps I could internationalize the extension even further by using translated strings, instead of always using the string "total", and always using the % symbol, which I'm not sure if it means the same thing in all languages. But I think I'll wait for now before investing in that work.

And about the Edge version, yeah, they are much slower to review updates for some reason, but the latest version has been submitted there, and it should be available within the next week (its status page currently says "Expect to hear back from us in 7 business days").

Thanks again for all the help, and feel free to let me know if you notice anything else that should be fixed.