HatScripts / youtube-auto-liker

A userscript that automatically likes 👍 each video you watch on YouTube ▶️
68 stars 15 forks source link

New selectors for like and dislike buttons, plus for shorts #33

Open kas-cor opened 1 year ago

BleakBluets commented 12 months ago

For the Shorts subscribe button, instead of testing for a class, we could test for the 'subscribed' attribute on the <ytd-subscribe-button-renderer> element which the subscribe button is a descendant of. The subscribe check would then look like this:

const subscribed = subscribeButton.hasAttribute('subscribe-button-invisible') || subscribeButton.hasAttribute('subscribed')

The selector for the subscribe button would then be:

SUBSCRIBE_BUTTON: '#subscribe-button > ytd-subscribe-button-renderer, ytd-reel-player-overlay-renderer #subscribe-button',

In my opinion, this is makes both the subscribe check and the selector cleaner and not dependent on the style of the UI.

BleakBluets commented 12 months ago

For the like/dislike button selectors, I made a similar change in #32, except, because there are two results for each button with those selectors, I think it may be necessary to be more specific due to issues raised in #17.

Your change also removes #segmented-like-button and #segmented-dislike-button, but they are still required, at least in my case. Those ids haven't been fully depreciated yet. If the #like-button button selector is what you have, then (I see this change was for the Shorts dis/like buttons) I believe that three selectors should be used like so:

LIKE_BUTTON: '#menu .YtLikeButtonViewModelHost button, #segmented-like-button button, #like-button button'

... and likewise for the dislike button:

DISLIKE_BUTTON: '#menu .YtDislikeButtonViewModelHost button, #segmented-dislike-button button, #dislike-button button'

These combined changes would also fix #30

HatScripts commented 12 months ago

@BleakBluets I've implemented your suggestions (https://github.com/HatScripts/youtube-auto-liker/commit/9ea38ad28973392cf71e69eef3f3209ba0195989)! Thank you

riccardosimo commented 12 months ago

Oh finally a script that works 😍😍 Is it possible to add an alert that disappears after like 2/3 seconds just to know if the script worked? Because everytime i have to scroll down the page to make sure that the script worked 🥹

HatScripts commented 12 months ago

@riccardosimo Could you please create a new issue for the feature request you are describing?

And please elaborate on: