austencm / youtube-auto-like

Chrome extension that automatically likes videos from your subscribed channels.
MIT License
164 stars 53 forks source link

Update selectors #97

Closed wthueb closed 2 years ago

wthueb commented 2 years ago

Addresses #95.

wthueb commented 2 years ago

Unfortunately I haven't been able to test this, as YouTube seems to like to sporadically give me the new like buttons and I didn't save the page when I last saw them, but if I'm remembering correctly these selectors should be right. I'll update this to confirm this works if YouTube decides I should see the new buttons anytime soon.

Kinomora commented 2 years ago

If you can send me a compiled beta (for chrome) I can test it since I seem to be getting the new buttons all the time now

Taknok commented 2 years ago

Your selector is a bit too specific, their is multiple youtube version co-existing at the same time. Some users are selected to test the new youtube version in their country and it differ for different countries. Ex: US may have latest youtube, while spain has only few users doing beta while none in Australia use the newer youtube.

I suggest you those selectors: (used on Firefox version)

if mobile location.hostname == "m.youtube.com":

".slim-video-action-bar-actions"

if old (document.getElementById("menu-container")?.offsetParent === null):

"ytd-menu-renderer.ytd-watch-metadata > div"

if new (document.getElementById("menu-container")?.offsetParent !== null):

document
      .getElementById("menu-container")
      ?.querySelector("#top-level-buttons-computed");
wthueb commented 2 years ago

@Taknok I don't think that mobile support has historically been a consideration for this project, and it seems like @austencm phased out non-material YouTube a long time ago with v2.0.0. The current selector(s) do use "#menu-container #top-level-buttons-computed".

wthueb commented 2 years ago

YouTube has decided to show me the new buttons and I can confirm that these new selectors are working.

Taknok commented 2 years ago

True for mobile, but I put an extended answer to give all keys to the owner. So he can select what he wants in the tool box.

There is subversion in youtube material, where tags, id, class, elements, SVG path change etc etc. On Firefox I had to release 2 versions of the addon in a row, and it goes like that:

  1. YouTube released new version in some places.
  2. Countries and beta testers warned me that the addon was broken for the new youtube.
  3. I updated the selectors assuming an old youtube material version is not used anymore and overwrite it.
  4. User in git issue tested it and it was functionnal.
  5. I published.
  6. Other user warned me that since addon new release, it is broken. But downgrading make it works.
  7. I restore old selector along the new
  8. Published
  9. No issue report for now

    So yes those new selectors are working for you, but maybe not for half of the others users, which is why I advise to use both testing case and adapted selectors. This is how I handled it in Firefox and I hope it can save time and release to austencm.

wthueb commented 2 years ago

If you look at the commit, I added the new selector while keeping the old (current, non-beta) one. This change doesn't remove functionality for anyone, it simply adds functionality for those who are shown the beta version of the UI.

wthueb commented 2 years ago

Closing this because I haven't seen the new buttons in a long time and never got to test it.