Activity replay, HUDFX in the overlay, chat filter, redeem art fix

- Dashboard Recent activity: readable details (reward name, cost, variation,
  rarity, TTS, viewer message; sub tier/months; bits; raids; polls), local
  times, and a Replay button. Each row now stores the overlay message that was
  shown (activity_log.replay_json); older redeem/raid rows are rebuilt from the
  raw Twitch event.
- Fix: redeem alerts lost polaroid/art/emote since 4fda606 (they had ended up
  inside a comment), so sticker art, Power-up emotes and sound-only were gone.
- HUDFX embedded in the overlay with ?ext=hudfx (opt-in per OBS source): its
  page is served from our domain with the camcorder CSS, its settings API is
  forwarded, its Web Worker is started from a same-origin stand-in (the alert
  box needs it; blob: workers break the site CSP), and the box sits in the
  alert corner. The HUDFX URL is a field on the Settings page.
- Blerp cassette CSS kept with it (src/ext/blerp.css, pasted into the Blerp
  OBS source; Blerp itself cannot be embedded: its realtime server only
  accepts its own site).
- On-screen chat: Settings -> Hidden chatters and Hide ! commands.
- Outgoing raids are logged with a line in the server log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-11-22 15:29:20 +02:00
parent 5f61b1ebe1
commit 19a0965eb2
16 changed files with 671 additions and 35 deletions

View file

@ -2,28 +2,42 @@
<p><em>No activity yet. Events will appear here once your overlay is connected and Twitch fires events.</em></p>
<% } else { %>
<figure>
<table>
<table class="activity">
<thead>
<tr>
<th>Time</th>
<th>Event</th>
<th>User</th>
<th>Detail</th>
<th>Actions fired</th>
<th><span title="Actions (Actions page) that fired for this event">Actions</span></th>
<th></th>
</tr>
</thead>
<tbody>
<% for (const log of logs) { %>
<% for (const log of logs) { const d = activity.describe(log); %>
<tr>
<td><small><%= log.created_at %></small></td>
<td><code><%= log.event_type %></code></td>
<td><small><time datetime="<%= String(log.created_at).replace(' ', 'T') %>Z"><%= log.created_at %> UTC</time></small></td>
<td><%= d.label %></td>
<td><%= log.username || '—' %></td>
<td><%= log.event_detail || '—' %></td>
<td>
<% if (d.title) { %><strong><%= d.title %></strong><% } %>
<% for (const tag of d.tags) { %> <span class="badge badge-grey"><%= tag %></span><% } %>
<% if (d.message) { %><br><small class="activity-msg">“<%= d.message %>”</small><% } %>
<% if (!d.title && !d.tags.length && !d.message) { %>—<% } %>
</td>
<td>
<span class="badge <%= log.actions_fired > 0 ? 'badge-green' : 'badge-grey' %>">
<%= log.actions_fired %>
</span>
</td>
<td>
<% if (activity.canReplay(log)) { %>
<button type="button" class="outline activity-replay" data-id="<%= log.id %>"
title="<%= log.replay_json ? 'Play this again on the overlay (queued like a real alert, not logged again)' : 'Older event: replays with a fresh pick of the reward\'s variations' %>"
style="width:auto; padding:.2rem .6rem; margin:0;">Replay</button>
<small class="activity-replay-status"></small>
<% } %>
</td>
</tr>
<% } %>
</tbody>

View file

@ -112,11 +112,32 @@
const stamp = document.getElementById('activity-updated');
const auto = document.getElementById('activity-auto');
let timer = null;
// times are stored in UTC: show them in this browser's time zone
function localTimes() {
box.querySelectorAll('time[datetime]').forEach(t => {
const d = new Date(t.getAttribute('datetime'));
if (!isNaN(d)) { t.title = t.textContent; t.textContent = d.toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' }); }
});
}
// Replay buttons (the table is re-rendered on reload, so listen on the box)
box.addEventListener('click', async ev => {
const b = ev.target.closest('.activity-replay'); if (!b) return;
const st = b.parentElement.querySelector('.activity-replay-status');
b.disabled = true; st.textContent = '…';
try {
const r = await fetch('/activity/' + encodeURIComponent(b.dataset.id) + '/replay', { method: 'POST' });
const j = await r.json().catch(() => ({}));
st.textContent = j.ok ? 'sent' : (j.error || `failed (${r.status})`);
} catch (e) { st.textContent = 'failed: ' + e.message; }
b.disabled = false;
});
localTimes();
async function reload() {
try {
const r = await fetch('/activity', { headers: { 'Accept': 'text/html' } });
if (r.redirected || !r.ok) { stamp.textContent = 'Reload failed (logged out?)'; return; }
box.innerHTML = await r.text();
localTimes();
stamp.textContent = 'Updated ' + new Date().toLocaleTimeString();
} catch (e) { stamp.textContent = 'Reload failed: ' + e.message; }
}

View file

@ -65,6 +65,12 @@
<%- settings.custom_css %>
</style>
<style>
/* HUDFX / Blerp pages (src/routers/ext.js). HUDFX's page is 2560x1440: scaled to this 1920x1080 page. */
.ext-frame { position:fixed; left:0; top:0; border:0; background:transparent; pointer-events:none; transform-origin:0 0; z-index:5; }
#ext-hudfx { width:2560px; height:1440px; transform:scale(.75); }
#ext-blerp { width:1920px; height:1080px; }
</style>
</head>
<body>
<% if (has('chat')) { %><div id="chat" class="<%= chatFlow %>"<% if (chatBox) { %> style="--chat-left:<%= chatBox.left %>px; --chat-top:<%= chatBox.top %>px; --chat-width:<%= chatBox.width %>px; --chat-height:<%= chatBox.height %>px;"<% } %>></div><% } %>
@ -117,6 +123,10 @@
client.on('message', (channel, tags, message) => {
if (!PARTS.has('chat')) return; // other sources only listen to chat for watch streaks
// Settings → Chat: hidden chatters (bots, alert services) and ! commands never reach the screen
const hidden = String(S.chat_hidden_users || '').toLowerCase().split(/[\s,]+/).filter(Boolean);
if (hidden.includes(String(tags.username || '').toLowerCase())) return;
if (S.chat_hide_commands && /^\s*!/.test(message)) return;
const now = Date.now();
const silence = (now - lastMsgTime) / 1000;
@ -221,5 +231,13 @@
<%- settings.custom_js %>
</script>
<% const extSrc = (n, v) => `/ext/${settings.overlay_id}/${n}?vol=${v}`; %>
<% if (ext.on.includes('hudfx')) { %>
<iframe id="ext-hudfx" class="ext-frame" src="<%= extSrc('hudfx', ext.hudfxVol) %>" allow="autoplay" scrolling="no"></iframe>
<% } %>
<% if (ext.on.includes('blerp')) { const b = ext.blerp; %>
<iframe id="ext-blerp" class="ext-frame" src="<%= extSrc('blerp', ext.blerpVol) %>" allow="autoplay" scrolling="no"
style="transform:translate(<%= b.cx - 960 * b.s %>px, <%= b.cy - 540 * b.s %>px) scale(<%= b.s %>)"></iframe>
<% } %>
</body>
</html>

View file

@ -25,7 +25,15 @@
</label>
</div>
<h3>Gap audio</h3>
<label title="Messages from these accounts never appear in the on-screen chat (bots, alert services). Twitch login names, separated by commas or spaces.">
Hidden chatters
<input type="text" name="chat_hidden_users" value="<%= settings.chat_hidden_users || '' %>" placeholder="bot_account, blerp, …">
</label>
<label title="Chat commands like !discord or !lurk are not shown in the on-screen chat. The bot's answer is hidden too if the bot is in Hidden chatters.">
<input type="checkbox" name="chat_hide_commands" role="switch" <%= settings.chat_hide_commands ? 'checked' : '' %>> Hide ! commands
</label>
<h3>Gap audio</h3>
<p><small>Plays a sound when a new message arrives after a period of silence.</small></p>
<label>
<input type="checkbox" name="gap_audio_enabled" role="switch" <%= settings.gap_audio_enabled ? 'checked' : '' %>>
@ -77,6 +85,12 @@
<small>If a message contains one, nothing is read and the letter shows "(message removed)". Whole words and phrases, not case-sensitive, plurals included; also catches swaps like 0→o, $→s and spaced-out letters (k y s). Starts with a list of slurs and Twitch-risky phrases (normal swearing is allowed); edit freely. Links are always removed.</small>
</label>
<h3>HUDFX</h3>
<label title="Paste the browser source URL from HUDFX. Then add &amp;ext=hudfx to an overlay URL in OBS: HUDFX effects play inside that overlay (one audio fader), with the camcorder look. Leave empty to turn it off.">
HUDFX overlay URL
<input type="url" name="hudfx_overlay_url" value="<%= settings.hudfx_overlay_url || '' %>" placeholder="https://overlays.hudfx.io/overlay/…">
</label>
<h3>Custom CSS / JS</h3>
<label>
Custom CSS (injected into the overlay)