Created
July 7, 2016 02:43
-
-
Save darktrojan/3bca175514267fc3402650e7b01b2076 to your computer and use it in GitHub Desktop.
Mutes a YouTube video at a specific point
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
// 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