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 all commits
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
21 changes: 13 additions & 8 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,9 @@ 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);
// insert before parent to bypass overlay
this.parent.parentNode.insertBefore(fragment, this.parent.parentNode.firstChild);
break;
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 +647,18 @@ 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) {
// only add vsc the first time for the apple-tv case (the attribute change is triggered every time you click the vsc)
if (node.vsc && mutation.target.nodeName === 'APPLE-TV-PLUS-PLAYER')
continue;
if (node.vsc)
node.vsc.remove();
checkForVideo(node, node.parentNode || mutation.target, true);
Expand All @@ -667,7 +672,7 @@ function initializeNow(document) {
);
});
observer.observe(document, {
attributeFilter: ["aria-hidden"],
attributeFilter: ["aria-hidden", "data-focus-method"],
childList: true,
subtree: true
});
Expand Down