4chan webm extension

Adds ability to pause, fullscreen, and close a webm by clicking on it

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey 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 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.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

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         4chan webm extension
// @namespace    http://tampermonkey.net/
// @version      0.11
// @description  Adds ability to pause, fullscreen, and close a webm by clicking on it
// @author       lolmao
// @match        https://boards.4chan.org/*/thread/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var observer = new MutationObserver(function (mutations, me) {
        for (var i = 0; i < mutations.length; i++) {
            for (var j = 0; j < mutations[i].addedNodes.length; j++) {
                var curr = mutations[i].addedNodes[j];
                if (curr.tagName === "VIDEO") {
                    addListeners(curr);
                }
            }
        }
    });
    observer.observe(document, {
        childList: true,
        subtree: true
    });
})();


function addListeners(videoObj){
    videoObj.addEventListener('click', function(ev) {
        //ev.preventDefault();
        if (videoObj.paused) {
            videoObj.play();
        } else {
            videoObj.pause();
        }
        return true;
    }, false);

    videoObj.addEventListener('dblclick', function(){
        if (!videoObj.webkitDisplayingFullscreen){
            videoObj.webkitRequestFullscreen();
        } else {
            videoObj.webkitExitFullscreen();
        }
    }, false);

    videoObj.addEventListener('contextmenu', function(ev) {
        ev.preventDefault();
        videoObj.parentElement.firstElementChild.children[1].firstElementChild.click();
    });
    return true;
}