Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oczki/f0a2487bed747a65be34bec8ca8e546e to your computer and use it in GitHub Desktop.
Save oczki/f0a2487bed747a65be34bec8ca8e546e to your computer and use it in GitHub Desktop.
Netflix - remove hearing impaired captions from subtitles
(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