-
Notifications
You must be signed in to change notification settings - Fork 3
/
ytEmbed.user.js
26 lines (24 loc) · 900 Bytes
/
ytEmbed.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// ==UserScript==
// @name Pouet 'YT embed' | v0.01
// @description replace the screenshot of the prods on Pouet.net by the embedded YT capture if possible
// @include http://pouet.net/prod.php*
// @include http://*.pouet.net/prod.php*
// ==/UserScript==
/* (c) August 2012 by Mathieu 'P01' HENRI ( http://www.p01.org ) */
!(function()
{ // replace screenshot by embeded YT capture if possible
var screenshot = document.querySelector('#screenshot img');
var yt = screenshot && document.querySelector('#links a[href*="youtu"]');
if( yt )
{
var i=document.createElement('iframe');
var code = (yt.href.match(/(v=|youtu\.be\/)([^&\?]+)/)||['']).pop();
i.width=400;
i.height=300;
i.frameBorder=0;
i.allowfullscreen=1;
i.src = 'http://www.youtube.com/embed/'+code;
screenshot.parentNode.appendChild(i);
screenshot.parentNode.removeChild(screenshot);
}
})();