Skip to content

Add option to display time in UI #299

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

ChTosar
Copy link

@ChTosar ChTosar commented Jun 11, 2025

It displays the time in the top right corner of the screen, disappears when playback starts, and returns when the video is paused.

Copy link
Collaborator

@fire332 fire332 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. There's a few changes I would like you to make.

@fire332 fire332 added this to the v0.4.0 milestone Jun 11, 2025
@fire332 fire332 removed this from the v0.4.0 milestone Jun 14, 2025
@ChTosar
Copy link
Author

ChTosar commented Jun 16, 2025

Finally implement the visibility based on ytlr-watch-default hybridnavfocusable attribute, more effective and simpler.

});
}

destroy() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use explicit resource management instead of a destroy function.

https://v8.dev/features/explicit-resource-management

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But as I can see, this executes Dispose, when the class has a certain life cycle, if events are running inside you have to finish it manually anyway

src/watch.js Outdated
for (const mutation of mutations) {
const value = mutation.target.getAttribute('hybridnavfocusable');
// Hide watch when player is focused
this.#watch.style.display = value === 'true' ? 'none' : 'block';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can most likely be done in pure CSS using a sibling combinator. Have you investigated that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it is not a child or sibling element, and it cannot be if we want to use it before the video element appears

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we can't use :has due to performance issues with the polyfill, you're correct. But fyi, in modern browsers, you can do this:

.webOs-watch {
  display: block;
}

:has(.ytlr-watch-default[hybridnavfocusable="true"]) ~ .webOs-watch {
  display: none;
}

src/watch.js Outdated
startClock() {
const nextSeg = (60 - new Date().getSeconds()) * 1000;

const formater = new Intl.DateTimeFormat(navigator.language, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatter, not formater.

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.

2 participants