gif + video link gamevn

This script display gif at url in gamevn and some xenforo 4r else.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name 		gif + video link gamevn
// @namespace 	https://greasyfork.org/en/scripts/9626
// @description This script display gif at url in gamevn and some xenforo 4r else.
// @run-at      document-end
// @version	    1.5.5
// @require 	https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @require 	https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @include 	https://*.gamevn.com/*
// @include 	http://*.gamevn.com/*
// ==/UserScript==
$(document).ready(function(){
    $("[id^='post-'] a").each(function() {
        var img, href;
        href = $(this).attr("href");
        var xxx = 1;    
        if (/\.(jpg|jpeg|png|gif|bmp)$/.test(href) && !(/<img/.test($(this).html())))
        {
            $(this).mouseover(function() {            
                img = $("<div><img src='" + href + "' title='Vui lòng nhấn vào đây để tới link ảnh gốc'/></div>");
                if(xxx)
                    $(this).after(img);
                xxx = 0;
            });
        }
        if (/\.(mp4|webm|ogg)$/.test(href)) {
            $(this).mouseover(function() { 
                var video = $('<div class="video_container"><video controls autoplay="autoplay" preload="metadata">Your browser does not support the <code>video</code> element.</video></div>');
                if(xxx){
                    video.children().attr("src", href);
                    $(this).after(video);            
                    xxx = 0;
                }
            });
        }
        if (/imgur.com/.test(href) && !(/<img/.test($(this).html()))) {
            $(this).mouseover(function(){
                if(xxx){
                    img = href.split('/'); 
                    href = img[img.length-1].split('.gifv')[0];
                    img = $('<div><video poster="http://i.imgur.com/'+href +'.jpg" preload="auto" autoplay="autoplay" muted="muted" loop="loop" webkit-playsinline=""><source src="http://i.imgur.com/'+href+'.webm" type="video/webm"></video></div>');
                    $(this).after(img);
                    xxx=0
                }
            });
        }
        if (/9gag.com/.test(href) && !(/<img/.test($(this).html()))) {
            $(this).mouseover(function(){
                if(xxx){
                    img = href.split('/'); 
                    href = img[img.length-1].split('?')[0];
                    img = $('<div><video poster="http://img-9gag-fun.9cache.com/photo/'+href +'_460s.jpg" preload="auto" autoplay="autoplay" muted="muted" loop="loop" webkit-playsinline=""><source src="http://img-9gag-fun.9cache.com/photo/'+href+'_460svwm.webm" type="video/webm"></video></div>');
                    $(this).after(img);
                    xxx=0
                }
            });
        }
    });
});