Skip to content

Instantly share code, notes, and snippets.

@jlewin
Created February 1, 2023 07:03
Show Gist options
  • Save jlewin/5e54fb35a30ac735b87e8ddfc8a035a8 to your computer and use it in GitHub Desktop.
Save jlewin/5e54fb35a30ac735b87e8ddfc8a035a8 to your computer and use it in GitHub Desktop.
Add playlist support to list of links in Canvas
var lastNode = null;
var video = document.createElement('iframe');
video.setAttribute('name','jlFrame');
video.style = `display: block;
width: 1900px;
float: right;
position: absolute;
right: 0px;
min-height: 100vh;
top: 0px;
z-index: 1000;`;
var target = document.querySelector('#application');
target.insertAdjacentElement('afterbegin', video);
var dump = document.querySelectorAll('.user_content.enhanced h2')[1];
var mediaLinks = Array.from(document.querySelectorAll('a')).filter(a => a.href.indexOf('/embed') > 0);
mediaLinks.forEach(function(l) {
l.setAttribute('target', 'jlFrame');
l.addEventListener('click', function() {
dump.innerText = l.text.split('\n')[0];
l.parentNode.style = 'background: #ccc; color: blue;';
if (lastNode)
lastNode.parentNode.style = '';
lastNode = l;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment