Skip to content

Instantly share code, notes, and snippets.

@neight-allen
Created March 1, 2015 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neight-allen/53113cd514f2e95bd72b to your computer and use it in GitHub Desktop.
Save neight-allen/53113cd514f2e95bd72b to your computer and use it in GitHub Desktop.
javascript: (function () {var jsCode = document.createElement('script'); jsCode.setAttribute('src', 'https://localhost/~nateallen/ytwall/ytwall.js'); document.body.appendChild(jsCode); }());
function addStyleString(str) {
var node = document.createElement('style');
node.innerHTML = str;
document.head.appendChild(node);
}
if (!($ = window.jQuery)) { // typeof jQuery=='undefined' works too
script = document.createElement( 'script' );
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
script.onload=releasetheKraken;
document.body.appendChild(script);
}
else {
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
console.log("im in");
releasetheKraken();
}
function releasetheKraken() {
addStyleString("#thewall {position:absolute; width:1280px; top:0; left:100px; z-index:9999 } iframe{float:left; width: 320px; height: 195px; } ");
var keys = []
$("#search-results li[data-context-item-id]").each(function(i){
var key = $(this).attr("data-context-item-id");
keys.push(key);
});
function onYouTubeIframeAPIReady() {
$("body").html("<div id=\"thewall\"></div>");
$(keys).each(function(i, id){
var fullid = id + '-player';
$("#thewall").append("<div id='" + fullid + "'></div>");
player = new YT.Player(fullid, {
height: '390',
width: '640',
videoId: id,
playerVars: {'controls': 0},
events: {
'onReady': onPlayerReady,
//'onStateChange': onPlayerStateChange
}
});
})
}
function onPlayerReady(event) {
event.target.playVideo();
event.target.setVolume(0);
$(event.target.getIframe()).hover(
function(e){
event.target.setVolume(100);
},function(e){
event.target.setVolume(0);
})
}
}
function YTIframe(id)
{
return "<iframe class=\"ytpreview\" type=\"text/html\" src=\"https://www.youtube.com/embed/" + id + "?autoplay=1&html5=1&controls=0&enablejsapi=1\" frameborder=\"0\"/>"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment