HTML5 video using VLC plugin

html video player using vlc

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name HTML5 video using VLC plugin
// @grant none
// @include     *
// @version 0.0.1.20210525221320
// @namespace https://greasyfork.org/users/776190
// @description html video player using vlc
// ==/UserScript==
function html5vlc(){
    var videos = document.getElementsByTagName("video"); 
    var embeds = new Array(videos.length);
    for (var i = 0; i < videos.length; i++) { 
        var vlc = document.createElement("embed"); 
        vlc.type = "application/x-vlc-plugin"; 
        if (videos[i].autoplay) {
            vlc.setAttribute("autoplay", videos[i].autoplay);
        } else {
            vlc.setAttribute("autoplay", "false");
        }
        if (videos[i].controls) {
            vlc.setAttribute("controls", "true");
        }
        if (videos[i].width) {
            vlc.width = videos[i].width; 
        }
        if (videos[i].height) {
            vlc.height = videos[i].height; 
        }
        vlc.setAttribute("target", videos[i].src); 
        var sources = videos[i].getElementsByTagName("source"); 
        for (var j = 0; j < sources.length; j++) { 
            vlc.setAttribute("target", sources[j].src); 
        } 
        let id = videos[i].getAttribute("id");
        if (id) {
            vlc.setAttribute("id", id);
        }
        let clas = videos[i].getAttribute("class");
        if (clas) {
            vlc.setAttribute("class", clas); 
        }
        embeds[i] = vlc;
    }
    for (var i = embeds.length-1; i >= 0; i--) {
        videos[i].parentNode.replaceChild(embeds[i], videos[i]);
    }
}

var retry = 0;

function wait(){
    if(retry++ > 100)   //adjust timeout and retry value for instable connection
        return;
    if(document.getElementsByTagName("video").length == 0 || document.getElementsByTagName("video")[0].src == "")
        setTimeout(wait,100);
    else    html5vlc();
}

if(window.location.href.indexOf("youtube.com") > -1)
    wait();
else html5vlc();