Mutes ads on Peacock
< Feedback on Mute Peacock Ads
I'm guessing they updated their player and the old code just didn't make sense anymore. I just posted your update. Thanks!
new update
let inAd = false
setInterval(function(){
var muteButton = document.querySelector('button[data-testid="playback-mute-volume"]')
var remainingTimeElement = document.querySelector('.countdown__remaining-time.ad-countdown__remaining-time');
var remainingTime = remainingTimeElement ? remainingTimeElement.textContent : null;
if(remainingTimeElement != null & !inAd){
muteButton.click()
inAd = true
}
if(remainingTimeElement == null & inAd){
muteButton.click()
inAd = false
}
}, 1000)
This update doesn't seem fully thought through. The "remainingTime" variable is unused, and the concept of the "inAd" variable seems to duplicate the original concept of the checking to see if we're in an ad based on the existence of the ".ad-countdown__remaining-time" element.
You're right that the remaining time is superfluous. I had added it and was testing with it before introducing the inAd flag.
inAd is needed because the mute button changed. Previously there was a separate mute and and an unmute button. So before the script checked if it was in an ad and hit mute, and hitting mute again and gain just remuted.
The new mute button mutes, and then unmutes if the volume is already muted. So hitting the button repeatedly turns mute on and off.
The inAd solves this by being the flag of the previous iteration of the loop. If it is in and ad this time, but wasn't last time, then it mutes and updates the flag. Opposite logic for once the ad ends.
I'm sorry, but this just isn't very well written from my perspective. I feel uncomfortable merging it, and don't really have time to talk or even think about it right now. I'm sure that's frustrating, but I figured I might as well be honest about where I am.
your shit doesn't even work. lmao. I'll share it myself so a useable piece of code is available to people.
your mute was also not working for me. Didn't follow your logic exactly, but tweaked it to something similar that works for me
setInterval(function(){
var adCountdown = document.querySelector('.ad-countdown__remaining-time')
var muteButton = document.querySelector('button.playback-button[aria-label="Mute Sound"]')
var unmuteButton = document.querySelector('button.playback-button[aria-label="Unmute Sound"]')
if(adCountdown === null & unmuteButton != null){
unmuteButton.click()
}
if(adCountdown != null & muteButton != null){
muteButton.click()
}
}, 1000)