Created
March 9, 2011 13:15
-
-
Save ArdaXi/862160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @description Replaces embedded YouTube with an image. | |
// @include http://*/* | |
// ==/UserScript== | |
(function(){var m=".ob-youtube-overlay{width:480px;height:360px;position:absolute;text-align:center;font-size:120px;opacity:0.5;filter:alpha(opacity=50);line-height:360px;cursor:pointer;color:White;text-shadow:1px 1px 4px black;}.ob-youtube-overlay:hover{opacity:0.8;filter:alpha(opacity=80);}",k=document.getElementsByTagName("head");if(k.length>0){var l=document.createElement("style");l.type="text/css";l.appendChild(document.createTextNode(m));k[0].appendChild(l)}var o=document.getElementsByTagName("object");while(o.length>0){var h=o[0],g=h.getElementsByTagName("embed")[0];if(g.src.substr(10,12)==".youtube.com"){var f=g.src.replace(/https?:\/\/(?:www.)?youtube\.com\/[ve]\/([a-zA-Z0-9-_]*).*/g,"$1"),n="http://i2.ytimg.com/vi/"+f+"/hqdefault.jpg",e="http://youtube.com/watch?v="+f,j=document.createElement("a"),i=document.createElement("img"),d=document.createElement("div");i.src=n;i.width=480;i.height=360;i.style.float="left";j.href=e;j.target="_blank";j.appendChild(i);d.innerHTML="►";d.className="ob-youtube-overlay";j.appendChild(d);h.parentNode.replaceChild(j,h)}}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment