Prevent webbrowser from automatically playing/downloading HTML5 videos
// ==UserScript==
// @name Disable HTML5 Videos autoplay/preload
// @description Prevent webbrowser from automatically playing/downloading HTML5 videos
// @namespace default
// @include *
// @exclude http*://www.youtube.com/*
// @version 1
// @grant none
// @author Ramast Magdy (ramast dot com at gmail dot com)
// ==/UserScript==
void(function() {
var prevent_autoplay = function() {
var videos = document.getElementsByTagName("video");
var video;
for (var i=0; i < videos.length; i++) {
video = videos[i];
video.removeAttribute("autoplay");
video.removeAttribute("autobuffer");
video.setAttribute("preload", "metadata");
}
};
// after 0.3, 1, 2 and 4 seconds
// This is because sometimes video is loaded through some JS code
setTimeout(prevent_autoplay, 300);
setTimeout(prevent_autoplay, 1000);
setTimeout(prevent_autoplay, 2000);
setTimeout(prevent_autoplay, 4000);
}());