Fix VKmag video

Fix lame as video player

当前为 2015-03-20 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Fix VKmag video 
// @namespace    Bierdopje.eu
// @description  Fix lame as video player
// @include      http://*.vkmag.com*
// @include      http://*.vkmag.com*
// @grant        unsafeWindow
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// @author       DLL
// @version      0.1
// ==/UserScript==]]]
if ($("#my-video1").length != 0)
{
    
	file = jwplayer('my-video1')['config']['file'];

    file = youtube_parser(file);
    $('<div class="video"></div>').insertAfter(".postInfo");
    $('.video').html('<iframe width="100%" src="http://www.youtube.com/embed/' + file + '?rel=0&autoplay=1" frameborder="0" allowfullscreen </iframe>')
    setAspectRatio();
    jQuery(window).resize(setAspectRatio);
    $(function() {
         $("#my-video1").remove();
        });
}else{

$(function() {
        var file = jwplayer('my-video')['config']['file'];
        $('<div class="video"></div>').insertAfter(".postInfo");
        $('.video').html('<video width="100%" autoplay="autoplay" controls="controls" loop><source src="' + file + '" type="video/mp4"></video>')
        $("#my-video").remove();
});
}
function youtube_parser(url) {
    var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
    var match = url.match(regExp);
    if (match && match[7].length == 11) {
        return match[7];
    } else {
        alert("Url incorrecta");
    }
}

function setAspectRatio() {
    jQuery('iframe').each(function() {
        jQuery(this).css('height', jQuery(this).width() * 9 / 16);
    });
}