// ==UserScript== // @name Pouet 'YT embed' | v0.02 // @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 ). Updated by Kabuto to use original screenshot as placeholder with play button in front. */ !(function() { // replace screenshot by embeded YT capture if possible var screenshot = document.querySelector('img[src^="screenshots/"][title^="screenshot added on the "]'); var yt = screenshot && document.querySelector('#mainDownload ~ a[href*="v="][href*="youtu"]'); if( yt ) { GM_addStyle(".yt-play {display:inline;cursor:pointer;} .yt-play > div {position:relative;height:0;width:89px;} .yt-play > div > div {position:absolute;left:0;top:" + (-31-screenshot.offsetHeight/2) + "px;width:89px;height:62px;border-radius:8px;color:white;font-size:40px;box-shadow:0 0 8px white;background:black;} .yt-play:hover > div > div {background:#C00;}"); screenshot.parentNode.innerHTML = '
'; var d2 = document.querySelector('.yt-play'); d2.insertBefore(screenshot,d2.firstChild); var f = function(){ 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+'?autoplay=1'; d2.parentNode.appendChild(i); d2.parentNode.removeChild(d2); }; d2.addEventListener("click",f,false); } })();