summaryrefslogtreecommitdiffstats
path: root/browser/extensions/pictureinpicture/video-wrappers
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /browser/extensions/pictureinpicture/video-wrappers
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/pictureinpicture/video-wrappers')
-rw-r--r--browser/extensions/pictureinpicture/video-wrappers/canalplus.js56
-rw-r--r--browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js (renamed from browser/extensions/pictureinpicture/video-wrappers/yahoo.js)9
2 files changed, 61 insertions, 4 deletions
diff --git a/browser/extensions/pictureinpicture/video-wrappers/canalplus.js b/browser/extensions/pictureinpicture/video-wrappers/canalplus.js
new file mode 100644
index 0000000000..3d725ef54a
--- /dev/null
+++ b/browser/extensions/pictureinpicture/video-wrappers/canalplus.js
@@ -0,0 +1,56 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+class PictureInPictureVideoWrapper {
+ isLive() {
+ let documentURI = document.documentURI;
+ return documentURI.includes("/live/") || documentURI.includes("/TV/");
+ }
+
+ getDuration(video) {
+ if (this.isLive(video)) {
+ return Infinity;
+ }
+ return video.duration;
+ }
+
+ setCaptionContainerObserver(video, updateCaptionsFunction) {
+ let container =
+ document.querySelector(`[data-testid="playerRoot"]`) ||
+ document.querySelector(`[player-root="true"]`);
+
+ if (container) {
+ updateCaptionsFunction("");
+ const callback = function (mutationsList) {
+ // eslint-disable-next-line no-unused-vars
+ for (const mutation of mutationsList) {
+ let text = container.querySelector(
+ ".rxp-texttrack-region"
+ )?.innerText;
+ if (!text) {
+ updateCaptionsFunction("");
+ return;
+ }
+
+ updateCaptionsFunction(text);
+ }
+ };
+
+ // immediately invoke the callback function to add subtitles to the PiP window
+ callback([1], null);
+
+ let captionsObserver = new MutationObserver(callback);
+
+ captionsObserver.observe(container, {
+ attributes: false,
+ childList: true,
+ subtree: true,
+ });
+ }
+ }
+}
+
+this.PictureInPictureVideoWrapper = PictureInPictureVideoWrapper;
diff --git a/browser/extensions/pictureinpicture/video-wrappers/yahoo.js b/browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js
index 1dd932bc37..37591c16f8 100644
--- a/browser/extensions/pictureinpicture/video-wrappers/yahoo.js
+++ b/browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js
@@ -4,15 +4,16 @@
"use strict";
+// This wrapper supports multiple sites that use JWPlayer
class PictureInPictureVideoWrapper {
setCaptionContainerObserver(video, updateCaptionsFunction) {
- let container = document.querySelector(".vp-main");
+ let container = document.querySelector(".jw-captions");
if (container) {
updateCaptionsFunction("");
- const callback = function () {
- let text = container.querySelector(".vp-cc-element.vp-show")?.innerText;
+ const callback = function () {
+ let text = container.innerText;
if (!text) {
updateCaptionsFunction("");
return;
@@ -22,7 +23,7 @@ class PictureInPictureVideoWrapper {
};
// immediately invoke the callback function to add subtitles to the PiP window
- callback([1], null);
+ callback();
let captionsObserver = new MutationObserver(callback);