Automatically mutes the Twitch player when an advertisement started and unmute it once finished. You can also hide ads by setting disableDisplay to true.
< 脚本 Twitch - Mute ads and optionally hide them 的反馈
Did you edit manually "restorePiP"? If yes you shouldn't. All the variables you can edit are tagged accordingly. Maybe that's why you have this issue. Though all the code around Picture in Picture is kinda experimental and i coded it +/- blind. I'm using Firefox and it's still using a custom implementation there instead of using the standard PiP API, so i can't test it myself. I did some small tests in Edge but not extensively.
At first I did manually edit "restorePiP", I didn't notice the "editable" tags for the variables that could be edited. After fixing that mistake, I still ran into the same issue. I deleted the script entirely and reinstalled it (setting "disableDisplay" to true) to see if that would change the problem, but to no avail. I use Chrome so I can't speak for other browsers, so this may just be a Chrome specific problem, but I'm not sure.
I wish i could fix it easily, but i don't have a proper test environment for that, sorry. With the player not in PiP mode, when you put document.querySelectorAll(".video-player__container video")[0].requestPictureInPicture()
in your console (Ctrl+Shift+C in Chrome it seems), does it properly opens the player in PiP, just to be sure?
The closest logical issue i can see there would be there's some DOM delay, and the request to re-open the player in PiP is too early, preventing it from working properly. If you want, you could try to modify the line 268 from: document.querySelectorAll(currentSelector.playerVideo)[_tmuteVars.playerIdAds].requestPictureInPicture();
to setTimeout(function() { document.querySelectorAll(currentSelector.playerVideo)[_tmuteVars.playerIdAds].requestPictureInPicture(); }, 2000);
just to see if it solves the issue or not. If not it needs further testing, i'll see what i can do.
I saw there's some troubles with the most used scripts atm, hopefully it should be solved soon too.
I did some tests and found the culprit:
"NotAllowedError: Failed to execute 'requestPictureInPicture' on 'HTMLVideoElement': Must be handling a user gesture if there isn't already an element in Picture-in-Picture.\n at :271:322"
It just means you can't open a PiP without an user action, fair enough. I'll see what i can do to get around this. It'll probably mean resizing the PiP video to a pixel for instance, and resizing it back to its normal size once the ad(s) are done. Or maybe not... I'm seeing the values are read only. It might be not hideable at all. I'll keep checking if anything is possible there.
As the v1.1614 suggests, i removed the Picture in Picture code. I couldn't test it with Firefox so i was unaware. Didn't see the specs when i added this a while ago, that you needed an user action. It's weird because i feel like when i tested it in Edge at that moment it was working, but i might have tested the functions separately and not in real conditions by faking ads like i did here for a proper test.
So yep, sorry but it seems we can't do much in an automatic way to hide a PiP player during an ad. It'll still mute it because the sound is attached to the main player, but that's it. Everything i checked which could help there was read-only.
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址
Works extremely well, one of the best scripts to avoid ads on Twitch by far! The only downside I would like to report to have fixed is when "restorePiP" is set to true (along with "disableDisplay" being set to true), after midroll ads finish playing, the PiP closes and exits PiP mode, and you would have to manually go in PiP mode again every single time, which could be very annoying and tedious. I would love for this feature to be fixed, but other than that this is an amazing script!