hbomax.js (1322B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 class PictureInPictureVideoWrapper { 8 setVolume(video, volume) { 9 video.volume = volume; 10 } 11 12 isMuted(video) { 13 return video.volume === 0; 14 } 15 16 setMuted(video, shouldMute) { 17 if (shouldMute) { 18 this.setVolume(video, 0); 19 } else { 20 this.setVolume(video, 1); 21 } 22 } 23 24 setCaptionContainerObserver(video, updateCaptionsFunction) { 25 let container = document.querySelector( 26 '[data-testid="CueBoxContainer"]' 27 ).parentElement; 28 29 if (container) { 30 updateCaptionsFunction(""); 31 const callback = function () { 32 let text = container.querySelector( 33 '[data-testid="CueBoxContainer"]' 34 )?.innerText; 35 updateCaptionsFunction(text); 36 }; 37 38 callback([1], null); 39 40 this.captionsObserver = new MutationObserver(callback); 41 42 this.captionsObserver.observe(container, { 43 attributes: false, 44 childList: true, 45 subtree: true, 46 }); 47 } 48 } 49 50 removeCaptionContainerObserver() { 51 this.captionsObserver?.disconnect(); 52 } 53 } 54 55 this.PictureInPictureVideoWrapper = PictureInPictureVideoWrapper;