From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../data/picture_in_picture_overrides.js | 154 +++++++++++++++++++-- browser/extensions/pictureinpicture/moz.build | 3 +- .../pictureinpicture/video-wrappers/canalplus.js | 56 ++++++++ .../video-wrappers/jwplayerWrapper.js | 39 ++++++ .../pictureinpicture/video-wrappers/yahoo.js | 38 ----- 5 files changed, 236 insertions(+), 54 deletions(-) create mode 100644 browser/extensions/pictureinpicture/video-wrappers/canalplus.js create mode 100644 browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js delete mode 100644 browser/extensions/pictureinpicture/video-wrappers/yahoo.js (limited to 'browser/extensions/pictureinpicture') diff --git a/browser/extensions/pictureinpicture/data/picture_in_picture_overrides.js b/browser/extensions/pictureinpicture/data/picture_in_picture_overrides.js index ecc4945135..e8b690a386 100644 --- a/browser/extensions/pictureinpicture/data/picture_in_picture_overrides.js +++ b/browser/extensions/pictureinpicture/data/picture_in_picture_overrides.js @@ -57,7 +57,7 @@ let AVAILABLE_PIP_OVERRIDES; aol: { "https://*.aol.com/*": { - videoWrapperScriptPath: "video-wrappers/yahoo.js", + videoWrapperScriptPath: "video-wrappers/videojsWrapper.js", }, }, @@ -81,12 +81,41 @@ let AVAILABLE_PIP_OVERRIDES; videoWrapperScriptPath: "video-wrappers/videojsWrapper.js", }, }, + + canalplus: { + "https://*.canalplus.com/live/*": { + videoWrapperScriptPath: "video-wrappers/canalplus.js", + disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK, + }, + "https://*.canalplus.com/*": { + videoWrapperScriptPath: "video-wrappers/canalplus.js", + }, + }, + cbc: { "https://*.cbc.ca/*": { videoWrapperScriptPath: "video-wrappers/cbc.js", }, }, + cnbc: { + "https://*.cnbc.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + + cpac: { + "https://*.cpac.ca/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + + cspan: { + "https://*.c-span.org/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + dailymotion: { "https://*.dailymotion.com/*": { videoWrapperScriptPath: "video-wrappers/dailymotion.js", @@ -105,6 +134,18 @@ let AVAILABLE_PIP_OVERRIDES; }, }, + fandom: { + "https://*.fandom.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + + fastcompany: { + "https://*.fastcompany.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + frontendMasters: { "https://*.frontendmasters.com/*": { videoWrapperScriptPath: "video-wrappers/videojsWrapper.js", @@ -117,6 +158,12 @@ let AVAILABLE_PIP_OVERRIDES; }, }, + fuse: { + "https://*.fuse.tv/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + hbomax: { "https://play.hbomax.com/page/*": { policy: TOGGLE_POLICIES.HIDDEN }, "https://play.hbomax.com/player/*": { @@ -136,10 +183,34 @@ let AVAILABLE_PIP_OVERRIDES; }, }, + imdb: { + "https://*.imdb.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + + indpendentuk: { + "https://*.independent.co.uk/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + + indy100: { + "https://*.indy100.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + instagram: { "https://www.instagram.com/*": { policy: TOGGLE_POLICIES.ONE_QUARTER }, }, + internetArchive: { + "https://*.archive.org/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + laracasts: { "https://*.laracasts.com/*": { policy: TOGGLE_POLICIES.ONE_QUARTER }, }, @@ -149,12 +220,31 @@ let AVAILABLE_PIP_OVERRIDES; visibilityThreshold: 0.7, }, }, + + msnbc: { + "https://*.msnbc.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + mxplayer: { "https://*.mxplayer.in/*": { videoWrapperScriptPath: "video-wrappers/videojsWrapper.js", }, }, + nbcnews: { + "https://*.nbcnews.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + + nbcUniversal: { + "https://*.nbcuni.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + nebula: { "https://*.nebula.app/*": { videoWrapperScriptPath: "video-wrappers/videojsWrapper.js", @@ -197,6 +287,17 @@ let AVAILABLE_PIP_OVERRIDES; }, }, + primeVideo: { + "https://*.primevideo.com/*": { + visibilityThreshold: 0.9, + videoWrapperScriptPath: "video-wrappers/primeVideo.js", + }, + "https://*.amazon.com/*": { + visibilityThreshold: 0.9, + videoWrapperScriptPath: "video-wrappers/primeVideo.js", + }, + }, + radiocanada: { "https://*.ici.radio-canada.ca/*": { videoWrapperScriptPath: "video-wrappers/radiocanada.js", @@ -207,18 +308,46 @@ let AVAILABLE_PIP_OVERRIDES; "https://*.reddit.com/*": { policy: TOGGLE_POLICIES.ONE_QUARTER }, }, + reuters: { + "https://*.reuters.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + sonyliv: { "https://*.sonyliv.com/*": { videoWrapperScriptPath: "video-wrappers/sonyliv.js", }, }, + syfy: { + "https://*.syfy.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + ted: { "https://*.ted.com/*": { showHiddenTextTracks: true, }, }, + time: { + "https://*.time.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + + timvision: { + "https://*.timvision.it/TV/*": { + videoWrapperScriptPath: "video-wrappers/canalplus.js", + disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK, + }, + "https://*.timvision.it/*": { + videoWrapperScriptPath: "video-wrappers/canalplus.js", + }, + }, + tubi: { "https://*.tubitv.com/live*": { videoWrapperScriptPath: "video-wrappers/tubilive.js", @@ -256,6 +385,12 @@ let AVAILABLE_PIP_OVERRIDES; }, }, + univision: { + "https://*.univision.com/*": { + videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js", + }, + }, + viki: { "https://*.viki.com/*": { videoWrapperScriptPath: "video-wrappers/videojsWrapper.js", @@ -274,9 +409,9 @@ let AVAILABLE_PIP_OVERRIDES; }, }, - yahoofinance: { - "https://*.finance.yahoo.com/*": { - videoWrapperScriptPath: "video-wrappers/yahoo.js", + yahoo: { + "https://*.s.yimg.com/*": { + videoWrapperScriptPath: "video-wrappers/videojsWrapper.js", }, }, @@ -301,16 +436,5 @@ let AVAILABLE_PIP_OVERRIDES; videoWrapperScriptPath: "video-wrappers/washingtonpost.js", }, }, - - primeVideo: { - "https://*.primevideo.com/*": { - visibilityThreshold: 0.9, - videoWrapperScriptPath: "video-wrappers/primeVideo.js", - }, - "https://*.amazon.com/*": { - visibilityThreshold: 0.9, - videoWrapperScriptPath: "video-wrappers/primeVideo.js", - }, - }, }; } diff --git a/browser/extensions/pictureinpicture/moz.build b/browser/extensions/pictureinpicture/moz.build index 7cc77f9594..fbdefbeb1c 100644 --- a/browser/extensions/pictureinpicture/moz.build +++ b/browser/extensions/pictureinpicture/moz.build @@ -31,6 +31,7 @@ FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["video-wrappers"] += "video-wrappers/airmozilla.js", "video-wrappers/arte.js", "video-wrappers/bbc.js", + "video-wrappers/canalplus.js", "video-wrappers/cbc.js", "video-wrappers/dailymotion.js", "video-wrappers/disneyplus.js", @@ -38,6 +39,7 @@ FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["video-wrappers"] += "video-wrappers/hbomax.js", "video-wrappers/hotstar.js", "video-wrappers/hulu.js", + "video-wrappers/jwplayerWrapper.js", "video-wrappers/mock-wrapper.js", "video-wrappers/netflix.js", "video-wrappers/nytimes.js", @@ -52,7 +54,6 @@ FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["video-wrappers"] += "video-wrappers/videojsWrapper.js", "video-wrappers/voot.js", "video-wrappers/washingtonpost.js", - "video-wrappers/yahoo.js", "video-wrappers/youtube.js", ] 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/jwplayerWrapper.js b/browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js new file mode 100644 index 0000000000..37591c16f8 --- /dev/null +++ b/browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js @@ -0,0 +1,39 @@ +/* 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"; + +// This wrapper supports multiple sites that use JWPlayer +class PictureInPictureVideoWrapper { + setCaptionContainerObserver(video, updateCaptionsFunction) { + let container = document.querySelector(".jw-captions"); + + if (container) { + updateCaptionsFunction(""); + + const callback = function () { + let text = container.innerText; + if (!text) { + updateCaptionsFunction(""); + return; + } + + updateCaptionsFunction(text); + }; + + // immediately invoke the callback function to add subtitles to the PiP window + callback(); + + 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/yahoo.js deleted file mode 100644 index 1dd932bc37..0000000000 --- a/browser/extensions/pictureinpicture/video-wrappers/yahoo.js +++ /dev/null @@ -1,38 +0,0 @@ -/* 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 { - setCaptionContainerObserver(video, updateCaptionsFunction) { - let container = document.querySelector(".vp-main"); - - if (container) { - updateCaptionsFunction(""); - const callback = function () { - let text = container.querySelector(".vp-cc-element.vp-show")?.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; -- cgit v1.2.3