Youtube Tag

Trying to see if I can get youtube tags to get replaced with iframes, like this: <youtube>dQw4w9WgXcQ</youtube>

dQw4w9WgXcQ

Seems to work perfectly. I'm using the code snippet below:

document.addEventListener("DOMContentLoaded", function() {
  const youtubeTags = document.querySelectorAll("youtube");

  youtubeTags.forEach(tag => {
    const videoId = tag.textContent.trim();
    if (videoId) {
      const iframe = document.createElement("iframe");
      iframe.width = "560";
      iframe.height = "315";
      iframe.src = `https://www.youtube.com/embed/${videoId}`;
      iframe.frameBorder = "0";
      iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
      iframe.allowFullscreen = true;

      tag.parentNode.replaceChild(iframe, tag);
    }
  });
});

If you want to add a youtube video, just <youtube>VIDEO_ID</youtube> will work!

Furigana??

明日(あした)

On this page
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9