This commit is contained in:
2026-07-16 18:01:36 +02:00
parent bf66a6d276
commit ef5fa4a6bc
2 changed files with 26 additions and 9 deletions

View File

@@ -432,8 +432,9 @@
padding: 0 3px;
text-shadow: none;
}
/* Hide images (emojis, inline imgs) inside unrevealed spoiler */
.danmaku-pill .dpill-spoiler img {
/* Hide images/videos (emojis, inline imgs, webm stickers) inside unrevealed spoiler */
.danmaku-pill .dpill-spoiler img,
.danmaku-pill .dpill-spoiler video {
opacity: 0;
transition: opacity 0.15s ease;
}
@@ -446,7 +447,9 @@
-1px 1px 0 #000, 1px 1px 0 #000;
}
.danmaku-pill .dpill-spoiler:hover img,
.danmaku-pill .dpill-spoiler.revealed img {
.danmaku-pill .dpill-spoiler.revealed img,
.danmaku-pill .dpill-spoiler:hover video,
.danmaku-pill .dpill-spoiler.revealed video {
opacity: 1;
}

View File

@@ -533,7 +533,7 @@ class Danmaku {
const raw = msg.dataset.rawText;
if (!raw) return;
// Only re-render if the content is still plain text (no img children)
if (!msg.querySelector('img.dpill-emoji')) {
if (!msg.querySelector('.dpill-emoji')) {
msg.textContent = '';
msg.appendChild(this._renderContent(raw));
}
@@ -600,11 +600,25 @@ class Danmaku {
const code = match[3];
const url = emojiCache[code];
if (url) {
const img = document.createElement('img');
img.src = url;
img.alt = `:${code}:`;
img.className = 'dpill-emoji';
parent.appendChild(img);
if (url.endsWith('.webm')) {
const vid = document.createElement('video');
vid.src = url;
vid.className = 'dpill-emoji';
vid.muted = true;
vid.loop = true;
vid.autoplay = true;
vid.playsInline = true;
vid.play().catch(() => {
vid.addEventListener('canplay', () => vid.play().catch(() => {}), { once: true });
});
parent.appendChild(vid);
} else {
const img = document.createElement('img');
img.src = url;
img.alt = `:${code}:`;
img.className = 'dpill-emoji';
parent.appendChild(img);
}
} else {
parent.appendChild(document.createTextNode(match[0]));
}