NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Video WebM VK Links
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Воспроизводит видео при нажатии на webm ссылку
// @author Flyink13
// @match https://vk.com/*
// @grant none
// ==/UserScript==
function WebVK() {
function ce(tagName, attr, style) {
var el = document.createElement(tagName);
if (attr) Object.assign(el, attr);
if (style) Object.assign(el.style, style);
return el;
}
function showBtVideoPlayer(href){
document.body.appendChild(ce("div",{
className: "WebVK_video",
onclick: function(){
if(this !== event.target) return 1;
this.outerHTML = "";
}
})).appendChild(ce("video",{
src: href,
controls: 1,
autoplay: 1,
onclick: function(){
if(this.paused){
this.play();
}else{
this.pause();
}
}
}));
return false;
}
document.head.appendChild(ce("style",{
innerHTML:
".WebVK_video{position: fixed; top: 0; left: 0; background: rgba(0,0,0,.8);width: 100%; height: 100%; z-index: 1000;}" +
".WebVK_video video{position: absolute; max-height: 100%;max-width: 100%;top: 0;left: 0;bottom: 0;right: 0;margin: auto;}"
}));
document.body.addEventListener("click", function(e){
if(e.target.tagName !== "A" || !/to=(.+)\.webm&/i.test(e.target.href)) return;
e.preventDefault();
e.stopPropagation();
return showBtVideoPlayer(decodeURIComponent(e.target.href.match(/to=(.+)&/)[1]));
});
}
var script = document.createElement('script');
script.appendChild(document.createTextNode('(' + WebVK + ')();'));
(document.body || document.head || document.documentElement).appendChild(script);