HTML5 video auto-pause

Auto-pause any HTML5 videos. Will still preload.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name           HTML5 video auto-pause
// @author         Vincent Beers
// @namespace      http://vincent.tengudev.com/
// @description    Auto-pause any HTML5 videos. Will still preload.
// @include        *
// @version        2014-04-14
// ==/UserScript==

document.addEventListener('DOMContentLoaded',function() {
    var elems = document.querySelectorAll("video");
    
    console.log("HTML video auto pause: pausing all HTML5 videos on page load");
    for (var i = 0; i < elems.length; i++) {
        elems[i].pause();
        _tmpDaVince = elems[i]; //Probably an ugly hack, but it works at least
        _tmpDaVince.addEventListener("canplay", function(e) {
            console.log("HTML video auto pause: this video can play, so pausing");
        	_tmpDaVince.pause();
        });
    }
});



//Pause newly created video elements
document.addEventListener("DOMNodeInserted", function(e) {
    var elem = e.target;
    if (elem.nodeName == "VIDEO") {
        elem.addEventListener("canplay", function(e) {
            console.log("HTML video auto pause: Video element was inserted after page load, pausing");
        	elem.pause();
        });
    }
}, false);