Skip to content

Instantly share code, notes, and snippets.

@BernieCr
Created February 5, 2018 19:30
Show Gist options
  • Save BernieCr/df8dc2c835ef1a474fdc53c8dc3e44eb to your computer and use it in GitHub Desktop.
Save BernieCr/df8dc2c835ef1a474fdc53c8dc3e44eb 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, "")
.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 });
})();
@oczki
Copy link

oczki commented Jun 7, 2020

Thanks for this!
I also added removing parenthesis, so there's no more (train clacking in distance), (loud snap), (grunts), ♪♪, etc. in Harry Potter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment