Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

1madman1

macrumors 6502
Original poster
Oct 23, 2013
481
346
Richmond, BC, Canada
Is there ANY way to disable HTML5 autoplay in Safari? Im okay with 100% disabling all web video if that what it takes. These bandwidth stealing videos embedded everywhere are pissing me off. Not everyone has unlimited bandwidth.

I know I can do it in Opera and Firefox, but I'd prefer to use Safari if possible.
 

Weaselboy

Moderator
Staff member
Jan 23, 2005
34,481
16,195
California
The only way I have found to stop those is to use an adblocker (I use the Adguard extension) to block the video element on the page. For example, this line in the adblocker stops the autoplay videos on MacWorld's page.

Code:
macworld.com#%#AG_onLoad(function() { IDG.video.playerCount = 2; });
 

avatar-adg

macrumors 6502
May 15, 2015
282
241
Moscow
The other way is to use userscript, here is one made by me:
https://github.com/AdguardTeam/Userscripts/raw/master/disableAutoplay/disable-autoplay.user.js

There are two ways of using it.
1. Install Tampermonkey for Safari (you can get it on tampermonkey.com) and install that userscript.
2. Or it can be converted it into an Adguard JS rule which you can add to the user filter.

Converted version:
Code:
#%#(function(){var removeAutoplay=function(){var arVideos=document.getElementsByTagName("video");for(var i=arVideos.length-1;i>=0;i--){var elmVideo=arVideos[i];if(elmVideo.autoplay){console.log("[Disable Video AutoPlay by Adguard] Removing autoplay attribute");elmVideo.autoplay=false}}};var handleDomChange=function(mutations){if(mutations.length===0)removeAutoplay()};var init=function(){removeAutoplay();var observer=new MutationObserver(handleDomChange);observer.observe(document.body,{childList:true, subtree:true})};init()})();
 
  • Like
Reactions: KALLT

KALLT

macrumors 603
Sep 23, 2008
5,380
3,415
This line in AdGuard stopped those for me.

Code:
macworld.com#%#AG_onLoad(function() { IDG.video.playerCount = 2; });

Edit: I see I posted the same thing a couple posts up. I am not a smart man. :oops:

No worries. I actually want to have a general rule, so if Adguard can support this, then that would be fantastic. Very annoying that we have to deal with this again, after Apple blocked autoloading of Flash plugins for years.
 
  • Like
Reactions: Weaselboy
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.