return-youtube-dislike icon indicating copy to clipboard operation
return-youtube-dislike copied to clipboard

(Bug): Re-format like numbers feature breaks youtube shorts like display

Open ErykDarnowski opened this issue 2 years ago • 10 comments

Browser

Brave

Browser Version

1.38.109 Chromium: 101.0.4951.41

Extension or Userscript?

Extension

Extension/Userscript Version

Version: 3.0.0.1

Video link where you see the problem

https://youtube.com/shorts/zqO22bpatLs?feature=share

What happened?

After watching a couple youtube shorts I noticed every video showed 0 likes until I switched the "Re-format like numbers" option off.

How to reproduce/recreate?

Just watch any youtube shorts video with the "Re-format like numbers" option turned on.

ErykDarnowski avatar May 02 '22 15:05 ErykDarnowski

<yt-formatted-string id="text" class="style-scope ytd-toggle-button-renderer style-text" aria-label="like this video along with 1.2K other people">0</yt-formatted-string>

Shorts don't have exact like counts. So we can't do formatting.

https://github.com/Anarios/return-youtube-dislike/blob/e4a52fe4de26fdae851cb6446fedd53c525323e8/Extensions/combined/src/state.js#L153

Here, return false instead, so we can use RYD server data for exact like counts. Here: https://github.com/Anarios/return-youtube-dislike/blob/e4a52fe4de26fdae851cb6446fedd53c525323e8/Extensions/combined/src/state.js#L168

  if (extConfig.numberDisplayReformatLikes === true) {
    const nativeLikes = getLikeCountFromButton();
    if (nativeLikes !== false) {
      setLikes(numberFormat(nativeLikes));
    } else {
      setLikes(numberFormat(response.likes));
    }
  }

https://github.com/Anarios/return-youtube-dislike/blob/e4a52fe4de26fdae851cb6446fedd53c525323e8/Extensions/combined/popup.html#L111

Here, change hover message to Make likes and dislikes format consistent. Shorts data are from RYD server.

Thanks @ErykDarnowski for reporting

cyrildtm avatar May 03 '22 02:05 cyrildtm

Sorry for creating a bit of a mess, I've tried implementing these changes, but when I worked on another issue unfortunetly I commited the changes straight to main, so it looks like I won't be able to create a clean pull request for this issue. Again, sorry but I'm still learning how to work with github.

ErykDarnowski avatar May 03 '22 12:05 ErykDarnowski

@ErykDarnowski Don't worry, and don't give up! Just do this one thing: always make a new branch from your main branch (assuming yours is always up to date with upstream) whenever you want to change one thing. Merge conflicts are often but in this way it's easier.

cyrildtm avatar May 03 '22 12:05 cyrildtm

Great, thank you so much for the advice! When my pull request (the one where I commited to main) gets closed I'll do just that 😃

ErykDarnowski avatar May 03 '22 13:05 ErykDarnowski

For that, you can do this trick: Create a new branch as if you want to make another PR. Cherry-pick all commits from your main branch and apply to the new branch. Make a new PR with the new branch. Force pull or sync or whatever that's called in git, do that on your main branch from upstream. Bottom line, your main branch should always be in sync with upstream. Every now and then you should check for new commits and ensure they are identical.

EDIT: Actually I overlooked the difficulty. Your main branch is already ahead, so it's not easy to create a new branch for this purpose. You can rebase, but what's the point. If I can get back some free time this weekend, I'll try to make a PR.

cyrildtm avatar May 03 '22 13:05 cyrildtm

Exactly, thank you for trying to help, but it looks like I'll just have to wait! ;)

ErykDarnowski avatar May 03 '22 13:05 ErykDarnowski

Ohh also, the same bug happens when using UserScript, so these changes also need to be implemented there.

ErykDarnowski avatar May 03 '22 13:05 ErykDarnowski

I've got an idea, I'm not sure if it's a good one. Because I could technically:

  1. close that pull request I have open (where I commited to main)
  2. remove my current fork
  3. create a new fork
  4. apply changes I've made for that pull request on a new branch
  5. create a new pull request

What do you think? 🤔

ErykDarnowski avatar May 03 '22 15:05 ErykDarnowski

You are getting close, but if you really want to do it ....

  1. Use "Revert commits" to revert changes you've made in main branch, go back to the point when you forked. Now you should have all your commits and revert commits on main branch.
  2. Sync your main with upstream.
  3. Create a new branch for the things you were working on using the main branch.
  4. Cherry pick the old commits from main. Don't pick the reverts, of course.
  5. Create a new PR with this new branch.

I should point out when you sync with upstream, there are two ways to do it. One way will eliminate all of your own work so your main branch is really "identical" to upstream. The other way makes the end results the same, but keeps your commits. And I don't remember which is which :) Stackoverflow time

cyrildtm avatar May 03 '22 15:05 cyrildtm

You're right, the pull request will probably get merged soon, so I guess it's better to wait and have a fresh start, than mess with stuff :)

ErykDarnowski avatar May 03 '22 15:05 ErykDarnowski