|
7 | 7 | */ |
8 | 8 |
|
9 | 9 | export default function decorate(block) { |
10 | | - const idCell = block.querySelector('div > div'); |
11 | | - if (!idCell) return; |
| 10 | + // Get the ID cell (second cell in the first row) |
| 11 | + const rows = block.querySelectorAll(':scope > div'); |
| 12 | + if (rows.length < 1) return; |
12 | 13 |
|
13 | | - const videoId = idCell.textContent.trim(); |
| 14 | + const idRow = rows[0]; // First row contains the ID |
| 15 | + const cells = idRow.querySelectorAll(':scope > div'); |
| 16 | + if (cells.length < 2) return; |
| 17 | + |
| 18 | + const videoId = cells[1].textContent.trim(); // Second cell contains the video ID |
14 | 19 | if (!videoId) return; |
15 | 20 |
|
| 21 | + console.log('Loading video ID:', videoId); // Debug log |
| 22 | + |
16 | 23 | const iframe = document.createElement('iframe'); |
17 | | - iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1&loop=1&playlist=${videoId}&mute=1&controls=0&rel=0&playsinline=1&disablekb=1`; |
18 | | - iframe.title = 'YouTube Video'; |
| 24 | + iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1&start=122&end=156&mute=1&loop=1&playlist=${videoId}&controls=0&rel=0&playsinline=1&modestbranding=1`; |
19 | 25 | iframe.allow = 'autoplay; encrypted-media'; |
20 | 26 | iframe.allowFullscreen = false; |
21 | | - iframe.setAttribute('tabindex', '-1'); |
22 | | - iframe.style = 'border: 0; width: 100%; aspect-ratio: 16/9; pointer-events: none;'; |
| 27 | + iframe.setAttribute('frameborder', '0'); |
| 28 | + iframe.style.cssText = 'border: 0; width: 100%; aspect-ratio: 16/9; pointer-events: none;'; |
23 | 29 |
|
| 30 | + // Replace the entire block content |
24 | 31 | block.innerHTML = ''; |
25 | 32 | block.appendChild(iframe); |
26 | 33 | } |
0 commit comments