tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bbc.js (996B)


      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  setCaptionContainerObserver(video, updateCaptionsFunction) {
      9    let container = document.querySelector(".p_subtitlesContainer");
     10 
     11    if (container) {
     12      updateCaptionsFunction("");
     13      const callback = function () {
     14        let text = container.querySelector(".p_cueDirUniWrapper")?.innerText;
     15        updateCaptionsFunction(text);
     16      };
     17 
     18      callback([1], null);
     19 
     20      this.captionsObserver = new MutationObserver(callback);
     21 
     22      this.captionsObserver.observe(container, {
     23        attributes: false,
     24        childList: true,
     25        subtree: true,
     26      });
     27    }
     28  }
     29 
     30  removeCaptionContainerObserver() {
     31    this.captionsObserver?.disconnect();
     32  }
     33 }
     34 
     35 this.PictureInPictureVideoWrapper = PictureInPictureVideoWrapper;