Skip to content

Instantly share code, notes, and snippets.

@darktrojan
Created July 7, 2016 02:43
Show Gist options
  • Save darktrojan/3bca175514267fc3402650e7b01b2076 to your computer and use it in GitHub Desktop.
Save darktrojan/3bca175514267fc3402650e7b01b2076 to your computer and use it in GitHub Desktop.
Mutes a YouTube video at a specific point
// for use on https://www.youtube.com/watch?v=e1X4RPDE-48
var video = document.querySelector('video');
var count = 0;
var interval = null;
video.ontimeupdate = function(event) {
if (interval === null && !this.paused && this.currentTime > 175 && this.currentTime < 180) {
console.log('start');
count = 0;
interval = setInterval(doIt, 40);
}
}
function doIt() {
if (video.paused || video.currentTime > 180) {
console.log('end', count);
clearInterval(interval);
interval = null;
}
if (video.muted = video.currentTime >= 176.5 && video.currentTime < 177.1) {
count++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment