-
-
Save oczki/f0a2487bed747a65be34bec8ca8e546e to your computer and use it in GitHub Desktop.
Netflix - remove hearing impaired captions from subtitles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var targetNode = document.querySelector('.player-timedtext'); | |
function callback(mutationsList) { | |
const e = document.querySelectorAll('.player-timedtext-text-container > *'); | |
if (e) { | |
e.forEach(sub => { | |
const before = sub.innerHTML; | |
let after = before | |
.replace(/\(.*\)/g, "") | |
.replace(/\[.*]/g, "") | |
.replace(/^♪[.*]/g, "") | |
.replace(/[.*]♪$/g, "") | |
.trim() | |
.replace(/^<br>/g, "") | |
.replace(/<br>$/g, "") | |
.replace(/^-$/g, ""); | |
if (before != after) { | |
console.log(before, " => ", after); | |
sub.innerHTML = after; | |
} | |
}); | |
} | |
}; | |
var observer = new MutationObserver(callback); | |
observer.observe(document.body, { subtree: true, attributes: false, childList: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment