Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implemented option to show like/dislike percentage instead of full like/dislike count #560

Merged
merged 15 commits into from
Jul 19, 2022
Merged

Conversation

ErykDarnowski
Copy link
Contributor

@ErykDarnowski ErykDarnowski commented Apr 21, 2022

Issue #211
I've had the same idea for some time, so after seeing @Nightcaat's issue I decided to work on this feature.

@ErykDarnowski ErykDarnowski changed the title Implemented option to show like/dislike percentage instead of full like/dislike count #211 Implemented option to show like/dislike percentage instead of full like/dislike count Apr 21, 2022
@ErykDarnowski
Copy link
Contributor Author

ErykDarnowski commented Apr 21, 2022

My bad, force-pushed to fix 2 things I missed because didn't notice this: "Add more commits by pushing to the main branch on ErykDarnowski/return-youtube-dislike."

@Nightcaat Nightcaat self-requested a review April 21, 2022 18:41
@Nightcaat Nightcaat added the enhancement New feature or request label Apr 21, 2022
<div class="custom-select">
<label for="tooltip_percentage_mode" data-hover="Use custom percentage display on hover.">Percent mode:</label>
<select name="tooltip_percentage_mode" id="tooltip_percentage_mode">
<option value="dash_like" id="tooltip_percentage_mode_dash_like">Dash like</option>
Copy link
Contributor

@cyrildtm cyrildtm Apr 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be easier for you and users if the <option> innerHTML is indeed the example: 190&nbsp;/&nbsp;10&nbsp;&nbsp;-&nbsp;&nbsp;5%

Copy link
Contributor Author

@ErykDarnowski ErykDarnowski Apr 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I created an example element the same way theme colors have one, but you've got a point. Let me try this out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It honestly looks and feels much better, thank you for the suggestion!

@cyrildtm
Copy link
Contributor

Just want to point out this feature is already implemented in this extension: Thumbnail Rating Bar for YouTube™ I've been using it since the same time I got RYD.

Anyway, good work.

@cyrildtm
Copy link
Contributor

BTW could you take a look at #540? Your feature would be also great for userscript.

@ErykDarnowski
Copy link
Contributor Author

ErykDarnowski commented Apr 22, 2022

Yeah, I saw your issue so I'm planning to do that ;). Also I think it's still nice to not have to install a couple extension for features related to each other.

@cyrildtm
Copy link
Contributor

I'm not so worried. I use that extension mainly for batch examining. It happens to put a percentage in the ration bar.

@ErykDarnowski
Copy link
Contributor Author

I've made a typo in this commit's 9982082 msg, I meant issue #211 instead of #221

@@ -29,6 +29,9 @@ let previousState = 3; //1=LIKED, 2=DISLIKED, 3=NEUTRAL
let likesvalue = 0;
let dislikesvalue = 0;

// Temporary user config variable until better solution is found:
var tooltipPercentageDisplayOption = "classic"; // classic ; dash_like ; dash_dislike ; both ; only_like ; only_dislike
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future consideration, you may take a look at #540. We can mirror the data structure in the extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll probably work on this today 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it would be a good idea to add a boolean value for switching the percent display on/off like I've done it in the extension popup window. Although it could totally be done in just one var like it is at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a list option 'none'?

Copy link
Contributor Author

@ErykDarnowski ErykDarnowski Apr 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an option called "classic" already which works like "none" would :). Although I guess "none" would make more sense. I used the same default value as I think colorTheme did.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The color thing has a separate switch so you can control two things differently, thumbs and bar. If i made the "none" option in the color theme then i can only turn everything on and off together.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, yeah I get that. I was just wondering if it should replicate the extension popup, but there isn't really a good reason for it.

"only_dislike": `${dislikePercentage}%`
};

if (tooltipPercentageDisplayModes[tooltipPercentageDisplayOption] === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be necessary for userscript, since everything is in this script :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... are you recommending a switch? Because either way (extension or UserScript) we still need to 'convert' the tooltipPercentageDisplayOption string from extConfig in to a format for the tooltip.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No i meant everything will be defined unless user misuse! Undefined is used in extension for change events or first install/new feature update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh! I get what you mean. But I'm using === undefined here to check if the string given by the user in tooltipPercentageDisplayOption from extConfig can be found as a key in the tooltipPercentageDisplayModes dict :). If the user inputs anything other than a correct option tooltipPercentageDisplayOption is set to "classic" (the default value).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's what I'm saying, you don't need it, because tooltipPercentageDisplayOption is set at the beginning, inside extConfig if you use the other pr. If it's undefined the switch statement should get into default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually i just read your code again. I would recommend against assigning strings for all options for every video, because you only need to see one. It's using a lot of computing power to process toLocaleString(), and the result will just get wasted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I missed that somehow, guess I should use a switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Copy link
Contributor

@Blueberryy Blueberryy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool feature

@ErykDarnowski
Copy link
Contributor Author

It was @Nightcaat's idea I just implemented it, but thank you 😄

@Anarios Anarios changed the base branch from main to develop July 19, 2022 22:01
@Anarios Anarios merged commit cb5f947 into Anarios:develop Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to show like/dislike percentage instead of full like/dislike count
5 participants