Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channelID lookup optimizations #1249

Closed
1 task done
mchangrh opened this issue Mar 26, 2022 · 7 comments · Fixed by #1250
Closed
1 task done

channelID lookup optimizations #1249

mchangrh opened this issue Mar 26, 2022 · 7 comments · Fixed by #1250
Assignees

Comments

@mchangrh
Copy link
Contributor

  • currently working on this

cc @zedseven

@mchangrh
Copy link
Contributor Author

.take

@zedseven
Copy link
Contributor

.take

@github-actions
Copy link
Contributor

The issue you are trying to assign to yourself is already assigned.

@mchangrh
Copy link
Contributor Author

mchangrh commented Mar 26, 2022

Selectors

in-video

.ytd-channel-name a

  • unreliable
  • multiple results
  • top results is hidden home screen

.ytd-video-owner-renderer a

  • would pick up on "join" button

a.ytd-video-owner-renderer

  • reliable
  • specific to channel box
  • reliable even in fullscreen and changing videos

embed

  • already reliable as-is

@zedseven
Copy link
Contributor

To see the unreliability of the .ytd-channel-name a selector, open a fresh tab and in the Home tab select a video that's from a different channel than the first result in the Home tab.

Once the video is loaded, run document.querySelector('.ytd-channel-name a') in the console - you should get the custom channel URL for the first Home result, not the channel of the current video.

Running document.querySelectorAll shows this selects all Home nodes.

Also, somewhat unrelated, but it seems like the custom channel URL is only used in the Home tab. For the channel links on active videos, it seems to always be the channel ID. This means that user channel overrides that use the custom URL (likely) have never worked and will not work after this is fixed.

@zedseven
Copy link
Contributor

The regex can also be more strict, handling trailing slashes and absolute/relative URLs as well. Using the capture group as the channel ID instead of replacing the non-channel ID parts, the following should work in all tested scenarios:
\/channel\/(UC[a-zA-Z0-9_\-]{22})

@zedseven
Copy link
Contributor

Also the Invidious selector should probably select based on the #channel-name instead of .channel-profile - there were several instances of .channel-profile in my testing but only one #channel-name.

Something like document.querySelector("#channel-name").parentElement.parentElement should do the trick.

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 a pull request may close this issue.

2 participants