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

(Bug): Update dislike when like is updated #561

Open
cyrildtm opened this issue Apr 22, 2022 · 3 comments
Open

(Bug): Update dislike when like is updated #561

cyrildtm opened this issue Apr 22, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@cyrildtm
Copy link
Contributor

Browser

Chrome

Browser Version

99

Extension or Userscript?

Extension

Extension/Userscript Version

3

Video link where you see the problem

any

What happened?

Dislike numbers are outdated, or not for the currently playing videos.

This issue and proposed fix should work for both extension and userscript.

How to reproduce/recreate?

Current youtube UI may "survive" when switching videos, meaning the entire page is not replaced for a new video, but just certain elements.
The extension and userscript should detect this video change, and update the dislike counter accordingly.

Related: #506 Live video does not get real-time counts.
Related: #498 When the new video does not get a dislike number, old results are displayed. This is because the HTML document is not reloaded.
Related: #518 Suspects mini player is involved, which does not reload a page when switching videos.

Possible solution:

  1. Add a default-empty variable to store last "checked" video (sent API server request, processed dislike number, updated ratio bar and thumbs).
  2. Add a function to detect if the current video is a live stream.
  3. Add an event listener for thumbs up innerHTML change. Treat it the same way as a page reload, if the current video is different than previous, or if it's a live stream.
@cyrildtm cyrildtm added the bug Something isn't working label Apr 22, 2022
@cyrildtm
Copy link
Contributor Author

cyrildtm commented Apr 24, 2022

Use the mutation observer implemented in #567 once it is merged. Hold on for now.

  • Wait for innerText change for like button
  • Compare memory variable lastProcessedVideoId with the new one: const videoId = getVideoId(window.location.href);
    const videoId = getVideoId(window.location.href);
  • If it's a different video (rather than a live stream), reset storedData
  • Call setInitialState

Consider: implement resetStoredData

@cyrildtm
Copy link
Contributor Author

cyrildtm commented May 1, 2022

This happened twice in ten minutes:
Capture

Because the old page for the previous video was not properly flushed out, new content was added after hitting the like button

cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue May 8, 2022
When like button is clicked, only one of the two aria-label attributes gets updated. Use the correct one to reflect latest like count. Affects user option "re-format like numbers"

Attn Anarios#561
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue May 8, 2022
When like button is clicked, YT will update like count. This conflicts with user option "re-format like numbers". Force update like number.

attn Anarios#561 Anarios#584
@cyrildtm
Copy link
Contributor Author

To be done soon: Extend the newly merged mutation observer to monitor like number changes

gergelypap pushed a commit to gergelypap/return-youtube-dislike that referenced this issue Sep 28, 2023
When like button is clicked, only one of the two aria-label attributes gets updated. Use the correct one to reflect latest like count. Affects user option "re-format like numbers"

Attn Anarios#561
gergelypap pushed a commit to gergelypap/return-youtube-dislike that referenced this issue Sep 28, 2023
When like button is clicked, YT will update like count. This conflicts with user option "re-format like numbers". Force update like number.

attn Anarios#561 Anarios#584
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant