14 lines
443 B
JavaScript
14 lines
443 B
JavaScript
function openVideo (elt) {
|
|
|
|
let url = elt.href;
|
|
|
|
var embedLink = url.replace(/(https?:\/\/.*\/videos)\/watch\/(.*)/, '$1/embed/$2?start=0s&autoplay=1');
|
|
|
|
|
|
var image = elt.getElementsByTagName('img')[0];
|
|
|
|
image.style.display = "none";
|
|
|
|
image.insertAdjacentHTML('afterend', '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups" src="'+embedLink+'" frameborder="0" allowfullscreen></iframe>');
|
|
}
|