danmaku
This commit is contained in:
@@ -432,8 +432,9 @@
|
|||||||
padding: 0 3px;
|
padding: 0 3px;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
/* Hide images (emojis, inline imgs) inside unrevealed spoiler */
|
/* Hide images/videos (emojis, inline imgs, webm stickers) inside unrevealed spoiler */
|
||||||
.danmaku-pill .dpill-spoiler img {
|
.danmaku-pill .dpill-spoiler img,
|
||||||
|
.danmaku-pill .dpill-spoiler video {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 0.15s ease;
|
transition: opacity 0.15s ease;
|
||||||
}
|
}
|
||||||
@@ -446,7 +447,9 @@
|
|||||||
-1px 1px 0 #000, 1px 1px 0 #000;
|
-1px 1px 0 #000, 1px 1px 0 #000;
|
||||||
}
|
}
|
||||||
.danmaku-pill .dpill-spoiler:hover img,
|
.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;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ class Danmaku {
|
|||||||
const raw = msg.dataset.rawText;
|
const raw = msg.dataset.rawText;
|
||||||
if (!raw) return;
|
if (!raw) return;
|
||||||
// Only re-render if the content is still plain text (no img children)
|
// 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.textContent = '';
|
||||||
msg.appendChild(this._renderContent(raw));
|
msg.appendChild(this._renderContent(raw));
|
||||||
}
|
}
|
||||||
@@ -600,11 +600,25 @@ class Danmaku {
|
|||||||
const code = match[3];
|
const code = match[3];
|
||||||
const url = emojiCache[code];
|
const url = emojiCache[code];
|
||||||
if (url) {
|
if (url) {
|
||||||
const img = document.createElement('img');
|
if (url.endsWith('.webm')) {
|
||||||
img.src = url;
|
const vid = document.createElement('video');
|
||||||
img.alt = `:${code}:`;
|
vid.src = url;
|
||||||
img.className = 'dpill-emoji';
|
vid.className = 'dpill-emoji';
|
||||||
parent.appendChild(img);
|
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 {
|
} else {
|
||||||
parent.appendChild(document.createTextNode(match[0]));
|
parent.appendChild(document.createTextNode(match[0]));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user