From ef5fa4a6bcd17e968e959d5011c79b7f4667f211 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Thu, 16 Jul 2026 18:01:36 +0200 Subject: [PATCH] danmaku --- public/s/css/v0ck.css | 9 ++++++--- public/s/js/danmaku.js | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/public/s/css/v0ck.css b/public/s/css/v0ck.css index fa34399..5cd596a 100644 --- a/public/s/css/v0ck.css +++ b/public/s/css/v0ck.css @@ -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; } diff --git a/public/s/js/danmaku.js b/public/s/js/danmaku.js index aa4931e..a527abf 100644 --- a/public/s/js/danmaku.js +++ b/public/s/js/danmaku.js @@ -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])); }