Fix lame as video player
当前为
// ==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);
});
}