Safari HTML5 Autoplay

Discussion in 'OS X El Capitan (10.11)' started by 1madman1, Aug 7, 2016.

  1. 1madman1 macrumors regular

    Joined:
    Oct 23, 2013
    Location:
    Richmond, BC, Canada
    #1
    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.
     
  2. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #2
    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; });
     
  3. avatar-adg macrumors 6502

    avatar-adg

    Joined:
    May 15, 2015
    Location:
    Moscow
    #3
    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()})();
     
  4. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #4
  5. Weaselboy, Aug 11, 2016
    Last edited: Aug 11, 2016

    Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #5
  6. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #6
    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.
     

Share This Page