czatko webm

wyświetlanie mp4 i webm na czatku

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         czatko webm
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  wyświetlanie mp4 i webm na czatku
// @author       You
// @require http://code.jquery.com/jquery-1.12.4.min.js
// @match        https://client.poorchat.net/jadisco
// @grant        all
// ==/UserScript==

(function() {
    'use strict';


$(function() {
    var urlG = '';
    var currentMessage = '';
    var validFormats = ['mp4', 'webm'];
    var regex = /(https?:\/\/[^\s]+)/g
    if (window.top === window.self) {
        console.log('dd');
    }
    else {
        $(document).on('DOMNodeInserted', '.message', function(e) {
            var prevMessage = currentMessage;
            currentMessage = $(this).find('.text span').html();
            if(currentMessage != undefined) {
                //currentMessage = currentMessage.replace(/["']/g, "");
                if(prevMessage != currentMessage) {

                    currentMessage.replace(regex, function(url) {
                        urlG = url;
                    });
                    urlG = urlG.replace('</a>', '');
                    var ext = urlG.split('.').pop();
                    console.log(currentMessage);
                    if(jQuery.inArray(ext, validFormats) !== -1) {
                        $(this).append('<video class="post" preload="auto" autoplay="autoplay" muted="muted" loop="loop" webkit-playsinline="" style="width: 240px"><source src="'+ urlG +'" "></video>');
                    }
                    urlG = '';
                }
            }
        })
    }
});
    
})();