Skip to content

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

Open
kas-cor wants to merge 1 commit intoHatScripts:masterfrom
kas-cor:patch-3
Open

New selectors for like and dislike buttons, plus for shorts#33
kas-cor wants to merge 1 commit intoHatScripts:masterfrom
kas-cor:patch-3

Conversation

@kas-cor
Copy link
Copy Markdown
Contributor

@kas-cor kas-cor commented Nov 23, 2023

No description provided.

@BleakBluets
Copy link
Copy Markdown
Contributor

BleakBluets commented Dec 1, 2023

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
Copy link
Copy Markdown
Contributor

BleakBluets commented Dec 1, 2023

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
Copy link
Copy Markdown
Owner

HatScripts commented Dec 1, 2023

@BleakBluets I've implemented your suggestions (9ea38ad)! Thank you

@riccardosimo
Copy link
Copy Markdown

riccardosimo commented Dec 1, 2023

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
Copy link
Copy Markdown
Owner

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

And please elaborate on:

  • when you want the alert to appear
  • what you mean by "scroll down the page to make sure that the script worked"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants