Created
February 5, 2018 19:30
-
-
Save BernieCr/df8dc2c835ef1a474fdc53c8dc3e44eb to your computer and use it in GitHub Desktop.
Netflix - remove hearing impaired captions from subtitles
This file contains hidden or 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, "") | |
.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
Thanks for this!
I also added removing parenthesis, so there's no more
(train clacking in distance)
,(loud snap)
,(grunts)
,♪♪
, etc. in Harry Potter.