Skip to content

Instantly share code, notes, and snippets.

@cycjusz157
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cycjusz157/704ea39e106d6a89636f to your computer and use it in GitHub Desktop.
Save cycjusz157/704ea39e106d6a89636f to your computer and use it in GitHub Desktop.
#cycoplayer
var list = '';
var x = document.getElementsByTagName('a');
for (var i = 0; i < x.length; i++) {
if (x[i].getAttribute('target') != null && x[i].getAttribute('href').indexOf('youtube') != -1) {
list = list + ',' + (x[i].getAttribute('href').substring(x[i].getAttribute('href').indexOf('v=') + 2, x[i].getAttribute('href').indexOf('v=') + 13));
} else if (x[i].getAttribute('target') != null && x[i].getAttribute('href').indexOf('youtu.be') != -1) {
list = list + ',' + (x[i].getAttribute('href').substring(x[i].getAttribute('href').indexOf('.be') + 4, x[i].getAttribute('href').indexOf('.be') + 15));
}
}
if (list != null && list != '') {
document.getElementsByTagName('html')[0].style.position = 'relative';
document.getElementsByTagName('html')[0].style.minHeight = '100%';
document.getElementsByTagName('body')[0].style.marginBottom = '100px';
var body = document.getElementsByTagName('body')[0].innerHTML;
document.getElementsByTagName('body')[0].innerHTML = body + '<footer id="wykotube"></footer>';
var player = document.getElementById('wykotube');
player.style.position = 'fixed';
player.style.bottom = '0';
player.style.right = '0';
player.style.marginRight = '0';
player.style.padding = '5px 5px 5px 5px';
player.style.width = '26.5%';
player.style.height = '30%';
player.style.zIndex = '99';
player.style.backgroundColor = '#3c3c3c';
console.log(list);
player.innerHTML = '<div><h4>#CYCOPLAYER</h4></div><div><iframe id="ytplayer" type="text/html" width="100%" height="100%" src="https://www.youtube.com/embed/?playlist=' + list.substring(1, list.length) + '&version=3&autoplay=1" frameborder="0" allowfullscreen></div>';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment