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
var css = document.createElement('style'); | |
css.type = 'text/css'; | |
css.innerHTML = ".myPopup{box-shadow:inset 0 1px 0 0 #fff;background:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#ededed),color-stop(1,#dfdfdf));background:-moz-linear-gradient(center top,#ededed 5%,#dfdfdf 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed',endColorstr='#dfdfdf');background-color:#ededed;border-radius:10px 10px 0 0;text-indent:0;border:1px solid #dcdcdc;display:block;color:#777;cursor:pointer;font-family:arial;font-size:14px;font-weight:700;font-style:normal;height:24px;line-height:24px;width:62px;text-decoration:none;text-align:center;text-shadow:1px 1px 0 #fff}.myPopup:hover{background:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#dfdfdf),color-stop(1,#ededed));background:-moz-linear-gradient(center top,#dfdfdf 5%,#ededed 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf',endColorstr='#ededed');background-color:#dfdfdf}.myPopup:active{position:relative;top:1px}"; | |
document.head.appendChild(css); | |
var body = document.getElementsByTagName('body')[0]; | |
var ifms = document.querySelectorAll('iframe[src^="http://www.youtube.com/embed/"],iframe[src^="http://www.youtube.com/embed/"]'); | |
for (var i = 0, max = ifms.length; i < max; i++) { | |
var pNode = ifms[i].parentNode; | |
var btn = document.createElement('a'); | |
btn.className = 'myPopup'; | |
btn.innerHTML = 'Popup'; | |
pNode.insertBefore(btn, ifms[i]); | |
var vid = ifms[i].src.replace(/http(s)?:\/\/www\.youtube\.com\/embed\//, ''); | |
(function(btn, vid) { | |
btn.addEventListener('click', function() { | |
window.open('https://youtube.googleapis.com/v/' + vid, (new Date).getTime(), "width=328,height=206,top=0,left=0"); | |
}); | |
})(btn, vid); | |
} |