Changeset View
Changeset View
Standalone View
Standalone View
extension/content-script.js
Show First 20 Lines • Show All 481 Lines • ▼ Show 20 Line(s) | 465 | mutations.forEach(function (mutation) { | |||
---|---|---|---|---|---|
482 | }); | 482 | }); | ||
483 | 483 | | |||
484 | mutation.removedNodes.forEach(function (node) { | 484 | mutation.removedNodes.forEach(function (node) { | ||
485 | if (typeof node.matches !== "function" || typeof node.querySelectorAll !== "function") { | 485 | if (typeof node.matches !== "function" || typeof node.querySelectorAll !== "function") { | ||
486 | return; | 486 | return; | ||
487 | } | 487 | } | ||
488 | 488 | | |||
489 | if (node.matches("video,audio")) { | 489 | if (node.matches("video,audio")) { | ||
490 | // If the node is still in the visible DOM, don't consider the player gone | ||||
491 | if (document.body.contains(node)) { | ||||
492 | return; | ||||
493 | } | ||||
494 | | ||||
490 | if (node == activePlayer) { | 495 | if (node == activePlayer) { | ||
491 | sendPlayerGone(); | 496 | sendPlayerGone(); | ||
492 | } | 497 | } | ||
493 | return; | 498 | return; | ||
494 | } | 499 | } | ||
495 | 500 | | |||
496 | var players = node.querySelectorAll("video,audio"); | 501 | var players = node.querySelectorAll("video,audio"); | ||
497 | players.forEach(function (player) { | 502 | players.forEach(function (player) { | ||
503 | // If the player is still in the visible DOM, don't consider the player gone | ||||
504 | if (document.body.contains(player)) { | ||||
505 | return; | ||||
506 | } | ||||
507 | | ||||
498 | if (player == activePlayer) { | 508 | if (player == activePlayer) { | ||
499 | sendPlayerGone(); | 509 | sendPlayerGone(); | ||
500 | return; | 510 | return; | ||
501 | } | 511 | } | ||
502 | }); | 512 | }); | ||
503 | }); | 513 | }); | ||
504 | }); | 514 | }); | ||
505 | }); | 515 | }); | ||
▲ Show 20 Lines • Show All 194 Lines • Show Last 20 Lines |