Komimau Wiki
Attachments
History
Blame
View Source
Documentation
Toggle dark mode
Login
Home
A - Z
Changelog
Menu
Komimau Wiki
▸ Home
▸ People
▸ Matrix
▸ History
▸ Worship
Gacha
▸ Arknights: Endfield
▸ Wuthering Waves
▸ Honkai: Star Rail
▸ Langrisser
Minecraft
▸ KomimauSMP
▸ Speedrunning
Tetris
▸ Terminologies
▸ Openers
▸ Set-ups
Escape from Tarkov
▸ Transit
▸ Quests
Tech
▸ Coding
▸ Linux
Misc
▸ Test
An Otter Wiki
Test
C
f72ad6
Commit
f72ad6
2026-02-05 22:22:34
luxmiyu
: confirm <youtube> tags work
test/c.md
..
@@ 1,5 1,28 @@
# Youtube Tag
-
Trying to see if I can get youtube tags to get replaced with iframes
+
Trying to see if I can get youtube tags to get replaced with iframes, like this: `<youtube>dQw4w9WgXcQ</youtube>`
<youtube>dQw4w9WgXcQ</youtube>
+
+
Seems to work perfectly. I'm using the code snippet below:
+
+
```js
+
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);
+
}
+
});
+
});
+
```
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