gif + video link gamevn

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

当前为 2015-10-07 提交的版本,查看 最新版本

// ==UserScript==
// @name 		gif + video link gamevn
// @namespace 	https://greasyfork.org/en/scripts/9626-gif-appear-gamevn
// @description This script display gif at url in gamevn and some xenforo 4r else.
// @run-at      document-end
// @version	    1.5.1
// @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==

$("[id^='post-'] a").each(function() {
    var img, href;
    href = $(this).attr("href");
    var x = 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(x)
                $(this).after(img);
            x = 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(x){
                video.children().attr("src", href);
                $(this).after(video);            
                x = 0;
            }
        });
    }http://img-9gag-fun.9cache.com/photo/aMQOxYM_460sv.mp4
    if (/imgur.com/.test(href) && !(/<img/.test($(this).html()))) {
        $(this).mouseover(function(){
           if(x){
               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);
               x=0
           }
        });
    }
    if (/9gag.com/.test(href) && !(/<img/.test($(this).html()))) {
        $(this).mouseover(function(){
           if(x){
               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);
               x=0
           }
        });
    }
});