Poll card and emote effects use the corner sticker from Actions -> Alerts
The heart on the winning poll option and the picture when Twitch sends no emote were still a fixed file name; they now come from the alert theme (placeholder when none is set). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c481ca92cb
commit
2659993a7d
2 changed files with 6 additions and 4 deletions
|
|
@ -11,7 +11,8 @@
|
|||
*/
|
||||
(function () {
|
||||
const AFTER_ANIM = 3000, SOUND_LEAD = 300;
|
||||
const FALLBACK = window.FX_FALLBACK || (window.ALERTS_BASE || '/alerts/') + 'art/Heart.png'; // when Twitch sends no emote
|
||||
// when Twitch sends no emote: the corner sticker from Actions → Alerts, else a plain shape
|
||||
const fallback = () => window.FX_FALLBACK || (window.S && window.S.alert_theme && window.S.alert_theme.heart) || (window.ALERTS_BASE || '/alerts/') + 'art/placeholder.svg';
|
||||
const esc = s => String(s ?? '').replace(/[&<>"]/g, c => ({ '&':'&', '<':'<', '>':'>', '"':'"' }[c]));
|
||||
const between = (a, b) => a + Math.random() * (b - a);
|
||||
|
||||
|
|
@ -27,7 +28,7 @@
|
|||
const a = new Audio(url); a.volume = volume;
|
||||
cur.timer = setTimeout(() => { cur.audio = a; a.play().catch(err => console.warn('[alerts] sound blocked:', err.message)); }, SOUND_LEAD);
|
||||
}
|
||||
const imgTag = (src, cls = '') => `<img class="${cls}" src="${esc(src || FALLBACK)}" alt="" onerror="this.onerror=null;this.src='${FALLBACK}'">`;
|
||||
const imgTag = (src, cls = '') => `<img class="${cls}" src="${esc(src || fallback())}" alt="" onerror="this.onerror=null;this.src='${fallback()}'">`;
|
||||
const A = (cur, node, frames, opts) => { const a = node.animate(frames, { fill:'both', ...opts }); cur.anims.push(a); return a; };
|
||||
const done = (cur, anim) => anim.finished.then(() => hide()).catch(() => {});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
*/
|
||||
(function () {
|
||||
const COLORS = ['#f4a0a8', '#a88be0', '#7fcfa6', '#f6c75b', '#8cc8f0'];
|
||||
const HEART = (window.ALERTS_BASE || '/alerts/') + 'art/Heart.png';
|
||||
// heart on the winning option: the corner sticker from Actions → Alerts, else a plain shape
|
||||
const heart = () => (window.S && window.S.alert_theme && window.S.alert_theme.heart) || (window.ALERTS_BASE || '/alerts/') + 'art/placeholder.svg';
|
||||
const SHOW_RESULT_MS = 9000;
|
||||
const esc = s => String(s ?? '').replace(/[&<>"]/g, c => ({ '&':'&', '<':'<', '>':'>', '"':'"' }[c]));
|
||||
let el = null, pollId = null, timer = null, hideTimer = null, endsAt = 0;
|
||||
|
|
@ -25,7 +26,7 @@
|
|||
${poll.choices.map((c, i) => `<div class="c" data-id="${esc(c.id)}">
|
||||
<div class="row"><span class="t">${esc(c.title)}</span><span class="n">0</span></div>
|
||||
<div class="track"><div class="fill" style="background-color:${COLORS[i % COLORS.length]}"></div></div>
|
||||
<img class="heart" src="${HEART}" alt=""></div>`).join('')}
|
||||
<img class="heart" src="${heart()}" alt=""></div>`).join('')}
|
||||
<div class="stamp">WINNER</div>`;
|
||||
el.style.visibility = 'visible';
|
||||
const tilt = (Math.random() * 4 - 2).toFixed(2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue