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

Update to work with the latest Apple TV #866

Merged
merged 2 commits into from
Sep 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ function defineVideoController() {
p.insertBefore(fragment, p.firstChild);
break;
case location.hostname == "tv.apple.com":
// insert after parent for correct stacking context
this.parent.getRootNode().querySelector(".scrim").prepend(fragment);
// pass-through, the latest version of AppleTV works with default behavior
Copy link
Owner

Choose a reason for hiding this comment

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

Can we remove this branch? No purpose, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up modifying it so that the hover works too (before it would show and you could use hotkeys but not modify the UI directly)

default:
// Note: when triggered via a MutationRecord, it's possible that the
// target is not the immediate parent. This appends the controller as
Expand Down Expand Up @@ -646,14 +645,15 @@ function initializeNow(document) {
break;
case "attributes":
if (
mutation.target.attributes["aria-hidden"] &&
mutation.target.attributes["aria-hidden"].value == "false"
(mutation.target.attributes["aria-hidden"] &&
mutation.target.attributes["aria-hidden"].value == "false")
|| mutation.target.nodeName === 'APPLE-TV-PLUS-PLAYER'
) {
var flattenedNodes = getShadow(document.body);
var node = flattenedNodes.filter(
var nodes = flattenedNodes.filter(
(x) => x.tagName == "VIDEO"
)[0];
if (node) {
);
for (let node of nodes) {
if (node.vsc)
node.vsc.remove();
checkForVideo(node, node.parentNode || mutation.target, true);
Expand All @@ -667,7 +667,7 @@ function initializeNow(document) {
);
});
observer.observe(document, {
attributeFilter: ["aria-hidden"],
attributes: true,
Copy link
Owner

Choose a reason for hiding this comment

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

This is a heavy performance tax, instead of opting in wholesale, we can provide a list of attributes. Is there an attribute we can target for AppleTV?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes there is, I'm a little worried about it changing cuz it's kind of random, but yeah the perf tax might be high otherwise

childList: true,
subtree: true
});
Expand Down