Bug 1768818 - More robust way to find subtitles on Netflix. r=pip-reviewers,mhowell

Differential Revision: https://phabricator.services.mozilla.com/D146093
This commit is contained in:
Niklas Baumgardner 2022-05-11 16:53:43 +00:00
parent 99809832ac
commit 0013e6295f

View File

@ -36,17 +36,8 @@ class PictureInPictureVideoWrapper {
if (container) {
updateCaptionsFunction("");
const callback = function(mutationsList, observer) {
let textNodeList = container
.querySelector(".player-timedtext")
?.querySelectorAll("span > span");
if (!textNodeList || textNodeList.length < 1) {
updateCaptionsFunction("");
return;
}
updateCaptionsFunction(
Array.from(textNodeList, x => x.textContent).join("\n")
);
let text = container.querySelector(".player-timedtext").innerText;
updateCaptionsFunction(text);
};
// immediately invoke the callback function to add subtitles to the PiP window