1if (!Element.prototype.matches) { 2 Element.prototype.matches = 3 Element.prototype.matchesSelector || 4 Element.prototype.mozMatchesSelector || 5 Element.prototype.msMatchesSelector || 6 Element.prototype.oMatchesSelector || 7 Element.prototype.webkitMatchesSelector || 8 function(s) { 9 var matches = (this.document || this.ownerDocument).querySelectorAll(s); 10 var i = matches.length; 11 while (--i >= 0 && matches.item(i) !== this) {} 12 return i > -1; 13 }; 14} 15 16function playVideo(button) { 17 let container = button.nextElementSibling; 18 19 if (!container) { 20 console.error('Video container not found'); 21 return; 22 } 23 24 container.style.display = 'block'; 25 button.style.display = 'none'; 26 27 setTimeout(function() { 28 let iframe = container.querySelector('iframe'); 29 30 if (!iframe) { 31 console.error('Iframe not found in container'); 32 return; 33 } 34 35 let src = iframe.src || iframe.getAttribute('src'); 36 37 if (!src) { 38 console.error('Iframe src is empty'); 39 return; 40 } 41 42 let urlMatch = src.match(/[?&]url=([^&]+)/); 43 44 if (!urlMatch || !urlMatch[1]) { 45 console.error('Could not find url parameter in oEmbed src'); 46 return; 47 } 48 49 let decodedUrl = decodeURIComponent(urlMatch[1]); 50 51 let videoId = extractYouTubeId(decodedUrl); 52 53 if (!videoId) { 54 console.error('Could not extract YouTube video ID'); 55 return; 56 } 57 58 let newSrc = 'https://www.youtube.com/embed/' + videoId + '?autoplay=1&enablejsapi=1'; 59 60 iframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'); 61 62 iframe.setAttribute('src', newSrc); 63 64 if (iframe.src !== newSrc) { 65 iframe.src = newSrc; 66 } 67 68 }, 100); 69} 70 71function extractYouTubeId(url) { 72 73 let match = url.match(/[?&]v=([^&]+)/); 74 75 if (match && match[1]) { 76 return match[1]; 77 } 78 79 match = url.match(/youtu\.be\/([^?&]+)/); 80 if (match && match[1]) { 81 return match[1]; 82 } 83 84 match = url.match(/youtube\.com\/embed\/([^?&]+)/); 85 if (match && match[1]) { 86 return match[1]; 87 } 88 89 match = url.match(/youtube\.com\/v\/([^?&]+)/); 90 if (match && match[1]) { 91 return match[1]; 92 } 93 94 return null; 95}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.