Safari Embedded WebM Support

Uses the VLC webplugin to play embeded webM videos.

09.09.2018 itibariyledir. En son verisyonu görün.

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         Safari Embedded WebM Support
// @namespace    safari-embedded-webm-support
// @version      1.1
// @description  Uses the VLC webplugin to play embeded webM videos.
// @author       Calumks
// @match        *://boards.4chan.org/*
// @match        *://8ch.net/*
// @match        *://gelbooru.com/index.php?page=post&*
// @match        *://danbooru.donmai.us/posts/*
// @grant        none
// @require      http://code.jquery.com/jquery-3.2.1.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// ==/UserScript==

(function() {

    function embedVLC(video, src) {
        // 4chan
        if (document.URL.indexOf("//boards.4chan") > -1) {
            insert4chan(video, src);
        // Other
        } else {
             // Create video
             var vlc = createVLC(video, src);
             video.before(vlc);

             // Hide video
             video.attr('style', 'width: 0; opacity: 0; height: 0;');
        }
    }

    // Create vlc video to insert
    function createVLC(video, src) {
        // Get source
        var vlc = $('<embed loop="' + video.prop("loop") + '">');
        vlc.attr({
            type: "application/x-vlc-plugin",
            pluginspage: "http://www.videolan.org",
            width: "855",
            height: "481",
            target: src,
        });
        return vlc;
    }

    // 4chan insert
    function insert4chan(video, src) {

        // Add vlc
        var vlc = createVLC(video, src);
        video.parent().before(vlc);
        vlc.attr("style", "margin: 5px 20px");

        // Hide thumb
        var thumb = video.parent().find('img');
        thumb.hide();

        // click to stop loading again
        thumb.click();

        // Create close button
        var closeSpan = $("<span class='collapseWebm'>-[<a>close</a>]</span>");
        var closeLink = $("a", closeSpan) ;
        vlc.prev().append(closeSpan);
        closeLink.click(function() {
            closeSpan.remove();
            vlc.remove();
            thumb.show();
        });
    }

    // Convert html5
    $(document).arrive('video[src$=".webm"]', function() {
        embedVLC($(this), $(this).attr("src"));
    });
    $('video[src$=".webm"]').each(function() {
        embedVLC($(this), $(this).attr("src"));
    });
     $(document).arrive('video source[src$=".webm"]', function() {
        embedVLC($(this).closest('video'), $(this).attr("src"));
    });
    $('video source[src$=".webm"]', $(this).src).each(function() {
        embedVLC($(this).closest('video'), $(this).attr("src"));
    });

})(this);