Skip to content

Instantly share code, notes, and snippets.

@AurielleP
Created October 10, 2024 15:45
Show Gist options
  • Save AurielleP/3880840bdc3b79dbf2ac76fb9237d8e6 to your computer and use it in GitHub Desktop.
Save AurielleP/3880840bdc3b79dbf2ac76fb9237d8e6 to your computer and use it in GitHub Desktop.
javascript:'use strict'%3Bconst adMuteIntervalTime%3D100%2CadOverlayClassList%3D"ytp-ad-module"%2CmuteClassList%3D"ytp-mute-button ytp-button"%2CvolumeClassList%3D"ytp-volume-panel"%2CvolumeMutedAttribute%3D"aria-valuetext"%2CvolumeMutedAttributeValue%3D"muted"%3Bvar adMuteIntervalId%2CadObserved%3D!1%2CadMuted%3D!1%3Bfunction startAdMuteInterval()%7BadMuteIntervalId%3DsetInterval(()%3D>%7BisAdVisible()%3FadObserved%7C%7C(adObserved%3D!0%2CisVideoMuted()%7C%7C(adMuted%3D!0%2CtoggleVideoMute()))%3AadObserved%26%26(adObserved%3D!1%2CadMuted%26%26(adMuted%3D!1%2CisVideoMuted()%26%26toggleVideoMute()))%7D%2CadMuteIntervalTime)%7Dfunction isAdVisible()%7Btry%7Breturn null%3D%3D%3Ddocument.getElementsByClassName(adOverlayClassList)%5B0%5D.offsetParent%3F!1%3A!0%7Dcatch(a)%7Breturn!1%7D%7Dfunction isVideoMuted()%7Breturn document.getElementsByClassName(volumeClassList)%5B0%5D.getAttribute(volumeMutedAttribute).includes(volumeMutedAttributeValue)%7Dfunction toggleVideoMute()%7Bconst a%3Ddocument.getElementsByClassName(muteClassList)%5B0%5D%3Bif("function"%3D%3D%3Dtypeof a.fireEvent)a.fireEvent("onclick")%3Belse if("function"%3D%3D%3Dtypeof a.dispatchEvent)%7Bconst b%3Ddocument.createEvent("Events")%3Bb.initEvent("click"%2C!0%2C!1)%3Ba.dispatchEvent(b)%7D%7Dconsole.log("Starting ad mute script")%3BstartAdMuteInterval()%3Bvoid+0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment