This is a JS function to automatically mute Hulu when an ad comes on, then unmute it when the show comes back. It works a of 7/26/2019.
To create a bookmarklet, create a new bookmark starting with javascript:, then the contents of minified.js.
| window.huluAdTimer = window.huluAdTimer || setInterval(function() { let volBtn = document.getElementsByClassName('controls__volume-button')[0], isMuted = volBtn.classList.contains('controls__volume-button--mute'), isAdbreak = document.getElementsByClassName('ad-container')[0].style.display=="block"; if((isAdbreak && !isMuted) || (!isAdbreak && isMuted)) volBtn.click(); }, 1000) |
| // Here is an un-minified version | |
| function muteAd() { | |
| let volBtn = document.getElementsByClassName('controls__volume-button')[0]; | |
| let isMuted = volBtn.classList.contains('controls__volume-button--mute'); | |
| let isAdbreak = document.getElementsByClassName('ad-container')[0].style.display=="block"; | |
| let needsMute = isAdbreak && !isMuted; | |
| let needsUnmute = !isAdbreak && isMuted; | |
| if(needsMute || needsUnmute) | |
| volBtn.click(); | |
| console.log("is " + (isAdbreak ? "" : "not ") + "ad"); | |
| console.log("is " + (isMuted ? "" : "not ") + "muted"); | |
| if(needsMute) | |
| console.log("muting"); | |
| else if(needsUnmute) | |
| console.log("unmuting"); | |
| else | |
| console.log("doing nothing"); | |
| } | |
| let timerId = setInterval(muteAd, 1000) |