Created
February 1, 2023 07:03
-
-
Save jlewin/5e54fb35a30ac735b87e8ddfc8a035a8 to your computer and use it in GitHub Desktop.
Add playlist support to list of links in Canvas
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 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