Stats per stream and period, public stats page, dashboard settings, Card alert style
Statistics - Per day and per stream statistics (src/periodstats.js, one generic stat_day table), backfilled once from the older tables; Stream / Week / Month / Year / All time views, Community and Streams tabs. - Viewer count every 5 minutes and title / category history per stream (EventSub channel.update): viewer graph, games played (donut), games in the streams list. - Twitch sync (src/twitchsync.js): followers with follow dates, current subs, mods, VIPs, all-time bits, channel emotes, past streams from VODs. Twitch analytics CSV import (src/twitchcsv.js). - Public stats page on its own host (Settings -> Stats and data): no message text, no bots, !hideme / !showme opt-out. Viewer page: roles, follow age, sub status, bits, a menu for rarely used actions. - StreamElements watch-time importer removed (already imported minutes stay as a baseline). Dashboard - Settings and Actions with a left sidebar; each settings page saves only its own fields. Connections (Twitch, StreamElements token now set here, HUDFX), OBS links (hidden behind an eye toggle) with a link builder, Chat (sound picked from the media library), TTS, Stats and data, Backup (export / import the whole setup), Advanced. Time zone setting for the stats pages. - Actions -> Alerts: alert style, pictures, sounds, bits tiers and card colours, stored in the database (src/theme.js); an old file-based theme is imported once. Alert preview page (/actions/alerts/preview, tools/preview/export.js for a static copy). - Old /actions page removed; Actions = Redeems / Alerts / TTS voices / Media. Alerts - New plain Card style for everyone (public/alerts/card.js); Polaroid, Cassette and the TTS letter stay as optional looks. Redeem variations can be Card, Cassette, Sound only or Video. Repo - No channel data in git: the channel's art, stickers and sounds stay on disk (gitignored) and are picked in the dashboard; examples for the server config (apache.example.sh, .env.example). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5bf4bffaa0
commit
c481ca92cb
57 changed files with 3080 additions and 774 deletions
411
views/_statsbody.ejs
Normal file
411
views/_statsbody.ejs
Normal file
|
|
@ -0,0 +1,411 @@
|
|||
<%#
|
||||
Shared statistics body for the admin Stats page (views/stats.ejs) and the public page (views/public_stats.ejs).
|
||||
Two views (?v=community | streams) x periods (?p=stream|week|month|year|all).
|
||||
Community: supporters, raids, leaderboards, community ranks, emotes, commands, rewards.
|
||||
Streams: numbers, one activity chart (pick what to show), games played, the streams list; one stream: viewer graph.
|
||||
Locals: s = periodstats.summary(), q = rangeQuery helper, base = link prefix ('/stats', '/public' or '/'),
|
||||
view = 'community' | 'streams', mode = 'admin' | 'public', viewerHref = viewer link prefix or null,
|
||||
extraBoards = [{ title, rows, level, wide }], ranks = [{ login, name, level }] (Regular and up, all time).
|
||||
Colours come from the page: --muted, --line, --accent, --accent-hover, --card (and --card-solid for popups).
|
||||
A new section goes here once and appears on both pages; wrap it in `if (admin)` when it is not for the public.
|
||||
%>
|
||||
<%
|
||||
const admin = locals.mode === 'admin';
|
||||
const esc = v => String(v ?? '').replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
const num = n => Number(n || 0).toLocaleString('en-US');
|
||||
const hm = m => m >= 60 ? `${Math.floor(m / 60)} h ${String(Math.round(m % 60)).padStart(2, '0')} m` : `${Math.round(m)} m`;
|
||||
const r = s.range, T = s.totals, C = s.channel || {}, TW = s.twitch;
|
||||
const v = locals.view === 'streams' ? 'streams' : 'community';
|
||||
const cur = { p: r.p, d: r.from || undefined, s: r.p === 'stream' ? r.stream.id : undefined };
|
||||
const link = (rq, view = v) => base + q({ ...rq, v: view === 'community' ? undefined : view });
|
||||
const TZ = locals.tz || 'UTC'; // Settings → General → Time zone
|
||||
const day = iso => new Date(iso).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric', timeZone: TZ });
|
||||
const time = iso => new Date(iso).toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit', timeZone: TZ });
|
||||
const emoteSrc = e => e.source === 'twitch' && e.id ? `https://static-cdn.jtvnw.net/emoticons/v2/${e.id}/default/dark/1.0`
|
||||
: e.source === '7tv' && e.id ? `https://cdn.7tv.app/emote/${e.id}/1x.webp` : null;
|
||||
// ⓘ with an instant tooltip (hover, or tap / keyboard focus)
|
||||
const info = text => text ? ` <span class="sb-i" tabindex="0" data-tip="${esc(text)}">ⓘ</span>` : '';
|
||||
const person = x => { const n = esc(x.name || x.login || '?'); return viewerHref && x.login ? `<a href="${viewerHref}${encodeURIComponent(x.login)}">${n}</a>` : n; };
|
||||
const since = TW && TW.streamedDays ? TW.cutoff : null; // period reaches back before HeyStreamer counted
|
||||
%>
|
||||
<style>
|
||||
.sb-nav { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem 1rem; margin:.4rem 0 1rem; }
|
||||
.sb-views { display:flex; gap:1.2rem; border-bottom:1px solid var(--line); margin:.2rem 0 .8rem; }
|
||||
.sb-views a { padding:.4rem .1rem; text-decoration:none; color:var(--muted); font-weight:700; border-bottom:3px solid transparent; margin-bottom:-1px; }
|
||||
.sb-views a.on { color:inherit; border-bottom-color:var(--accent); }
|
||||
.sb-tabs { display:flex; gap:.25rem; flex-wrap:wrap; }
|
||||
.sb-tabs a { padding:.25rem .8rem; border-radius:99px; border:1px solid var(--line); text-decoration:none; color:inherit; font-size:.85rem; }
|
||||
.sb-tabs a.on { background:var(--accent); border-color:var(--accent); color:#fff; }
|
||||
.sb-step { display:flex; align-items:center; gap:.4rem; margin-left:auto; }
|
||||
.sb-step a, .sb-step span.off { padding:.15rem .6rem; border-radius:8px; border:1px solid var(--line); text-decoration:none; color:inherit; }
|
||||
.sb-step span.off { opacity:.35; }
|
||||
.sb-title { font-weight:700; }
|
||||
.sb-sub { color:var(--muted); font-size:.85rem; }
|
||||
.sb-i { position:relative; cursor:help; color:var(--muted); font-size:.85em; outline:none; }
|
||||
.sb-i:hover::after, .sb-i:focus::after { content:attr(data-tip); position:absolute; left:50%; bottom:calc(100% + 6px); transform:translateX(-50%);
|
||||
width:max-content; max-width:260px; white-space:normal; text-align:left; font-size:.78rem; font-weight:400; line-height:1.35; color:inherit;
|
||||
background:var(--card-solid, var(--card)); border:1px solid var(--line); border-radius:8px; padding:.4rem .55rem;
|
||||
box-shadow:0 6px 18px rgba(0,0,0,.3); z-index:30; }
|
||||
.sb-tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:.6rem; margin:.2rem 0 1.2rem; }
|
||||
.sb-tile { border:1px solid var(--line); border-radius:12px; padding:.65rem .85rem; background:var(--card); }
|
||||
.sb-tile .v { font-size:1.5rem; font-weight:700; line-height:1.1; font-variant-numeric:tabular-nums; white-space:nowrap; }
|
||||
.sb-tile .k { font-size:.8rem; color:var(--muted); }
|
||||
.sb-h { margin:1.4rem 0 .6rem; font-size:1.1rem; }
|
||||
.sb-streams { width:100%; border-collapse:collapse; font-size:.86rem; }
|
||||
.sb-streams th, .sb-streams td { text-align:left; padding:.4rem .5rem; border-bottom:1px solid var(--line); background:none; vertical-align:top; }
|
||||
.sb-streams th { color:var(--muted); font-weight:600; font-size:.78rem; }
|
||||
.sb-streams td.n { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
|
||||
.sb-streams .t { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:20rem; display:block; }
|
||||
.sb-streams .g { color:var(--muted); font-size:.78rem; }
|
||||
.sb-scroll { overflow-x:auto; }
|
||||
.sb-chart { border:1px solid var(--line); border-radius:12px; padding:.7rem .9rem; position:relative; background:var(--card); }
|
||||
.sb-chart h4 { margin:0 0 .4rem; font-size:.95rem; }
|
||||
.sb-chart svg { width:100%; height:auto; display:block; }
|
||||
.sb-chart .bar { fill:var(--accent); }
|
||||
.sb-chart .hit:hover + .bar { fill:var(--accent-hover); }
|
||||
.sb-chart .grid { stroke:var(--line); stroke-width:1; }
|
||||
.sb-chart .ax { fill:var(--muted); font-size:10px; }
|
||||
.sb-metrics { display:flex; flex-wrap:wrap; gap:.3rem; margin-bottom:.5rem; }
|
||||
.sb-metrics button { all:unset; cursor:pointer; padding:.2rem .7rem; border-radius:99px; border:1px solid var(--line); font-size:.8rem; }
|
||||
.sb-metrics button.on { background:var(--accent); border-color:var(--accent); color:#fff; }
|
||||
.sb-tip { position:absolute; pointer-events:none; background:var(--card-solid, var(--card)); border:1px solid var(--line);
|
||||
border-radius:8px; padding:.25rem .5rem; font-size:.8rem; box-shadow:0 4px 12px rgba(0,0,0,.35); white-space:nowrap; display:none; z-index:5; }
|
||||
.sb-two { display:grid; grid-template-columns:minmax(0, 2fr) minmax(260px, 1fr); gap:1rem; align-items:start; }
|
||||
@media (max-width: 800px) { .sb-two { grid-template-columns:1fr; } }
|
||||
.sb-games { display:flex; gap:1rem; align-items:center; flex-wrap:wrap; }
|
||||
.sb-games svg { width:150px; height:150px; flex:none; }
|
||||
.sb-games ul { list-style:none; margin:0; padding:0; flex:1; min-width:160px; max-width:440px; font-size:.85rem; }
|
||||
.sb-games li { list-style:none; display:grid; grid-template-columns:.8rem minmax(0, 1fr) auto; gap:.45rem; align-items:center; padding:.15rem 0; }
|
||||
.sb-games .sw { width:.8rem; height:.8rem; border-radius:3px; }
|
||||
.sb-games .nm { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
||||
.sb-games .hv { color:var(--muted); font-variant-numeric:tabular-nums; white-space:nowrap; }
|
||||
.sb-boards { display:grid; grid-template-columns:repeat(auto-fill, minmax(290px, 1fr)); gap:1rem; }
|
||||
.sb-board { border:1px solid var(--line); border-radius:12px; padding:.6rem .8rem; background:var(--card); }
|
||||
.sb-board h4 { margin:0 0 .3rem; font-size:.95rem; }
|
||||
.sb-board ol { list-style:none; margin:0; padding:0; }
|
||||
.sb-board li { list-style:none; display:grid; grid-template-columns:1.6rem minmax(0, 1fr) var(--nw, 4.6rem); align-items:center; gap:.5rem;
|
||||
height:2rem; margin:0; padding:0 .2rem; border-bottom:1px solid var(--line); font-size:.88rem; }
|
||||
.sb-board li:last-child { border-bottom:0; }
|
||||
.sb-board .r { color:var(--muted); text-align:right; font-variant-numeric:tabular-nums; }
|
||||
.sb-board .who { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
|
||||
.sb-board .who a { text-decoration:none; }
|
||||
.sb-board .lvl { font-size:.66rem; padding:.02rem .45rem; border-radius:99px; border:1px solid var(--line); color:var(--muted); white-space:nowrap; justify-self:start; }
|
||||
.sb-board .n { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
|
||||
.sb-board.wide { grid-column:span 2; }
|
||||
.sb-board.wide li { grid-template-columns:1.6rem minmax(0, 1fr) 5.5rem var(--nw, 4.6rem); }
|
||||
@media (max-width: 700px) { .sb-board.wide { grid-column:auto; } }
|
||||
.sb-pills { display:flex; flex-wrap:wrap; gap:.45rem; }
|
||||
.sb-pill { display:flex; align-items:center; gap:.35rem; border:1px solid var(--line); border-radius:99px; padding:.15rem .6rem .15rem .3rem; font-size:.82rem; background:var(--card); }
|
||||
.sb-pill.txt { padding-left:.6rem; }
|
||||
.sb-pill img { width:26px; height:26px; object-fit:contain; }
|
||||
.sb-pill a { text-decoration:none; }
|
||||
.sb-pill .what { color:var(--muted); font-size:.75rem; }
|
||||
.sb-pill.zero { opacity:.5; }
|
||||
.sb-empty { color:var(--muted); font-size:.85rem; font-style:italic; }
|
||||
.sb-note { color:var(--muted); font-size:.8rem; }
|
||||
.sb-ranks { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:1rem; }
|
||||
.sb-rank { border:1px solid var(--line); border-radius:12px; padding:.6rem .8rem; background:var(--card); }
|
||||
.sb-rank h4 { margin:0 0 .45rem; font-size:.95rem; }
|
||||
.sb-timeline .area { fill:var(--accent); opacity:.18; }
|
||||
.sb-timeline .line { fill:none; stroke:var(--accent); stroke-width:2.5; stroke-linejoin:round; }
|
||||
.sb-timeline .dot { fill:transparent; }
|
||||
.sb-timeline .dot:hover { fill:var(--accent); }
|
||||
.sb-timeline .mark { stroke:var(--muted); stroke-dasharray:4 4; }
|
||||
.sb-timeline .markdot { fill:var(--muted); }
|
||||
.sb-changes { list-style:none; padding:0; margin:.6rem 0 0; font-size:.86rem; }
|
||||
.sb-changes li { list-style:none; padding:.2rem 0; border-bottom:1px dashed var(--line); }
|
||||
.sb-changes .when { display:inline-block; min-width:3.4rem; color:var(--muted); font-variant-numeric:tabular-nums; }
|
||||
.sb-changes .game { color:var(--muted); font-size:.8rem; margin-left:.4rem; }
|
||||
.sb-vod { font-size:.65rem; border:1px solid var(--line); border-radius:99px; padding:0 .35rem; color:var(--muted); }
|
||||
</style>
|
||||
|
||||
<div class="sb-views" role="tablist">
|
||||
<a href="<%= link(cur, 'community') %>" class="<%= v === 'community' ? 'on' : '' %>">Community</a>
|
||||
<a href="<%= link(cur, 'streams') %>" class="<%= v === 'streams' ? 'on' : '' %>">Streams</a>
|
||||
</div>
|
||||
|
||||
<div class="sb-nav">
|
||||
<div class="sb-tabs">
|
||||
<% for (const [p, label] of [['stream', 'Stream'], ['week', 'Week'], ['month', 'Month'], ['year', 'Year'], ['all', 'All time']]) { %>
|
||||
<a href="<%= link(p === 'all' ? { p } : { p, ...(p === 'stream' ? {} : { d: r.from || undefined }) }) %>" class="<%= r.p === p ? 'on' : '' %>"><%= label %></a>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="sb-step">
|
||||
<% if (r.p !== 'all') { %>
|
||||
<% if (r.prev) { %><a href="<%= link(r.prev) %>" title="<%= r.p === 'stream' ? 'Older stream' : 'Earlier' %>">‹</a><% } else { %><span class="off">‹</span><% } %>
|
||||
<% } %>
|
||||
<span><span class="sb-title"><%= r.label %></span><% if (r.sub) { %> <span class="sb-sub">· <%= r.sub %></span><% } %></span>
|
||||
<% if (r.p !== 'all') { %>
|
||||
<% if (r.next) { %><a href="<%= link(r.next) %>" title="<%= r.p === 'stream' ? 'Newer stream' : 'Later' %>">›</a><% } else { %><span class="off">›</span><% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%
|
||||
// ---- number tiles. Public: a short, friendly set; admin: everything ----
|
||||
const T_ = {}; // id -> [value, label, tooltip]
|
||||
T_.messages = [num(T.messages), 'chat messages', since ? `Before ${since} from Twitch's daily analytics, after that counted by HeyStreamer` : ''];
|
||||
T_.watch = [num(T.watchHours), 'hours watched', T.historyWatchHours ? `${num(T.historyWatchHours)} h from Twitch's daily analytics (before ${since}), the rest counted by HeyStreamer` : T.baselineHours ? `Includes ${num(T.baselineHours)} h counted by StreamElements before HeyStreamer counted itself` : ''];
|
||||
if (r.p !== 'stream') T_.streams = [num(T.streams), T.streams === 1 ? 'stream' : 'streams', since ? `Before ${since} every day with a stream counts as one stream (Twitch's daily analytics)` : ''];
|
||||
T_.streamed = r.p === 'stream' && s.streams[0] ? [hm(s.streams[0].minutes), s.streams[0].live ? 'live for' : 'streamed'] : [num(T.hoursStreamed), 'hours streamed'];
|
||||
T_.emotes = [num(T.emotes), 'emotes used', since ? `Counted by HeyStreamer since ${since}` : ''];
|
||||
if (TW && TW.clips) T_.clips = [num(TW.clips), 'clips created', `${num(TW.clipViews)} clip views (Twitch's daily analytics)`];
|
||||
T_.redeems = [num(T.redeems), 'rewards redeemed', `${num(T.channelPoints)} channel points spent${since ? `; counted since ${since}` : ''}`];
|
||||
if (admin) {
|
||||
if (r.p === 'all' && C.followers != null) T_.followers = [num(C.followers), 'followers', 'Following the channel right now (from Twitch)'];
|
||||
if (r.p === 'all' && C.subsNow != null) T_.subsNow = [num(C.subsNow), 'subscribers', 'Subscribed right now (from Twitch, without the streamer)'];
|
||||
T_.chatters = [num(T.chatters), since ? `chatters since ${since}` : 'chatters', 'Different people who chatted. Twitch\'s export has no names, so this only counts from HeyStreamer\'s start'];
|
||||
T_.viewers = [num(T.viewers), since ? `viewers since ${since}` : 'viewers', `Different people in the chatter list while live, lurkers included${T.viewersFromBaseline ? `. Includes ${num(T.viewersFromBaseline)} viewers known only from StreamElements' watch time (from before HeyStreamer counted), which is why All time is higher than the other tabs` : ''}`];
|
||||
const pk = r.p === 'stream' ? s.streams[0] : C;
|
||||
if (pk && pk.peak != null) T_.peak = [num(pk.peak), 'peak viewers', pk.avg != null ? `About ${num(pk.avg)} on average` : ''];
|
||||
if (TW && TW.uniquePerDay != null) T_.unique = [num(TW.uniquePerDay), 'unique viewers / stream day', 'Twitch\'s count of different people who watched, averaged over the days you streamed'];
|
||||
if (TW && (TW.newEngaged || TW.returningEngaged)) T_.engaged = [num(TW.newEngaged), 'new engaged viewers', `${num(TW.returningEngaged)} returning engaged viewer-days. Engaged = watched 5+ minutes and chatted or followed (Twitch)`];
|
||||
if (TW && TW.revenue) T_.revenue = [`$${TW.revenue.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`, 'revenue · admin only',
|
||||
TW.revenueByType.map(([k, x]) => `${k} $${x.toFixed(2)}`).join(', ') + ' (Twitch export, before payout fees and taxes)'];
|
||||
if (T.follows && !T_.followers) T_.follows = [num(T.follows), 'new followers'];
|
||||
if (T.intros) T_.intros = [num(T.intros), 'first-time chatters'];
|
||||
if (T.subs || T.giftSubs) T_.subs = [num(T.subs + T.giftSubs), 'subs', `${num(T.subs)} subs and resubs, ${num(T.giftSubs)} gifted`];
|
||||
if (T.bits) T_.bits = [num(T.bits), 'bits', s.bitsSource === 'twitch' ? 'All time, from Twitch (top 100 cheerers)' : T.powerUps ? `${num(T.powerUps)} Power-ups included` : ''];
|
||||
if (T.raids) T_.raids = [num(T.raids), T.raids === 1 ? 'raid' : 'raids', `${num(T.raidViewers)} viewers brought in`];
|
||||
if (T.checkins) T_.checkins = [num(T.checkins), 'check-ins', 'First message of a stream'];
|
||||
}
|
||||
const order = admin
|
||||
? ['followers', 'subsNow', 'messages', 'chatters', 'viewers', 'watch', 'streams', 'streamed', 'peak', 'unique', 'engaged', 'clips', 'revenue', 'follows', 'intros', 'emotes', 'subs', 'bits', 'redeems', 'raids', 'checkins']
|
||||
: ['messages', 'watch', 'streams', 'streamed', 'emotes', 'clips', 'redeems'];
|
||||
const tiles = order.filter(k => T_[k]).map(k => T_[k]);
|
||||
%>
|
||||
<% if (admin || v === 'streams') { %>
|
||||
<div class="sb-tiles">
|
||||
<% for (const [val, k, tip] of tiles) { %><div class="sb-tile"><div class="v"><%= val %></div><div class="k"><%= k %><%- info(tip) %></div></div><% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (v === 'streams') { %>
|
||||
<%# ===================== STREAMS ===================== %>
|
||||
<% if (r.p === 'stream' && s.streams[0]) { const x = s.streams[0]; %>
|
||||
<p class="sb-sub" style="margin-top:-.6rem;">
|
||||
<%= day(x.started_at) %>, <%= time(x.started_at) %>–<%= x.ended_at ? time(x.ended_at) : 'now' %><%= x.games.length ? ` · ${x.games.join(', ')}` : '' %>
|
||||
<% if (x.live) { %> · <strong>live now</strong><% } %>
|
||||
<% if (x.source === 'vod') { %> · from the VOD (HeyStreamer was not counting)<% } %>
|
||||
</p>
|
||||
<%
|
||||
// viewers every 5 minutes as an area line; title / category changes as dashed markers
|
||||
const tl = s.timeline;
|
||||
if (tl && (tl.samples.length || tl.changes.length)) {
|
||||
const W = 900, H = 200, L = 34, B = 20, TOP = 10;
|
||||
const t0 = Date.parse(tl.start), t1 = Math.max(Date.parse(tl.end), t0 + 60000);
|
||||
const max = Math.max(1, ...tl.samples.map(p => p.viewers));
|
||||
const top = (() => { const p = Math.pow(10, Math.floor(Math.log10(max))); return [1, 2, 2.5, 5, 10].map(m => m * p).find(x => x >= max); })();
|
||||
const X = t => L + (W - L) * (Date.parse(t) - t0) / (t1 - t0), Y = n => TOP + (H - TOP - B) * (1 - n / top);
|
||||
let svg = `<svg viewBox="0 0 ${W} ${H}" role="img" aria-label="Viewers during the stream">`;
|
||||
for (const g of [0, top / 2, top]) svg += `<line class="grid" x1="${L}" x2="${W}" y1="${Y(g)}" y2="${Y(g)}"/><text class="ax" x="${L - 4}" y="${Y(g) + 3}" text-anchor="end">${g}</text>`;
|
||||
for (let h = 0; h <= (t1 - t0) / 36e5; h++) { const tt = new Date(t0 + h * 36e5).toISOString(); svg += `<text class="ax" x="${X(tt)}" y="${H - 5}" text-anchor="middle">${time(tt)}</text>`; }
|
||||
if (tl.samples.length) {
|
||||
const pts = tl.samples.map(p => `${X(p.at).toFixed(1)},${Y(p.viewers).toFixed(1)}`);
|
||||
svg += `<path class="area" d="M${X(tl.samples[0].at).toFixed(1)},${H - B} L${pts.join(' L')} L${X(tl.samples.at(-1).at).toFixed(1)},${H - B} Z"/>`;
|
||||
svg += `<polyline class="line" points="${pts.join(' ')}"/>`;
|
||||
for (const p of tl.samples) svg += `<circle class="dot hit" cx="${X(p.at).toFixed(1)}" cy="${Y(p.viewers).toFixed(1)}" r="6" data-tip="${time(p.at)} · ${p.viewers} viewers"/>`;
|
||||
}
|
||||
for (const c of tl.changes) {
|
||||
if (c.start) continue;
|
||||
const x = X(c.at).toFixed(1);
|
||||
svg += `<line class="mark" x1="${x}" x2="${x}" y1="${TOP}" y2="${H - B}"/><circle class="markdot hit" cx="${x}" cy="${TOP + 4}" r="5" data-tip="${time(c.at)} · ${esc(c.title || '')}${c.game ? ' · ' + esc(c.game) : ''}"/>`;
|
||||
}
|
||||
%>
|
||||
<h3 class="sb-h">Viewers</h3>
|
||||
<div class="sb-chart sb-timeline"><%- svg %></svg><div class="sb-tip"></div></div>
|
||||
<% if (!tl.samples.length) { %><p class="sb-note">No viewer counts were recorded for this stream.</p><% } %>
|
||||
<% if (tl.changes.length) { %>
|
||||
<ol class="sb-changes">
|
||||
<% for (const c of tl.changes) { %><li><span class="when"><%= c.start ? 'start' : time(c.at) %></span> <span><%= c.title || '—' %></span><% if (c.game) { %> <span class="game"><%= c.game %></span><% } %></li><% } %>
|
||||
</ol>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
<%
|
||||
// one activity chart, like Twitch's: pick what it shows
|
||||
const METRICS = [['messages', 'Chat messages', ''], ['watchHours', 'Hours watched', 'h'], ['streamHours', 'Hours streamed', 'h'],
|
||||
['avgViewers', 'Average viewers', ''], ['follows', 'New followers', '']];
|
||||
const rows = s.series ? s.series.rows : [];
|
||||
const shown = METRICS.filter(([k]) => rows.some(x => x[k]));
|
||||
%>
|
||||
<% if (rows.length && shown.length) { %>
|
||||
<h3 class="sb-h">Activity <span class="sb-sub">per <%= s.series.unit %></span></h3>
|
||||
<div class="sb-chart" id="sb-activity">
|
||||
<div class="sb-metrics"><% shown.forEach(([k, label], i) => { %><button type="button" data-k="<%= k %>" class="<%= i ? '' : 'on' %>"><%= label %></button><% }) %></div>
|
||||
<div class="plot"></div><div class="sb-tip"></div>
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
const rows = <%- JSON.stringify(rows.map(x => ({ label: x.label, messages: x.messages, watchHours: x.watchHours, streamHours: x.streamHours, avgViewers: x.avgViewers, follows: x.follows }))).replace(/</g, '\\u003c') %>;
|
||||
const units = <%- JSON.stringify(Object.fromEntries(METRICS.map(([k, l, u]) => [k, { label: l, unit: u }]))) %>;
|
||||
const box = document.getElementById('sb-activity'), plot = box.querySelector('.plot');
|
||||
const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
function draw(key) {
|
||||
const W = 900, H = 200, L = 38, B = 20, TOP = 8, n = rows.length, max = Math.max(1, ...rows.map(d => d[key] || 0));
|
||||
const p = Math.pow(10, Math.floor(Math.log10(max))), top = [1, 2, 2.5, 5, 10].map(m => m * p).find(x => x >= max);
|
||||
const slot = (W - L) / n, bw = Math.max(2, Math.min(slot - 2, 44)), pad = (slot - bw) / 2, y = x => TOP + (H - TOP - B) * (1 - x / top);
|
||||
const every = Math.ceil(n / 12);
|
||||
let out = `<svg viewBox="0 0 ${W} ${H}" role="img" aria-label="${esc(units[key].label)}">`;
|
||||
for (const g of [0, top / 2, top]) out += `<line class="grid" x1="${L}" x2="${W}" y1="${y(g)}" y2="${y(g)}"/><text class="ax" x="${L - 4}" y="${y(g) + 3}" text-anchor="end">${+g.toFixed(1)}</text>`;
|
||||
rows.forEach((d, i) => {
|
||||
const x = L + i * slot + pad, val = d[key] || 0, tp = y(val), h = (H - B) - tp, rr = Math.min(4, bw / 2, h);
|
||||
out += `<rect class="hit" x="${L + i * slot}" y="${TOP}" width="${slot}" height="${H - TOP - B}" fill="transparent" data-tip="${esc(d.label)} · ${val}${units[key].unit ? ' ' + units[key].unit : ''}"/>`;
|
||||
if (val > 0) out += `<path class="bar" d="M${x},${H - B} V${tp + rr} Q${x},${tp} ${x + rr},${tp} H${x + bw - rr} Q${x + bw},${tp} ${x + bw},${tp + rr} V${H - B} Z"/>`;
|
||||
if (i % every === 0) out += `<text class="ax" x="${x + bw / 2}" y="${H - 4}" text-anchor="middle">${esc(d.label)}</text>`;
|
||||
});
|
||||
plot.innerHTML = out + '</svg>';
|
||||
window.sbHoverTips && window.sbHoverTips(box);
|
||||
}
|
||||
box.querySelectorAll('.sb-metrics button').forEach(b => b.addEventListener('click', () => {
|
||||
box.querySelectorAll('.sb-metrics button').forEach(x => x.classList.toggle('on', x === b));
|
||||
draw(b.dataset.k);
|
||||
}));
|
||||
draw(box.querySelector('.sb-metrics button.on').dataset.k);
|
||||
})();
|
||||
</script>
|
||||
<% } %>
|
||||
|
||||
<%
|
||||
// games played: donut of streamed time per category (from HeyStreamer's title / category history)
|
||||
const PAL = ['#b74347', '#5b8fc7', '#d39b3a', '#4f9a68', '#8c6bb1', '#c76f9a', '#3fa3a1', '#9a8a5a'];
|
||||
const games = s.games || [];
|
||||
const totalMin = games.reduce((a, g) => a + g.minutes, 0);
|
||||
const slices = games.length > 8 ? [...games.slice(0, 7), { game: `${games.length - 7} more`, minutes: games.slice(7).reduce((a, g) => a + g.minutes, 0), other: true }] : games;
|
||||
%>
|
||||
<% if (r.p !== 'stream' || slices.length > 1) { %>
|
||||
<h3 class="sb-h">Games<%- info('Time per category, from every title / category change HeyStreamer saw. Twitch keeps no history of categories, so streams from before HeyStreamer recorded them have no game.') %></h3>
|
||||
<% if (!totalMin) { %><p class="sb-empty">no categories recorded in this period yet</p><% } else { %>
|
||||
<div class="sb-chart sb-games">
|
||||
<svg viewBox="-1 -1 2 2" role="img" aria-label="Time per game">
|
||||
<% let acc = 0; slices.forEach((g, i) => {
|
||||
const a0 = acc / totalMin * 2 * Math.PI, a1 = (acc + g.minutes) / totalMin * 2 * Math.PI; acc += g.minutes;
|
||||
const big = a1 - a0 > Math.PI ? 1 : 0, P = a => `${(Math.sin(a) * .95).toFixed(4)} ${(-Math.cos(a) * .95).toFixed(4)}`, Q = a => `${(Math.sin(a) * .55).toFixed(4)} ${(-Math.cos(a) * .55).toFixed(4)}`;
|
||||
const d = slices.length === 1 ? 'M0 -.95 A.95 .95 0 1 1 0 .95 A.95 .95 0 1 1 0 -.95 Z M0 -.55 A.55 .55 0 1 0 0 .55 A.55 .55 0 1 0 0 -.55 Z'
|
||||
: `M${P(a0)} A.95 .95 0 ${big} 1 ${P(a1)} L${Q(a1)} A.55 .55 0 ${big} 0 ${Q(a0)} Z`; %>
|
||||
<path d="<%= d %>" fill="<%= g.other ? '#8a8a8a' : PAL[i % PAL.length] %>" fill-rule="evenodd" stroke="var(--card-solid, #fff)" stroke-width=".02"><title><%= g.game %> · <%= hm(g.minutes) %></title></path>
|
||||
<% }) %>
|
||||
</svg>
|
||||
<ul>
|
||||
<% slices.forEach((g, i) => { %>
|
||||
<li><span class="sw" style="background:<%= g.other ? '#8a8a8a' : PAL[i % PAL.length] %>"></span><span class="nm" title="<%= g.game %>"><%= g.game %></span>
|
||||
<span class="hv"><%= hm(g.minutes) %> · <%= Math.round(g.minutes / totalMin * 100) %>%</span></li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
</div>
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
<% if (r.p !== 'stream' && s.streams.length) { %>
|
||||
<h3 class="sb-h"><%= r.p === 'all' ? 'Recent streams' : 'Streams' %></h3>
|
||||
<div class="sb-scroll"><table class="sb-streams">
|
||||
<thead><tr><th>Date</th><th>Title · games</th><th style="text-align:right">Length</th><th style="text-align:right">Peak</th><th style="text-align:right">Viewers</th><th style="text-align:right">Chatters</th><th style="text-align:right">Messages</th></tr></thead>
|
||||
<tbody>
|
||||
<% for (const x of s.streams.slice(0, r.p === 'all' ? 15 : 100)) { %>
|
||||
<tr>
|
||||
<td style="white-space:nowrap"><a href="<%= link({ p: 'stream', s: x.id }) %>"><%= day(x.started_at) %></a><%= x.live ? ' · live' : '' %><% if (x.source === 'vod') { %> <span class="sb-vod" title="Known from the Twitch VOD only: HeyStreamer was not counting during this stream">VOD</span><% } %></td>
|
||||
<td><span class="t" title="<%= x.title %>"><%= x.title || '—' %></span><% if (x.games.length) { %><span class="g"><%= x.games.join(' · ') %></span><% } %></td>
|
||||
<td class="n"><%= hm(x.minutes) %></td><td class="n"><%= x.peak != null ? num(x.peak) : '—' %></td>
|
||||
<td class="n"><%= num(x.viewers) %></td><td class="n"><%= num(x.chatters) %></td><td class="n"><%= num(x.messages) %></td>
|
||||
</tr>
|
||||
<% } %>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<% } %>
|
||||
|
||||
<% } else { %>
|
||||
<%# ===================== COMMUNITY ===================== %>
|
||||
<% const cm = s.community || {}; %>
|
||||
<% if ((cm.supporters || []).length) { %>
|
||||
<h3 class="sb-h">Thank you for the support</h3>
|
||||
<div class="sb-pills">
|
||||
<% for (const x of cm.supporters.slice(0, 40)) {
|
||||
const what = [x.bits ? `${num(x.bits)} bits` : '', x.subs ? (x.subs === 1 ? 'sub' : `${x.subs} subs`) : '', x.gifts ? `${num(x.gifts)} gifted` : '', admin && x.tips ? 'tip' : ''].filter(Boolean).join(' · '); %>
|
||||
<span class="sb-pill txt"><%- person(x) %> <span class="what"><%= what %></span></span>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if ((cm.raiders || []).length) { %>
|
||||
<h3 class="sb-h">Raids</h3>
|
||||
<div class="sb-pills"><% for (const x of cm.raiders) { %><span class="sb-pill txt"><%- person(x) %> <span class="what"><%= x.raids > 1 ? `${x.raids} raids · ` : '' %><%= num(x.viewers) %> viewers</span></span><% } %></div>
|
||||
<% } %>
|
||||
|
||||
<%
|
||||
const board = b => {
|
||||
const nw = b.nw ? ` style="--nw:${b.nw}"` : '';
|
||||
let out = `<div class="sb-board${b.wide ? ' wide' : ''}"${nw}><h4>${esc(b.title)}</h4>`;
|
||||
if (!b.rows.length) return out + '<p class="sb-empty">nothing yet</p></div>';
|
||||
out += '<ol>';
|
||||
b.rows.forEach((x, i) => {
|
||||
out += `<li><span class="r">${i + 1}</span><span class="who" title="${esc(x.name || x.login)}">${person(x)}</span>${b.level ? `<span class="lvl">${esc(b.level(x))}</span>` : ''}<span class="n">${(b.fmt || num)(x.n)}</span></li>`;
|
||||
});
|
||||
return out + '</ol></div>';
|
||||
};
|
||||
const boards = [
|
||||
...(locals.extraBoards || []),
|
||||
{ title: 'Most active in chat', rows: s.boards.chat },
|
||||
{ title: 'Watch time', rows: s.boards.watch, fmt: hm, nw: '6.4rem' },
|
||||
{ title: 'Channel points spent', rows: s.boards.channelPoints, optional: true },
|
||||
...(admin ? [{ title: 'Bits', rows: s.boards.bits, optional: true }, { title: 'Subs and gifts', rows: s.boards.subs, optional: true }] : []),
|
||||
].filter(b => !(b.optional && !b.rows.length));
|
||||
%>
|
||||
<h3 class="sb-h">Leaderboards</h3>
|
||||
<div class="sb-boards"><% for (const b of boards) { %><%- board(b) %><% } %></div>
|
||||
|
||||
<% if ((locals.ranks || []).length) {
|
||||
const LV = ['Veteran', 'Loyal', 'Regular']; %>
|
||||
<h3 class="sb-h">Community ranks<%- info('Levels by total watch time: Regular from 50 h, Loyal from 200 h, Veteran from 1000 h. All time.') %></h3>
|
||||
<div class="sb-ranks">
|
||||
<% for (const lv of LV) { const list = ranks.filter(x => x.level === lv); if (!list.length) continue; %>
|
||||
<div class="sb-rank"><h4><%= lv %> <span class="sb-sub"><%= list.length %></span></h4>
|
||||
<div class="sb-pills"><% for (const x of list) { %><span class="sb-pill txt"><%- person(x) %></span><% } %></div></div>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (s.channelEmotes && s.channelEmotes.length) { %>
|
||||
<h3 class="sb-h">Channel emotes<%- info('The channel\'s own emotes and how often they were used in this chat in this period. Twitch does not tell how often they are used in other channels.') %></h3>
|
||||
<div class="sb-pills">
|
||||
<% for (const e of s.channelEmotes) { %>
|
||||
<span class="sb-pill<%= e.uses ? '' : ' zero' %>" title="<%= e.name %><%= e.tier ? ` · Tier ${String(e.tier).slice(0, 1)}` : '' %><%= e.type === 'follower' ? ' · follower emote' : e.type === 'bitstier' ? ' · bits emote' : '' %><%= e.gone ? ' · removed from the channel' : '' %>"><% if (e.image) { %><img src="<%= e.image %>" alt="" loading="lazy"><% } %><%= e.name %> <strong><%= num(e.uses) %></strong></span>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<h3 class="sb-h">Top emotes</h3>
|
||||
<% if (!s.emotes.length) { %><p class="sb-empty">nothing yet</p><% } else { %>
|
||||
<div class="sb-pills">
|
||||
<% for (const e of s.emotes) { const src = emoteSrc(e); %>
|
||||
<span class="sb-pill" title="<%= e.emote %><%= e.source ? ` · ${e.source === '7tv' ? '7TV' : 'Twitch'}` : '' %>"><% if (src) { %><img src="<%= src %>" alt="" loading="lazy"><% } %><%= e.emote %> <strong><%= num(e.uses) %></strong></span>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (s.commands.length) { %>
|
||||
<h3 class="sb-h">Top commands</h3>
|
||||
<div class="sb-pills"><% for (const c of s.commands) { %><span class="sb-pill txt"><code><%= c.command %></code> <strong><%= num(c.uses) %></strong></span><% } %></div>
|
||||
<% } %>
|
||||
|
||||
<% if (s.rewards.length) { %>
|
||||
<h3 class="sb-h">Rewards and Power-ups</h3>
|
||||
<div class="sb-pills"><% for (const x of s.rewards) { %><span class="sb-pill txt"><%= x.item %> <strong><%= num(x.uses) %></strong></span><% } %></div>
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
<script>
|
||||
// chart hover tooltips (bars, viewer dots, title-change markers)
|
||||
window.sbHoverTips = function (scope) {
|
||||
(scope ? [scope] : document.querySelectorAll('.sb-chart')).forEach(ch => {
|
||||
const tip = ch.querySelector('.sb-tip');
|
||||
if (!tip) return;
|
||||
ch.querySelectorAll('.hit').forEach(h => {
|
||||
h.addEventListener('mouseenter', () => { tip.textContent = h.dataset.tip; tip.style.display = 'block'; });
|
||||
h.addEventListener('mousemove', e => { const r = ch.getBoundingClientRect(); tip.style.left = (e.clientX - r.left + 12) + 'px'; tip.style.top = (e.clientY - r.top - 28) + 'px'; });
|
||||
h.addEventListener('mouseleave', () => { tip.style.display = 'none'; });
|
||||
});
|
||||
});
|
||||
};
|
||||
window.sbHoverTips();
|
||||
</script>
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
<h2>Actions</h2>
|
||||
<p><small>Map Twitch events to sounds, videos, or on-screen alerts.</small></p>
|
||||
|
||||
<details>
|
||||
<summary>Add new action</summary>
|
||||
<form method="POST" action="/actions" style="margin-top:1rem;">
|
||||
<div style="display:grid; grid-template-columns:1fr 1fr; gap:1rem;">
|
||||
<label>Name <input type="text" name="name" required placeholder="e.g. Sub sound"></label>
|
||||
<label>
|
||||
Event type
|
||||
<select name="event_type" required>
|
||||
<option value="sub">Sub</option>
|
||||
<option value="gift_sub">Gift sub</option>
|
||||
<option value="bits">Bits</option>
|
||||
<option value="channel_points">Channel points</option>
|
||||
<option value="command">Chat command</option>
|
||||
<option value="follow">Follow</option>
|
||||
<option value="raid">Raid</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Event detail <small>(tier / min bits / command name / reward ID)</small>
|
||||
<input type="text" name="event_detail" placeholder="Optional">
|
||||
</label>
|
||||
<label>
|
||||
Action type
|
||||
<select name="action_type" required>
|
||||
<option value="sound">Sound</option>
|
||||
<option value="video">Video</option>
|
||||
<option value="alert">Alert text</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Media file
|
||||
<select name="media_file_id">
|
||||
<option value="">— none —</option>
|
||||
<% for (const f of media) { %>
|
||||
<option value="<%= f.id %>"><%= f.original_name %> (<%= f.media_type %>)</option>
|
||||
<% } %>
|
||||
</select>
|
||||
</label>
|
||||
<label>Alert text <input type="text" name="alert_text" placeholder="{username} just subbed!"></label>
|
||||
<label>Cooldown (seconds) <input type="number" name="cooldown_seconds" value="0" min="0"></label>
|
||||
</div>
|
||||
<button type="submit">Add action</button>
|
||||
</form>
|
||||
</details>
|
||||
|
||||
<% if (actions.length === 0) { %>
|
||||
<p><em>No actions yet.</em></p>
|
||||
<% } else { %>
|
||||
<figure>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Event</th>
|
||||
<th>Detail</th>
|
||||
<th>Action</th>
|
||||
<th>Cooldown</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% for (const a of actions) { %>
|
||||
<tr>
|
||||
<td><%= a.name %></td>
|
||||
<td><code><%= a.event_type %></code></td>
|
||||
<td><%= a.event_detail || '—' %></td>
|
||||
<td><code><%= a.action_type %></code></td>
|
||||
<td><%= a.cooldown_seconds %>s</td>
|
||||
<td>
|
||||
<span class="badge <%= a.enabled ? 'badge-green' : 'badge-grey' %>">
|
||||
<%= a.enabled ? 'on' : 'off' %>
|
||||
</span>
|
||||
</td>
|
||||
<td style="display:flex; gap:0.5rem;">
|
||||
<form method="POST" action="/actions/<%= a.id %>/test"><button type="submit" class="outline" style="padding:0.2rem 0.6rem; font-size:0.8rem;">Test</button></form>
|
||||
<form method="POST" action="/actions/<%= a.id %>/toggle"><button type="submit" class="outline" style="padding:0.2rem 0.6rem; font-size:0.8rem;"><%= a.enabled ? 'Disable' : 'Enable' %></button></form>
|
||||
<form method="POST" action="/actions/<%= a.id %>/delete"><button type="button" data-confirm class="outline" style="padding:0.2rem 0.6rem; font-size:0.8rem; color:#f88;">Delete</button></form>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
</tbody>
|
||||
</table>
|
||||
</figure>
|
||||
<% } %>
|
||||
133
views/alerts_preview.ejs
Normal file
133
views/alerts_preview.ejs
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
<!doctype html>
|
||||
<%#
|
||||
Alert preview: the real overlay code on a 1920x1080 stage, with a button for every alert. Served at
|
||||
/actions/alerts/preview (logged in) and exported as a static page by tools/export-preview.js.
|
||||
Locals: base ('/alerts/' or 'alerts/'), themes { key: { label, theme } }, start (theme key), samples (src/alerts.js SAMPLES).
|
||||
%>
|
||||
<html lang="en"><head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Alert preview</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Caveat:wght@700&family=Nunito:wght@700;800;900&display=block">
|
||||
<% for (const f of ['card', 'polaroid', 'cassette', 'fx']) { %><link rel="stylesheet" href="<%= base %><%= f %>.css"><% } %>
|
||||
<style>
|
||||
* { box-sizing:border-box; }
|
||||
html, body { margin:0; height:100%; background:#101014; color:#f1edf7; font-family:'Nunito', system-ui, sans-serif; }
|
||||
.wrap { display:grid; grid-template-columns:minmax(0, 1fr) 380px; height:100vh; }
|
||||
@media (max-width: 1000px) { .wrap { grid-template-columns:1fr; height:auto; } }
|
||||
.viewport { position:relative; overflow:hidden; display:grid; place-items:center; padding:16px; }
|
||||
.stage-box { position:relative; width:100%; aspect-ratio:16 / 9; max-height:calc(100vh - 32px); }
|
||||
#stage { position:absolute; left:0; top:0; width:1920px; height:1080px; transform-origin:0 0; overflow:hidden; border-radius:10px;
|
||||
background:var(--bg); box-shadow:0 10px 40px rgba(0,0,0,.5); }
|
||||
/* the alert elements are position:fixed in the overlay; inside the scaled stage they must follow the stage */
|
||||
#stage { contain:layout paint; transform-style:flat; }
|
||||
.bg-game { --bg:radial-gradient(1200px 700px at 30% 40%, #3a5f4f, #16261f 70%), #16261f; }
|
||||
.bg-dark { --bg:#1b1b22; }
|
||||
.bg-light { --bg:#e9e6ef; }
|
||||
.bg-check { --bg:repeating-conic-gradient(#2a2a33 0 25%, #22222a 0 50%) 0 0 / 40px 40px; }
|
||||
.scene { position:absolute; inset:0; pointer-events:none; }
|
||||
.scene .cam { position:absolute; right:60px; bottom:60px; width:480px; height:270px; border-radius:18px; background:rgba(255,255,255,.08);
|
||||
border:2px dashed rgba(255,255,255,.18); display:grid; place-items:center; color:rgba(255,255,255,.35); font:800 26px Nunito; }
|
||||
.panel { overflow:auto; background:#191720; border-left:1px solid #2b2836; padding:16px 18px 30px; }
|
||||
.panel h1 { font-size:20px; margin:0 0 4px; }
|
||||
.note { font-size:13px; color:#b9b0cc; margin:0 0 10px; line-height:1.4; }
|
||||
h3 { font-size:12px; letter-spacing:.12em; color:#b9a3ec; margin:16px 0 7px; text-transform:uppercase; }
|
||||
.row { display:flex; flex-wrap:wrap; gap:6px; }
|
||||
button { font:800 13px 'Nunito'; border:0; border-radius:14px; padding:6px 12px; cursor:pointer; background:#2c2838; color:#f1edf7; }
|
||||
button:hover { background:#3b3550; }
|
||||
button.on { background:#9146ff; color:#fff; }
|
||||
button.alt { background:#efe6ff; color:#2a1d40; }
|
||||
.colors { display:flex; gap:12px; flex-wrap:wrap; font-size:13px; align-items:center; }
|
||||
.colors label { display:flex; gap:6px; align-items:center; }
|
||||
.colors input { width:34px; height:26px; border:0; padding:0; background:none; }
|
||||
#log { font:700 12px monospace; color:#c9ffd8; margin-top:14px; min-height:1.2em; }
|
||||
</style></head><body>
|
||||
<div class="wrap">
|
||||
<div class="viewport"><div class="stage-box" id="box"><div id="stage" class="bg-game"><div class="scene"><div class="cam">camera</div></div></div></div></div>
|
||||
<div class="panel">
|
||||
<h1>Alert preview</h1>
|
||||
<p class="note">The real overlay code. Click a button to play an alert; a click replaces the one showing. Click anywhere once first so the browser allows sound.</p>
|
||||
|
||||
<h3>Look</h3>
|
||||
<div class="row" id="themes"><% for (const [k, t] of Object.entries(themes)) { %><button data-theme="<%= k %>"><%= t.label %></button><% } %></div>
|
||||
<div class="row" style="margin-top:6px;" id="styles">
|
||||
<button data-style="card">Alerts: Card</button><button data-style="polaroid">Alerts: Polaroid</button>
|
||||
</div>
|
||||
<div class="colors" style="margin-top:8px;">
|
||||
<label><input type="color" data-c="accent"> accent</label><label><input type="color" data-c="bg"> card</label><label><input type="color" data-c="text"> text</label>
|
||||
</div>
|
||||
|
||||
<h3>Background</h3>
|
||||
<div class="row" id="bgs"><button data-bg="bg-game" class="on">Game</button><button data-bg="bg-dark">Dark</button><button data-bg="bg-light">Light</button><button data-bg="bg-check">Transparent</button></div>
|
||||
|
||||
<h3>Follows and subs</h3>
|
||||
<div class="row"><% for (const [k, l] of [['follow', 'Follow'], ['sub-new', 'New sub'], ['sub-prime', 'Prime'], ['sub-resub', 'Resub 14 months'], ['sub-6', '6 months at once'], ['gift-1', 'Gift 1'], ['gift-10', 'Gift 10'], ['gift-anon', 'Anonymous gift']]) { %><button data-k="<%= k %>"><%= l %></button><% } %></div>
|
||||
<h3>Bits, tips, raids</h3>
|
||||
<div class="row"><% for (const [k, l] of [['bits-20', '20 bits'], ['bits-120', '120 bits'], ['bits-500', '500 bits'], ['tip-5', 'Tip 5'], ['tip-100', 'Tip 100'], ['raid', 'Raid'], ['streak', 'Watch streak']]) { %><button data-k="<%= k %>"><%= l %></button><% } %></div>
|
||||
<h3>Hype Train</h3>
|
||||
<div class="row"><% for (const [k, l] of [['hype-begin', 'Start'], ['hype-level', 'Level up'], ['hype-end', 'End'], ['hype-golden', 'Golden Kappa']]) { %><button data-k="<%= k %>"><%= l %></button><% } %></div>
|
||||
<h3>Redeems</h3>
|
||||
<div class="row">
|
||||
<button data-r="card">Card</button><button data-r="cassette">Cassette</button><button data-r="cassette-rare">Cassette rare</button><button data-r="cassette-ultra">Cassette ultra rare</button>
|
||||
<button data-r="tts">Read aloud</button><button data-r="message">Highlight message</button><button data-r="emote">Gigantify emote</button><button data-r="rain">Celebration</button>
|
||||
</div>
|
||||
<h3>Queue</h3>
|
||||
<div class="row"><button data-queue class="alt">4 alerts at once</button><button data-reset>Stop</button></div>
|
||||
<div id="log">ready</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.ALERTS_BASE = <%- JSON.stringify(base) %>;
|
||||
const THEMES = <%- JSON.stringify(Object.fromEntries(Object.entries(themes).map(([k, t]) => [k, t.theme]))).replace(/</g, '\\u003c') %>;
|
||||
window.S = { alert_theme: JSON.parse(JSON.stringify(THEMES[<%- JSON.stringify(start) %>])) };
|
||||
</script>
|
||||
<% for (const f of ['card', 'cassette', 'fx', 'polaroid']) { %><script src="<%= base %><%= f %>.js"></script><% } %>
|
||||
<script>
|
||||
const SAMPLES = <%- JSON.stringify(samples).replace(/</g, '\\u003c') %>;
|
||||
const REDEEMS = {
|
||||
card: { style: 'card', user: 'LurkingLynx', reward: 'Hydrate!', variation: 'Water break', rarity: 'common', caption: 'redeemed it! ♡' },
|
||||
cassette: { style: 'cassette', user: 'PixelPotato', reward: 'Posture check', variation: 'Sit up straight', rarity: 'common', caption: 'redeemed it! ♡' },
|
||||
'cassette-rare': { style: 'cassette', user: 'ChickenWhisperer', reward: 'Random sound', variation: 'Chicken dance', rarity: 'rare', caption: 'redeemed it! ♡' },
|
||||
'cassette-ultra': { style: 'cassette', user: 'BobTheBuilder99', reward: 'Random sound', variation: 'The legendary one', rarity: 'ultra_rare', caption: 'redeemed it! ♡' },
|
||||
tts: { style: 'tts', user: 'Chatty', reward: 'Read my message', variation: 'Robot voice', caption: 'says:', input: 'hello there streamer, that was a very nice shot and I was totally not camping that corner' },
|
||||
message: { style: 'message', user: 'PixelPotato', reward: 'Highlight my message', caption: 'highlighted:', input: 'this stream is the coziest place on the internet' },
|
||||
emote: { style: 'emote', user: 'LurkingLynx', reward: 'Gigantify an Emote', caption: 'gigantified an emote!', emote: 'https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/3.0' },
|
||||
rain: { style: 'emote_rain', user: 'BobTheBuilder99', reward: 'On-Screen Celebration', caption: 'is celebrating!', emote: 'https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/3.0' },
|
||||
};
|
||||
const log = t => { document.getElementById('log').textContent = t; };
|
||||
|
||||
// scale the 1920x1080 stage to its box; fixed-position alerts are kept inside it by moving them into the stage
|
||||
const stage = document.getElementById('stage'), box = document.getElementById('box');
|
||||
const fit = () => { stage.style.transform = `scale(${box.clientWidth / 1920})`; };
|
||||
new ResizeObserver(fit).observe(box); fit();
|
||||
new MutationObserver(() => {
|
||||
for (const id of ['card-alert', 'polaroid-alert', 'cassette-alert', 'fx-alert']) {
|
||||
const el = document.getElementById(id);
|
||||
if (el && el.parentElement !== stage) stage.appendChild(el);
|
||||
}
|
||||
}).observe(document.body, { childList: true });
|
||||
|
||||
const mark = (sel, attr, v) => document.querySelectorAll(sel).forEach(b => b.classList.toggle('on', b.dataset[attr] === v));
|
||||
function useTheme(k) {
|
||||
window.S.alert_theme = JSON.parse(JSON.stringify(THEMES[k]));
|
||||
mark('#themes button', 'theme', k); mark('#styles button', 'style', window.S.alert_theme.style);
|
||||
document.querySelectorAll('[data-c]').forEach(i => { i.value = window.S.alert_theme.card[i.dataset.c]; });
|
||||
PolaroidAlerts.reset(); log('look: ' + document.querySelector(`[data-theme="${k}"]`).textContent);
|
||||
}
|
||||
document.querySelectorAll('[data-theme]').forEach(b => b.addEventListener('click', () => useTheme(b.dataset.theme)));
|
||||
document.querySelectorAll('[data-style]').forEach(b => b.addEventListener('click', () => { window.S.alert_theme.style = b.dataset.style; mark('#styles button', 'style', b.dataset.style); }));
|
||||
document.querySelectorAll('[data-c]').forEach(i => i.addEventListener('input', () => { window.S.alert_theme.card[i.dataset.c] = i.value; }));
|
||||
document.querySelectorAll('[data-bg]').forEach(b => b.addEventListener('click', () => { stage.className = b.dataset.bg; mark('#bgs button', 'bg', b.dataset.bg); }));
|
||||
document.querySelectorAll('[data-k]').forEach(b => b.addEventListener('click', () => { PolaroidAlerts.playTest({ ...SAMPLES[b.dataset.k], test: true }); log(b.textContent); }));
|
||||
document.querySelectorAll('[data-r]').forEach(b => b.addEventListener('click', () => {
|
||||
const r = REDEEMS[b.dataset.r];
|
||||
PolaroidAlerts.playTest({ type: 'redeem', kind: 'reward', key: 'preview', volume: .8, polaroid: true, test: true, ...r }); log('redeem: ' + b.textContent);
|
||||
}));
|
||||
document.querySelector('[data-queue]').addEventListener('click', () => {
|
||||
PolaroidAlerts.reset(); ['follow', 'bits-120', 'gift-10', 'hype-level'].forEach(k => PolaroidAlerts.play(SAMPLES[k]));
|
||||
log('queued: follow, 120 bits, gift 10, hype level');
|
||||
});
|
||||
document.querySelector('[data-reset]').addEventListener('click', () => { PolaroidAlerts.reset(); log('stopped'); });
|
||||
useTheme(<%- JSON.stringify(start) %>);
|
||||
</script>
|
||||
</body></html>
|
||||
233
views/alerts_setup.ejs
Normal file
233
views/alerts_setup.ejs
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
<% const J = x => JSON.stringify(x).replace(/</g, '\\u003c'); %>
|
||||
<style>
|
||||
.al-grid { display:grid; grid-template-columns:minmax(150px, 200px) minmax(0, 1fr) minmax(0, 1fr) auto; gap:.5rem 1rem; align-items:center; }
|
||||
.al-grid .hd { font-size:.75rem; color:var(--pico-muted-color); text-transform:uppercase; letter-spacing:.06em; }
|
||||
.al-grid select { margin:0; font-size:.88rem; padding:.3rem .5rem; height:auto; }
|
||||
.al-name { font-weight:600; font-size:.92rem; }
|
||||
.al-name small { display:block; font-weight:400; color:var(--pico-muted-color); font-size:.78rem; }
|
||||
.pk { display:flex; align-items:center; gap:.4rem; }
|
||||
.pk img { width:34px; height:34px; object-fit:contain; border-radius:6px; background:rgba(255,255,255,.06); flex:none; }
|
||||
.pk img[src=""] { visibility:hidden; }
|
||||
.pk button, .btn-xs { width:auto; margin:0; padding:.2rem .55rem; font-size:.78rem; }
|
||||
@media (max-width: 900px) { .al-grid { grid-template-columns:1fr 1fr; } .al-grid .hd { display:none; } }
|
||||
.set-row > .seg { justify-self:start; }
|
||||
.set-row.stack { grid-template-columns:1fr; }
|
||||
.tiers .pk select { min-width:200px; }
|
||||
.seg { display:inline-flex; border:1px solid var(--pico-muted-border-color); border-radius:8px; overflow:hidden; }
|
||||
.seg label { margin:0; padding:.35rem .9rem; cursor:pointer; font-size:.88rem; border-left:1px solid var(--pico-muted-border-color); }
|
||||
.seg label:first-child { border-left:0; }
|
||||
.seg input { display:none; }
|
||||
.seg label:has(input:checked) { background:var(--pico-primary-background); color:#fff; }
|
||||
.tiers { width:100%; font-size:.86rem; }
|
||||
.tiers td, .tiers th { padding:.3rem .4rem; vertical-align:middle; }
|
||||
.tiers input, .tiers select { margin:0; padding:.25rem .4rem; font-size:.85rem; height:auto; }
|
||||
.savebar-al { position:sticky; bottom:0; display:flex; gap:.8rem; align-items:center; padding:.7rem 0; background:var(--pico-background-color);
|
||||
border-top:1px solid var(--pico-muted-border-color); z-index:5; }
|
||||
.savebar-al button { width:auto; margin:0; }
|
||||
.dirty { color:#e6b800; font-weight:600; }
|
||||
.backs { display:flex; flex-wrap:wrap; gap:.4rem; align-items:center; }
|
||||
.backs .b { display:flex; align-items:center; gap:.2rem; border:1px solid var(--pico-muted-border-color); border-radius:8px; padding:.15rem .3rem; }
|
||||
.backs .b img { width:30px; height:30px; object-fit:contain; }
|
||||
.colors { display:flex; gap:1rem; flex-wrap:wrap; align-items:center; }
|
||||
.colors label { display:flex; gap:.4rem; align-items:center; margin:0; font-size:.88rem; }
|
||||
.colors input[type=color] { width:2.6rem; height:2rem; padding:0; margin:0; }
|
||||
.hint { color:var(--pico-muted-color); font-size:.8rem; }
|
||||
</style>
|
||||
|
||||
<h2 class="set-h">Alerts</h2>
|
||||
<p class="set-intro"><a href="/actions/alerts/preview" target="_blank" rel="noopener" style="float:right; margin-left:1rem;">Open the preview ↗</a>What follows, subs, gifts, raids, bits, tips and the Hype Train look and sound like. Pictures and sounds come from
|
||||
<a href="/media">Media</a> (upload your own there). Changes reach OBS as soon as you save; use Test to see them.</p>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Style</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Alerts<small>Follows, subs, gifts, raids, bits, tips, Hype Train.</small></div>
|
||||
<span class="seg"><% for (const [v, l] of [['card', 'Card'], ['polaroid', 'Polaroid']]) { %><label><input type="radio" name="style" value="<%= v %>"><%= l %></label><% } %></span>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">New redeem variations<small>Look of variations you add on Redeems (each variation can still be changed there).</small></div>
|
||||
<span class="seg"><% for (const [v, l] of [['card', 'Card'], ['cassette', 'Cassette']]) { %><label><input type="radio" name="redeemStyle" value="<%= v %>"><%= l %></label><% } %></span>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Read-aloud redeems<small>Variations with a TTS voice.</small></div>
|
||||
<span class="seg"><% for (const [v, l] of [['card', 'Card'], ['letter', 'Letter']]) { %><label><input type="radio" name="ttsStyle" value="<%= v %>"><%= l %></label><% } %></span>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Card colours</div>
|
||||
<div class="colors">
|
||||
<label><input type="color" data-k="card.accent"> accent</label>
|
||||
<label><input type="color" data-k="card.bg"> background</label>
|
||||
<label><input type="color" data-k="card.text"> text</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Volume<small>Alert sounds (a bits tier can have its own).</small></div>
|
||||
<div class="set-inline"><input type="range" min="0" max="1" step="0.05" data-k="volume" style="max-width:240px;"><span id="vol-out" class="hint"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Events</h3>
|
||||
<div class="al-grid" id="events">
|
||||
<span class="hd">Event</span><span class="hd">Picture</span><span class="hd">Sound</span><span class="hd"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Bits</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">No alert under</div>
|
||||
<div class="set-inline"><input type="number" min="1" data-k="bitsMin" style="max-width:7rem;"> <span class="hint">bits</span></div>
|
||||
</div>
|
||||
<div class="set-row stack">
|
||||
<div class="lbl">Tiers<small>The highest tier the cheer reaches is used.</small></div>
|
||||
<div>
|
||||
<div style="overflow-x:auto;"><table class="tiers"><thead><tr><th>From</th><th>Picture</th><th>Sound</th><th>Volume</th><th>Badge</th><th>Hearts</th><th></th></tr></thead><tbody id="tiers"></tbody></table></div>
|
||||
<div class="set-inline"><button type="button" class="outline btn-xs" id="tier-add">+ Add tier</button>
|
||||
<button type="button" class="outline btn-xs" data-test="bits-120">Test 120 bits</button><button type="button" class="outline btn-xs" data-test="bits-500">Test 500 bits</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Extras</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Corner sticker<small>Polaroid: sticker on the photo's corner (and the extra ones for big alerts).</small></div>
|
||||
<div class="pk" data-pick="heart" data-type="image"></div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Photos behind<small>Polaroid: photos fanned out behind multi-month subs, gift bombs and raids.</small></div>
|
||||
<div class="backs" id="backs"></div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Raid send-off picture<small>When the raided channel has no picture.</small></div>
|
||||
<div class="pk" data-pick="raidFallback" data-type="image"></div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Default redeem sticker<small>Card and Cassette redeems whose variation has no picture.</small></div>
|
||||
<div class="pk" data-pick="defaultSticker" data-type="image"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="savebar-al">
|
||||
<button type="button" id="save">Save</button>
|
||||
<span id="state" class="hint">No changes</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(() => {
|
||||
let T = <%- J(theme) %>;
|
||||
const IMAGES = <%- J(images.map(m => ({ url: m.url, label: m.label }))) %>;
|
||||
const SOUNDS = <%- J(sounds.map(m => ({ url: m.url, label: m.label }))) %>;
|
||||
const EVENTS = [
|
||||
['follow', 'Follow', '', 'follow', 'follow'], ['sub', 'New sub', '', 'sub', 'sub-new'], ['resub', 'Resub', 'sound: same as New sub', null, 'sub-resub'],
|
||||
['prime', 'Prime sub', 'sound: same as New sub', null, 'sub-prime'], ['gift', 'Gift subs', '', 'gift', 'gift-10'],
|
||||
['streak', 'Watch streak', '', 'streak', 'streak'], ['raid', 'Raid', '', 'raid', 'raid'], ['tip', 'Tip', 'StreamElements', 'tip', 'tip-25'],
|
||||
['hype', 'Hype Train', 'start sound', 'hypeBegin', 'hype-begin'],
|
||||
[null, 'Hype Train level up', '', 'hypeLevel', 'hype-level'], [null, 'Hype Train end', '', 'hypeEnd', 'hype-end'],
|
||||
];
|
||||
const esc = s => String(s ?? '').replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
const get = k => k.split('.').reduce((o, p) => o?.[p], T);
|
||||
const set = (k, v) => { const ps = k.split('.'); let o = T; ps.slice(0, -1).forEach(p => { o = o[p] = o[p] || {}; }); o[ps.at(-1)] = v; dirty(); };
|
||||
const state = document.getElementById('state');
|
||||
const dirty = () => { state.textContent = 'Unsaved changes'; state.className = 'dirty'; };
|
||||
|
||||
// a picker: select from the media library (+ thumbnail / play button); onChange(url)
|
||||
let audio = null;
|
||||
function picker(type, value, onChange) {
|
||||
const list = type === 'image' ? IMAGES : SOUNDS;
|
||||
const w = document.createElement('span'); w.className = 'pk';
|
||||
const opts = ['<option value="">— none —</option>', ...list.map(m => `<option value="${esc(m.url)}">${esc(m.label)}</option>`)];
|
||||
if (value && !list.some(m => m.url === value)) opts.push(`<option value="${esc(value)}">${esc(value.split('/').pop())} (missing)</option>`);
|
||||
w.innerHTML = (type === 'image' ? `<img src="${esc(value || '')}" alt="">` : '') + `<select>${opts.join('')}</select>` + (type === 'audio' ? '<button type="button" class="outline" title="Play">▶</button>' : '');
|
||||
const sel = w.querySelector('select'); sel.value = value || '';
|
||||
sel.addEventListener('change', () => { if (type === 'image') w.querySelector('img').src = sel.value; onChange(sel.value); });
|
||||
if (type === 'audio') w.querySelector('button').addEventListener('click', () => { audio?.pause(); if (sel.value) { audio = new Audio(sel.value); audio.volume = T.volume ?? .8; audio.play(); } });
|
||||
return w;
|
||||
}
|
||||
const testBtn = key => { const b = document.createElement('button'); b.type = 'button'; b.className = 'outline btn-xs'; b.textContent = 'Test'; b.dataset.test = key; return b; };
|
||||
|
||||
function render() {
|
||||
// style radios, colours, numbers
|
||||
for (const n of ['style', 'redeemStyle', 'ttsStyle']) document.querySelectorAll(`input[name=${n}]`).forEach(r => { r.checked = r.value === T[n]; });
|
||||
document.querySelectorAll('[data-k]').forEach(i => { i.value = get(i.dataset.k) ?? ''; });
|
||||
document.getElementById('vol-out').textContent = Math.round((T.volume ?? .8) * 100) + '%';
|
||||
// events grid
|
||||
const g = document.getElementById('events');
|
||||
g.querySelectorAll(':scope > :not(.hd)').forEach(x => x.remove());
|
||||
for (const [artKey, label, sub, soundKey, test] of EVENTS) {
|
||||
const name = document.createElement('div'); name.className = 'al-name'; name.innerHTML = esc(label) + (sub ? `<small>${esc(sub)}</small>` : '');
|
||||
g.append(name,
|
||||
artKey ? picker('image', T.art[artKey], v => { T.art[artKey] = v; dirty(); }) : document.createElement('span'),
|
||||
soundKey ? picker('audio', T.sounds[soundKey], v => { T.sounds[soundKey] = v; dirty(); }) : Object.assign(document.createElement('span'), { className: 'hint', textContent: '' }),
|
||||
testBtn(test));
|
||||
}
|
||||
// bits tiers
|
||||
const tb = document.getElementById('tiers'); tb.innerHTML = '';
|
||||
T.bitsTiers.forEach((t, i) => {
|
||||
const tr = document.createElement('tr');
|
||||
tr.innerHTML = `<td><input type="number" min="1" value="${t.min}" style="width:6rem"></td><td></td><td></td>
|
||||
<td><input type="number" min="0" max="1" step="0.05" value="${t.volume ?? ''}" placeholder="default" style="width:6rem"></td>
|
||||
<td><input type="color" value="${esc(t.badge || '#8a8aa8')}" style="width:2.4rem; height:1.8rem; padding:0"></td>
|
||||
<td><select style="width:4rem">${[0, 1, 2, 3].map(h => `<option ${h === t.hearts ? 'selected' : ''}>${h}</option>`).join('')}</select></td>
|
||||
<td><button type="button" class="outline btn-xs" title="Remove tier">✕</button></td>`;
|
||||
tr.children[1].append(picker('image', t.art, v => { t.art = v; dirty(); }));
|
||||
tr.children[2].append(picker('audio', t.sound, v => { t.sound = v; dirty(); }));
|
||||
const [min, , , vol, badge, hearts] = [...tr.children].map(td => td.querySelector('input, select'));
|
||||
min.addEventListener('input', () => { t.min = +min.value || 1; dirty(); });
|
||||
vol.addEventListener('input', () => { t.volume = vol.value === '' ? null : +vol.value; dirty(); });
|
||||
badge.addEventListener('input', () => { t.badge = badge.value; dirty(); });
|
||||
hearts.addEventListener('change', () => { t.hearts = +hearts.value; dirty(); });
|
||||
tr.querySelector('button').addEventListener('click', () => { T.bitsTiers.splice(i, 1); dirty(); render(); });
|
||||
tb.append(tr);
|
||||
});
|
||||
// single pickers
|
||||
document.querySelectorAll('[data-pick]').forEach(el => {
|
||||
const key = el.dataset.pick, type = el.dataset.type;
|
||||
const w = picker(type, T[key], v => { T[key] = v; dirty(); });
|
||||
w.dataset.pick = key; w.dataset.type = type;
|
||||
el.replaceWith(w);
|
||||
});
|
||||
// photos behind
|
||||
const bk = document.getElementById('backs'); bk.innerHTML = '';
|
||||
T.back.forEach((u, i) => {
|
||||
const b = document.createElement('span'); b.className = 'b';
|
||||
b.innerHTML = `<img src="${esc(u)}" alt="" title="${esc(u.split('/').pop())}"><button type="button" class="outline btn-xs" title="Remove">✕</button>`;
|
||||
b.querySelector('button').addEventListener('click', () => { T.back.splice(i, 1); dirty(); render(); });
|
||||
bk.append(b);
|
||||
});
|
||||
const add = picker('image', '', v => { if (v) { T.back.push(v); dirty(); render(); } });
|
||||
add.querySelector('select').options[0].textContent = '+ add a photo';
|
||||
bk.append(add);
|
||||
}
|
||||
|
||||
document.querySelectorAll('input[name=style], input[name=redeemStyle], input[name=ttsStyle]').forEach(r => r.addEventListener('change', () => { T[r.name] = r.value; dirty(); }));
|
||||
document.querySelectorAll('[data-k]').forEach(i => i.addEventListener('input', () => {
|
||||
set(i.dataset.k, i.type === 'number' || i.type === 'range' ? +i.value : i.value);
|
||||
if (i.dataset.k === 'volume') document.getElementById('vol-out').textContent = Math.round(i.value * 100) + '%';
|
||||
}));
|
||||
document.getElementById('tier-add').addEventListener('click', () => { T.bitsTiers.push({ min: 1, art: '', sound: '', volume: null, badge: '#8a8aa8', hearts: 0 }); dirty(); render(); });
|
||||
|
||||
async function save() {
|
||||
state.textContent = 'Saving…'; state.className = 'hint';
|
||||
try {
|
||||
const r = await fetch('/actions/alerts', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(T) });
|
||||
const j = await r.json();
|
||||
if (!j.ok) throw new Error(j.error || r.status);
|
||||
T = j.theme; render();
|
||||
state.textContent = 'Saved'; state.className = 'hint';
|
||||
} catch (e) { state.textContent = 'Save failed: ' + e.message; state.className = 'dirty'; }
|
||||
}
|
||||
document.getElementById('save').addEventListener('click', save);
|
||||
document.addEventListener('keydown', e => { if ((e.ctrlKey || e.metaKey) && e.key === 's') { e.preventDefault(); save(); } });
|
||||
window.addEventListener('beforeunload', e => { if (state.classList.contains('dirty')) { e.preventDefault(); e.returnValue = ''; } });
|
||||
// test buttons: save first, then play the sample on the overlay
|
||||
document.addEventListener('click', async e => {
|
||||
const b = e.target.closest('[data-test]'); if (!b) return;
|
||||
if (state.classList.contains('dirty')) await save();
|
||||
const r = await fetch('/alerts/test/' + encodeURIComponent(b.dataset.test), { method: 'POST' });
|
||||
const l = b.textContent; b.textContent = r.ok ? 'Sent' : 'Failed'; setTimeout(() => { b.textContent = l; }, 1200);
|
||||
});
|
||||
render();
|
||||
})();
|
||||
</script>
|
||||
|
|
@ -1,22 +1,20 @@
|
|||
<h2>Dashboard</h2>
|
||||
|
||||
<div style="display:flex; gap:1rem; margin-bottom:1.5rem; flex-wrap:wrap;">
|
||||
<div>
|
||||
<strong>Channel:</strong>
|
||||
<%= settings.channel || '<em>not set</em>' %>
|
||||
</div>
|
||||
<div>
|
||||
<strong>OBS browser sources</strong> (1920×1080):<br>
|
||||
<small>Chat only, set its audio to <em>Monitor Only (mute output)</em> so chat sounds stay off stream:</small><br>
|
||||
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=chat</code><br>
|
||||
<small>Everything except chat (alerts, redeems, poll, Hype Train bar, raid send-off):</small><br>
|
||||
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=nochat</code><br>
|
||||
<small>Chat somewhere else, e.g. in the Intermission panel (left,top,width,height in px of the 1920×1080 page; <em>up</em> = newest at the bottom):</small><br>
|
||||
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=chat&chat=130,640,700,360&chatflow=up</code><br>
|
||||
<small title="parts: chat, alerts, poll, hypebar, raid. List them (?parts=chat,raid) or exclude with no… (?parts=nochat,noraid). No ?parts = everything.">
|
||||
Other combinations: hover for help · everything in one source: <code>/overlay/<%= settings.overlay_id %></code></small>
|
||||
</div>
|
||||
<div class="dash-status">
|
||||
<a href="/settings/connections" title="Settings → Connections">
|
||||
Twitch <% if (eventsubStatus.connected) { %><span class="badge badge-green">connected</span><% } else if (eventsubStatus.running) { %><span class="badge badge-grey">connecting…</span><% } else { %><span class="badge badge-red">not running</span><% } %>
|
||||
</a>
|
||||
<a href="/settings/connections" title="Settings → Connections">
|
||||
StreamElements <% if (!seStatus.enabled) { %><span class="badge badge-grey">off</span><% } else if (seStatus.subscribed) { %><span class="badge badge-green">connected</span><% } else { %><span class="badge badge-grey">connecting…</span><% } %>
|
||||
</a>
|
||||
<a href="/settings/obs" title="Browser source links for OBS">OBS links →</a>
|
||||
<% if (eventsubStatus.failed.length) { %><a href="/settings/connections" style="color:#f88">Some Twitch permissions are missing: log in again</a><% } %>
|
||||
</div>
|
||||
<style>
|
||||
.dash-status { display:flex; gap:1.4rem; flex-wrap:wrap; align-items:center; margin:0 0 1.4rem; padding:.6rem .9rem;
|
||||
border:1px solid var(--pico-muted-border-color); border-radius:12px; }
|
||||
.dash-status a { text-decoration:none; font-size:.92rem; }
|
||||
</style>
|
||||
|
||||
<div style="display:flex; gap:.8rem; align-items:center; margin-bottom:1.5rem;">
|
||||
<button type="button" id="skip-alert" class="outline" style="width:auto; margin:0;"
|
||||
|
|
@ -32,32 +30,6 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<h3>Twitch connection</h3>
|
||||
<p>
|
||||
<% if (eventsubStatus.connected) { %>
|
||||
<span class="badge badge-green">connected</span>
|
||||
<% } else if (eventsubStatus.running) { %>
|
||||
<span class="badge badge-grey">connecting…</span>
|
||||
<% } else { %>
|
||||
<span class="badge badge-grey">not running</span> (log in again to start)
|
||||
<% } %>
|
||||
<% if (eventsubStatus.subscribed.length) { %><br><small>Listening to: <%= eventsubStatus.subscribed.join(', ') %></small><% } %>
|
||||
<% if (eventsubStatus.failed.length) { %><br><small style="color:#c0392b">Failed: <%= eventsubStatus.failed.join(', ') %> (log out and in again if a permission is missing)</small><% } %>
|
||||
<% if (eventsubStatus.lastEventAt) { %><br><small>Last event: <%= eventsubStatus.lastEventAt %></small><% } %>
|
||||
</p>
|
||||
|
||||
<h3>StreamElements tips</h3>
|
||||
<p>
|
||||
<% if (!seStatus.enabled) { %>
|
||||
<span class="badge badge-grey">off</span> <small>set <code>SE_JWT</code> in <code>.env</code> (StreamElements dashboard → avatar → your channel → JWT token) and restart</small>
|
||||
<% } else if (seStatus.subscribed) { %>
|
||||
<span class="badge badge-green">connected</span><% if (seStatus.lastTipAt) { %> <small>last tip: <%= seStatus.lastTipAt %></small><% } %>
|
||||
<% } else { %>
|
||||
<span class="badge badge-grey">connecting…</span>
|
||||
<% } %>
|
||||
<% if (seStatus.error) { %><br><small style="color:#c0392b"><%= seStatus.error %></small><% } %>
|
||||
</p>
|
||||
|
||||
<h3>Raid</h3>
|
||||
<p><small>Start the raid here and the send-off card stays on stream (silent) until the raid happens. Same as Twitch's Raid button.</small></p>
|
||||
<div style="display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-bottom:.4rem;">
|
||||
|
|
@ -82,7 +54,7 @@
|
|||
</script>
|
||||
|
||||
<h3>Test alerts</h3>
|
||||
<p><small>Sends a sample alert to the overlay (OBS). Not logged, no actions fired.</small></p>
|
||||
<p><small>Sends a sample alert to the overlay (OBS). Not logged, no actions fired. Looks and sounds: <a href="/actions/alerts">Actions → Alerts</a>.</small></p>
|
||||
<div id="test-alerts" style="display:flex; flex-wrap:wrap; gap:.4rem; margin-bottom:.5rem;">
|
||||
<% for (const key of testKeys) { %>
|
||||
<button type="button" class="outline" data-key="<%= key %>" style="width:auto; padding:.3rem .8rem; margin:0;"><%= key %></button>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,45 @@
|
|||
.badge-green { background: #1a7a1a; color: #a8f0a8; }
|
||||
.badge-red { background: #7a1a1a; color: #f0a8a8; }
|
||||
.badge-grey { background: #333; color: #aaa; }
|
||||
nav ul li a.on { color: var(--pico-color); font-weight: 700; }
|
||||
/* left sidebar of Actions / Settings */
|
||||
main.with-side { max-width: 1400px; margin: 0 auto; }
|
||||
.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 2rem; align-items: start; }
|
||||
.side { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .15rem; }
|
||||
.side-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--pico-muted-color); margin: 0 0 .4rem .75rem; }
|
||||
.side a { display: block; padding: .45rem .75rem; border-radius: 8px; text-decoration: none; color: var(--pico-muted-color); font-size: .95rem; }
|
||||
.side a:hover { background: var(--pico-card-background-color); color: var(--pico-color); }
|
||||
.side a.on { background: var(--pico-primary-background); color: #fff; font-weight: 600; }
|
||||
@media (max-width: 800px) {
|
||||
.shell { grid-template-columns: 1fr; gap: 1rem; }
|
||||
.side { position: static; flex-direction: row; flex-wrap: wrap; }
|
||||
.side-title { display: none; }
|
||||
}
|
||||
/* settings pages: one card per group, label left, control right */
|
||||
.set-h { margin: 0 0 .3rem; }
|
||||
.set-intro { color: var(--pico-muted-color); margin: 0 0 1.2rem; }
|
||||
.set-card { border: 1px solid var(--pico-muted-border-color); border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1.2rem; }
|
||||
.set-card > h3 { font-size: 1.05rem; margin: 0 0 .8rem; }
|
||||
.set-row { display: grid; grid-template-columns: minmax(180px, 280px) minmax(0, 1fr); gap: .4rem 1.4rem; align-items: start; padding: .7rem 0; border-top: 1px solid var(--pico-muted-border-color); }
|
||||
.set-card > h3 + .set-row, .set-card > .set-row:first-child { border-top: 0; padding-top: 0; }
|
||||
.set-row > .lbl { font-weight: 600; font-size: .92rem; }
|
||||
.set-row > .lbl small { display: block; font-weight: 400; color: var(--pico-muted-color); font-size: .8rem; margin-top: .15rem; }
|
||||
.set-row input:not([type=checkbox]):not([type=radio]), .set-row select, .set-row textarea { margin: 0; }
|
||||
.set-row label { margin: 0; }
|
||||
@media (max-width: 700px) { .set-row { grid-template-columns: 1fr; } }
|
||||
.set-inline { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
|
||||
.set-inline > * { margin: 0 !important; }
|
||||
.btn-auto { width: auto !important; }
|
||||
.savebar-set { position: sticky; bottom: 0; display: flex; gap: .8rem; align-items: center; padding: .7rem 0; background: var(--pico-background-color); border-top: 1px solid var(--pico-muted-border-color); margin-top: .5rem; z-index: 5; }
|
||||
.savebar-set button { width: auto; margin: 0; }
|
||||
.flash { padding: .5rem .8rem; border-radius: 8px; margin: 0 0 1rem; background: rgba(63,185,80,.15); border: 1px solid rgba(63,185,80,.5); }
|
||||
.flash.err { background: rgba(248,136,136,.12); border-color: #f88; }
|
||||
.copy { display: flex; gap: .4rem; align-items: center; }
|
||||
.copy code { flex: 1; overflow-x: auto; white-space: nowrap; padding: .35rem .55rem; }
|
||||
.copy button { width: auto; margin: 0; padding: .25rem .7rem; font-size: .8rem; }
|
||||
/* sensitive values (OBS links, HUDFX link, tokens): blurred until the eye is clicked; Copy still copies them */
|
||||
.secret:not(.shown) { filter: blur(6px); user-select: none; pointer-events: none; }
|
||||
.eye { width: auto !important; margin: 0 !important; padding: .25rem .55rem !important; font-size: .9rem !important; line-height: 1; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -22,28 +61,56 @@
|
|||
<li><a class="nav-brand" href="/">HeyStreamer</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="/">Dashboard</a></li>
|
||||
<li><a href="/redeems">Redeems</a></li>
|
||||
<li><a href="/tts">TTS</a></li>
|
||||
<li><a href="/actions">Actions</a></li>
|
||||
<li><a href="/media">Media</a></li>
|
||||
<li><a href="/stats">Stats</a></li>
|
||||
<li><a href="/settings">Settings</a></li>
|
||||
<% const top = locals.sidebar ? locals.sidebar.name : ''; %>
|
||||
<li><a href="/" class="<%= !top && locals.navActive === 'dashboard' ? 'on' : '' %>">Dashboard</a></li>
|
||||
<li><a href="/redeems" class="<%= top === 'actions' ? 'on' : '' %>">Actions</a></li>
|
||||
<li><a href="/stats" class="<%= locals.navActive === 'stats' ? 'on' : '' %>">Stats</a></li>
|
||||
<li><a href="/settings" class="<%= top === 'settings' ? 'on' : '' %>">Settings</a></li>
|
||||
<% if (locals.user) { %>
|
||||
<li><a href="/auth/logout">Logout (<%= user.login %>)</a></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</nav>
|
||||
<main class="container">
|
||||
<%- body %>
|
||||
<main class="container<%= locals.sidebar ? '-fluid with-side' : '' %>">
|
||||
<% if (locals.sidebar) { %>
|
||||
<div class="shell">
|
||||
<aside class="side">
|
||||
<div class="side-title"><%= sidebar.title %></div>
|
||||
<% for (const i of sidebar.items) { %>
|
||||
<a href="<%= i.href %>" class="<%= i.on ? 'on' : '' %>"<% if (i.hint) { %> title="<%= i.hint %>"<% } %>><%= i.label %></a>
|
||||
<% } %>
|
||||
</aside>
|
||||
<section class="pane"><%- body %></section>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<%- body %>
|
||||
<% } %>
|
||||
</main>
|
||||
<script>
|
||||
// eye buttons: <button data-reveal="#id"> shows / hides a blurred .secret element or a password input
|
||||
document.addEventListener('click', e => {
|
||||
const b = e.target.closest('[data-reveal]');
|
||||
if (!b) return;
|
||||
const t = document.querySelector(b.dataset.reveal);
|
||||
if (!t) return;
|
||||
const show = t.tagName === 'INPUT' ? t.type === 'password' : !t.classList.contains('shown');
|
||||
if (t.tagName === 'INPUT') t.type = show ? 'text' : 'password'; else t.classList.toggle('shown', show);
|
||||
b.textContent = show ? '🙈' : '👁'; b.title = show ? 'Hide' : 'Show';
|
||||
});
|
||||
// copy buttons: <button data-copy="text"> or data-copy-from="#id"
|
||||
document.addEventListener('click', e => {
|
||||
const b = e.target.closest('[data-copy],[data-copy-from]');
|
||||
if (!b) return;
|
||||
const text = b.dataset.copy ?? document.querySelector(b.dataset.copyFrom)?.textContent ?? '';
|
||||
navigator.clipboard?.writeText(text).then(() => { const l = b.textContent; b.textContent = 'Copied'; setTimeout(() => { b.textContent = l; }, 1200); });
|
||||
});
|
||||
// Two-click delete instead of a browser confirm() dialog: first click arms the button, second submits.
|
||||
document.addEventListener('click', e => {
|
||||
const b = e.target.closest('button[data-confirm]');
|
||||
if (!b) return;
|
||||
if (b.dataset.armed) { b.form.requestSubmit(); return; }
|
||||
b.dataset.armed = '1'; b.dataset.label = b.textContent; b.textContent = 'Really delete?';
|
||||
if (b.dataset.armed) { if (b.type !== 'submit') b.form.requestSubmit(); return; } // armed submit button: let it submit
|
||||
e.preventDefault();
|
||||
b.dataset.armed = '1'; b.dataset.label = b.textContent; b.textContent = b.dataset.confirm || 'Really delete?';
|
||||
b.style.fontWeight = '700';
|
||||
setTimeout(() => { delete b.dataset.armed; b.textContent = b.dataset.label; b.style.fontWeight = ''; }, 4000);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Caveat:wght@700&family=Nunito:wght@800;900&display=swap">
|
||||
<% const has = p => parts.includes(p); %>
|
||||
<% if (has('alerts')) { %>
|
||||
<link rel="stylesheet" href="/alerts/card.css?v=<%= boot %>">
|
||||
<link rel="stylesheet" href="/alerts/polaroid.css?v=<%= boot %>">
|
||||
<link rel="stylesheet" href="/alerts/cassette.css?v=<%= boot %>">
|
||||
<link rel="stylesheet" href="/alerts/fx.css?v=<%= boot %>">
|
||||
|
|
@ -81,6 +82,7 @@
|
|||
<script src="/vendor/tmi.min.js"></script>
|
||||
<% if (has('chat')) { %><script src="/chat/chat.js?v=<%= boot %>"></script><% } %>
|
||||
<% if (has('alerts')) { %>
|
||||
<script src="/alerts/card.js?v=<%= boot %>"></script>
|
||||
<script src="/alerts/cassette.js?v=<%= boot %>"></script>
|
||||
<script src="/alerts/fx.js?v=<%= boot %>"></script>
|
||||
<script src="/alerts/polaroid.js?v=<%= boot %>"></script>
|
||||
|
|
|
|||
72
views/public_stats.ejs
Normal file
72
views/public_stats.ejs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><%= displayName %> · Stream stats</title>
|
||||
<meta name="description" content="Stream statistics for <%= displayName %> on Twitch: streams, chat, emotes, leaderboards.">
|
||||
<%# viewer names are listed: keep the page out of search engines (remove this line to allow indexing) %>
|
||||
<meta name="robots" content="noindex">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Caveat:wght@700&family=Nunito:wght@400;600;700;800;900&display=swap">
|
||||
<style>
|
||||
/* paper look of the overlay alerts (polaroid / letter): cream paper, ink, red, lilac washi tape */
|
||||
:root { --bg:#f3ece2; --paper:#fffdf7; --ink:#3a2a20; --muted:#8a7565; --line:#e4d9cb; --accent:#b74347; --accent-hover:#9a3539;
|
||||
--card:var(--paper); --card-solid:var(--paper); --tape:rgba(201,182,228,.85); --link:#b74347; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root { --bg:#1d1916; --paper:#2a2420; --ink:#f1e7da; --muted:#b09d8b; --line:#3d342d; --accent:#d0626a; --accent-hover:#e07a82;
|
||||
--card:var(--paper); --card-solid:var(--paper); --tape:rgba(155,130,195,.7); --link:#e58b91; }
|
||||
}
|
||||
* { box-sizing:border-box; }
|
||||
html, body { margin:0; background:var(--bg); color:var(--ink); }
|
||||
body { font:400 15px/1.45 'Nunito', system-ui, sans-serif; }
|
||||
a { color:var(--link); }
|
||||
.wrap { max-width:1100px; margin:0 auto; padding:24px 16px 48px; }
|
||||
header.hero { position:relative; background:var(--paper); padding:22px 24px 18px; margin:14px 0 22px; box-shadow:0 10px 24px rgba(0,0,0,.12);
|
||||
transform:rotate(-.4deg); display:flex; flex-wrap:wrap; align-items:center; gap:.5rem 1.2rem; }
|
||||
header.hero:before, header.hero:after { content:''; position:absolute; top:-14px; width:120px; height:32px; background-color:var(--tape);
|
||||
background-image:repeating-linear-gradient(45deg,#fff6 0 8px,#0000 8px 16px); box-shadow:0 1px 2px rgba(0,0,0,.15); }
|
||||
header.hero:before { left:-18px; transform:rotate(-8deg); }
|
||||
header.hero:after { right:-18px; transform:rotate(7deg); }
|
||||
header.hero h1 { font:700 46px/1 'Caveat', cursive; margin:0; }
|
||||
header.hero h1 span { color:var(--accent); }
|
||||
header.hero .sub { color:var(--muted); font-weight:600; }
|
||||
.live { display:inline-flex; align-items:center; gap:.4rem; background:var(--accent); color:#fff; border-radius:99px; padding:.2rem .8rem;
|
||||
font-weight:800; font-size:.85rem; text-decoration:none; margin-left:auto; }
|
||||
.live:before { content:''; width:8px; height:8px; border-radius:50%; background:#fff; animation:blink 1.4s infinite; }
|
||||
.watch { margin-left:auto; font-weight:700; text-decoration:none; }
|
||||
@keyframes blink { 50% { opacity:.3; } }
|
||||
.preview { background:#e6b800; color:#221a00; padding:.4rem .8rem; border-radius:8px; font-weight:700; font-size:.85rem; margin-bottom:.6rem; }
|
||||
h3.sb-h { font:700 30px/1 'Caveat', cursive; margin:1.8rem 0 .7rem; }
|
||||
.sb-tile .v { font-weight:900; }
|
||||
.sb-board h4, .sb-chart h4 { font-weight:800; }
|
||||
.sb-tabs a.on { color:#fff; }
|
||||
code { font-family:ui-monospace, monospace; font-size:.9em; }
|
||||
footer { margin-top:2.4rem; color:var(--muted); font-size:.85rem; border-top:1px dashed var(--line); padding-top:1rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<% if (preview) { %><div class="preview">Preview: the public page is off (Settings → Public stats page). Only you can see this.</div><% } %>
|
||||
<header class="hero">
|
||||
<h1><span><%= displayName %></span>'s stream stats</h1>
|
||||
<span class="sub">the people who make the streams fun ♡</span>
|
||||
<% if (live) { %>
|
||||
<a class="live" href="https://twitch.tv/<%= encodeURIComponent(channel) %>" target="_blank" rel="noopener">live now</a>
|
||||
<% } else if (channel) { %>
|
||||
<a class="watch" href="https://twitch.tv/<%= encodeURIComponent(channel) %>" target="_blank" rel="noopener">twitch.tv/<%= channel %> ↗</a>
|
||||
<% } %>
|
||||
</header>
|
||||
|
||||
<%- include('_statsbody', { s, q, base: base || '/', viewerHref: null, mode: 'public', view, ranks, tz }) %>
|
||||
|
||||
<footer>
|
||||
Chat activity and watch time are counted for these statistics; message text is never shown here.
|
||||
Don't want your name on this page? Type <code>!hideme</code> in chat (you still count in the totals, unnamed);
|
||||
<code>!showme</code> brings it back. To have your data deleted completely, ask in chat or whisper the streamer.
|
||||
Days are UTC; numbers update every few minutes.
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -71,6 +71,7 @@
|
|||
.pick ul.opts li.none { color:var(--pico-muted-color); cursor:default; }
|
||||
[data-show] { display:none !important; }
|
||||
.vcard[data-display="cassette"] [data-show~="cassette"],
|
||||
.vcard[data-display="card"] [data-show~="cassette"],
|
||||
.vcard[data-display="sound"] [data-show~="sound"],
|
||||
.vcard[data-display="video"] [data-show~="video"] { display:flex !important; }
|
||||
</style>
|
||||
|
|
@ -114,7 +115,7 @@
|
|||
</summary>
|
||||
|
||||
<% for (const v of t.variations) {
|
||||
const display = v.video ? 'video' : v.polaroid ? 'cassette' : 'sound'; %>
|
||||
const display = v.video ? 'video' : !v.polaroid ? 'sound' : v.look === 'card' ? 'card' : 'cassette'; %>
|
||||
<div class="vcard<%= v.enabled ? '' : ' off' %>" data-id="<%= v.id %>" data-display="<%= display %>">
|
||||
<div class="vrow">
|
||||
<input type="checkbox" role="switch" data-f="enabled" <%= v.enabled ? 'checked' : '' %> title="On: this variation can play">
|
||||
|
|
@ -129,8 +130,8 @@
|
|||
</div>
|
||||
|
||||
<div class="vrow">
|
||||
<span class="seg" title="Cassette: tape alert with sound. Sound only: just the sound. Video: full-screen video on the ?parts=video overlay">
|
||||
<% for (const [val, lbl] of [['cassette', 'Cassette'], ['sound', 'Sound only'], ['video', 'Video']]) { %>
|
||||
<span class="seg" title="Card: plain alert card with sound. Cassette: tape alert with sound. Sound only: just the sound. Video: full-screen video on the ?parts=video overlay">
|
||||
<% for (const [val, lbl] of [['card', 'Card'], ['cassette', 'Cassette'], ['sound', 'Sound only'], ['video', 'Video']]) { %>
|
||||
<label><input type="radio" name="display-<%= v.id %>" data-f="display" value="<%= val %>" <%= display === val ? 'checked' : '' %>><%= lbl %></label>
|
||||
<% } %>
|
||||
</span>
|
||||
|
|
@ -147,7 +148,7 @@
|
|||
|
||||
<div class="vrow" data-show="cassette">
|
||||
<input type="hidden" data-f="art" value="<%= v.art || '' %>">
|
||||
<span class="pick" data-pick="art" title="Sticker in the cassette's corner"></span>
|
||||
<span class="pick" data-pick="art" title="Picture on the card / sticker in the cassette's corner"></span>
|
||||
<span class="field grow"><input data-f="caption" value="<%= v.caption %>" title="Text after the viewer's name on the paper strip. {reward} = reward name, {variation} = this variation's name. The viewer's typed message is added automatically."></span>
|
||||
<input type="hidden" data-f="tts_voice_id" value="<%= v.tts_voice_id || '' %>">
|
||||
<span class="pick" data-pick="tts_voice_id" title="Read the viewer's typed text aloud (voice from the TTS page), shown as a big paper note. The voice replaces the sound. The reward needs 'Require Viewer to Enter Text' on Twitch."></span>
|
||||
|
|
@ -184,7 +185,8 @@
|
|||
tts_voice_id: <%- JSON.stringify(ttsVoices.map(t => ({ url: String(t.id), label: t.name }))) %>,
|
||||
};
|
||||
const ADD = { sound: '+ sound', video: '+ video', art: '+ sticker', tts_voice_id: '+ TTS voice' };
|
||||
const DEFAULT_STICKER = { url: '', label: 'headset Streamer (default)', img: '/alerts/stickers/default-sticker.png' };
|
||||
const THEME_STICKER = <%- JSON.stringify(theme.defaultSticker || '') %>; // Actions → Alerts → Default redeem sticker
|
||||
const DEFAULT_STICKER = { url: '', label: 'default picture', img: THEME_STICKER || '/alerts/art/placeholder.svg' };
|
||||
const DRAFT_KEY = 'redeemsDraft', OPEN_KEY = 'redeemsOpen';
|
||||
const stateEl = document.getElementById('save-state');
|
||||
const dirty = new Set();
|
||||
|
|
@ -224,7 +226,7 @@
|
|||
c.dataset.display = o.display;
|
||||
c.classList.toggle('off', !o.enabled);
|
||||
c.querySelector('[data-vol]').textContent = Math.round(o.volume * 100) + '%';
|
||||
const ttsOn = !!o.tts_voice_id && o.display === 'cassette';
|
||||
const ttsOn = !!o.tts_voice_id && (o.display === 'cassette' || o.display === 'card');
|
||||
c.querySelector('[data-pick="sound"]').classList.toggle('disabled', ttsOn);
|
||||
c.querySelectorAll('[data-pick]').forEach(renderPick);
|
||||
chances(c.closest('[data-trigger]'));
|
||||
|
|
|
|||
|
|
@ -1,112 +0,0 @@
|
|||
<h2>Settings</h2>
|
||||
|
||||
<article>
|
||||
<header><strong>Overlay URL</strong></header>
|
||||
<p>Add this as a <strong>Browser Source</strong> in OBS (1920×1080, transparent background):</p>
|
||||
<code><%= baseUrl %>/overlay/<%= settings.overlay_id %></code>
|
||||
</article>
|
||||
|
||||
<form method="POST" action="/settings">
|
||||
|
||||
<h3>Chat</h3>
|
||||
<label>
|
||||
Twitch channel
|
||||
<input type="text" name="channel" value="<%= settings.channel %>" placeholder="yourchannel">
|
||||
</label>
|
||||
<div style="display:grid; grid-template-columns:1fr 1fr; gap:1rem;">
|
||||
<label>
|
||||
Message timeout (seconds)
|
||||
<input type="number" name="message_timeout" value="<%= settings.message_timeout %>" min="0" max="600">
|
||||
<small>0 = messages stay forever</small>
|
||||
</label>
|
||||
<label>
|
||||
Max messages shown
|
||||
<input type="number" name="max_messages" value="<%= settings.max_messages %>" min="1" max="100">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<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' : '' %>>
|
||||
Enable gap audio
|
||||
</label>
|
||||
<label>
|
||||
Sound URL
|
||||
<input type="text" name="gap_audio_url" value="<%= settings.gap_audio_url %>" placeholder="https://... or /media/filename.mp3">
|
||||
</label>
|
||||
<div style="display:grid; grid-template-columns:1fr 1fr 1fr; gap:1rem;">
|
||||
<label>
|
||||
Min silence before triggering (s)
|
||||
<input type="number" name="gap_audio_min_silence" value="<%= settings.gap_audio_min_silence %>" min="0">
|
||||
<small>Sound won't play if chat was more recent than this</small>
|
||||
</label>
|
||||
<label>
|
||||
Min volume (0–1)
|
||||
<input type="number" name="gap_audio_min_volume" value="<%= settings.gap_audio_min_volume %>" min="0" max="1" step="0.05">
|
||||
<small>Volume right after min silence</small>
|
||||
</label>
|
||||
<label>
|
||||
Max volume (0–1)
|
||||
<input type="number" name="gap_audio_max_volume" value="<%= settings.gap_audio_max_volume %>" min="0" max="1" step="0.05">
|
||||
<small>Volume after long silence</small>
|
||||
</label>
|
||||
</div>
|
||||
<label>
|
||||
Full volume after silence of (seconds)
|
||||
<input type="number" name="gap_audio_loud_after" value="<%= settings.gap_audio_loud_after %>" min="0">
|
||||
<small>e.g. 3600 = 1 hour of silence → max volume</small>
|
||||
</label>
|
||||
|
||||
<h3>TTS redeems</h3>
|
||||
<p><small>For redeem variations with a TTS voice (set on the Redeems page; voices are made on the TTS page).</small></p>
|
||||
<div style="display:grid; grid-template-columns:1fr 1fr; gap:1rem;">
|
||||
<label>
|
||||
Max length (characters)
|
||||
<input type="number" name="tts_max_chars" value="<%= settings.tts_max_chars %>" min="20" max="500">
|
||||
<small>Longer messages are cut at a word.</small>
|
||||
</label>
|
||||
<label style="align-self:center;">
|
||||
<input type="checkbox" name="tts_say_name" role="switch" <%= settings.tts_say_name ? 'checked' : '' %>>
|
||||
Say the name first ("ChickenWhisperer says: …")
|
||||
</label>
|
||||
</div>
|
||||
<label>
|
||||
Blocked words
|
||||
<textarea name="tts_blocklist" rows="4" placeholder="one per line, or comma-separated"><%= settings.tts_blocklist %></textarea>
|
||||
<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 &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)
|
||||
<textarea name="custom_css" rows="6" style="font-family:monospace"><%= settings.custom_css %></textarea>
|
||||
</label>
|
||||
<label>
|
||||
Custom JS (injected into the overlay, runs after init)
|
||||
<textarea name="custom_js" rows="6" style="font-family:monospace"><%= settings.custom_js %></textarea>
|
||||
</label>
|
||||
|
||||
<button type="submit">Save settings</button>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
<h3>EventSub</h3>
|
||||
<form method="POST" action="/settings/reconnect" style="display:inline;">
|
||||
<button type="submit" class="outline">Reconnect EventSub</button>
|
||||
</form>
|
||||
<small style="margin-left:1rem;">Use this if Twitch alerts stop working after a token refresh.</small>
|
||||
2
views/settings/_flash.ejs
Normal file
2
views/settings/_flash.ejs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<% if (locals.msg) { %><p class="flash"><%= msg %></p><% } %>
|
||||
<% if (locals.err) { %><p class="flash err"><%= err %></p><% } %>
|
||||
16
views/settings/advanced.ejs
Normal file
16
views/settings/advanced.ejs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<h2 class="set-h">Advanced</h2>
|
||||
<p class="set-intro">Extra CSS and JavaScript added to every overlay page.</p>
|
||||
<%- include('_flash') %>
|
||||
<form method="POST" action="/settings/advanced">
|
||||
<div class="set-card">
|
||||
<div class="set-row">
|
||||
<div class="lbl">Custom CSS</div>
|
||||
<textarea name="custom_css" rows="10" style="font-family:monospace"><%= settings.custom_css %></textarea>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Custom JS<small>Runs after the overlay starts.</small></div>
|
||||
<textarea name="custom_js" rows="10" style="font-family:monospace"><%= settings.custom_js %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="savebar-set"><button type="submit">Save</button></div>
|
||||
</form>
|
||||
16
views/settings/backup.ejs
Normal file
16
views/settings/backup.ejs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<h2 class="set-h">Backup</h2>
|
||||
<p class="set-intro">Your whole setup in one file: settings, alert theme, redeems and their variations, TTS voices. Not included: the media files themselves (keep a copy of your uploads), statistics, and secrets (Twitch login, StreamElements token).</p>
|
||||
<%- include('_flash') %>
|
||||
<div class="set-card">
|
||||
<div class="set-row">
|
||||
<div class="lbl">Export<small>Download a .json file.</small></div>
|
||||
<div><a href="/settings/backup/export" role="button" class="btn-auto">Download backup</a></div>
|
||||
</div>
|
||||
<form method="POST" action="/settings/backup/import" enctype="multipart/form-data" class="set-row">
|
||||
<div class="lbl">Import<small>Replaces the current settings, theme, redeems and TTS voices with the ones in the file. Statistics stay.</small></div>
|
||||
<div class="set-inline">
|
||||
<input type="file" name="file" accept=".json,application/json" required>
|
||||
<button type="submit" class="outline btn-auto" data-confirm="Really replace everything?">Import and replace</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
62
views/settings/chat.ejs
Normal file
62
views/settings/chat.ejs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<h2 class="set-h">Chat</h2>
|
||||
<p class="set-intro">The chat shown on the overlay (OBS source with the chat part).</p>
|
||||
<%- include('_flash') %>
|
||||
<form method="POST" action="/settings/chat">
|
||||
<div class="set-card">
|
||||
<h3>Messages</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Message timeout<small>Seconds a message stays. 0 = forever.</small></div>
|
||||
<input type="number" name="message_timeout" value="<%= settings.message_timeout %>" min="0" max="600" style="max-width:8rem;">
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Max messages shown</div>
|
||||
<input type="number" name="max_messages" value="<%= settings.max_messages %>" min="1" max="100" style="max-width:8rem;">
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Hidden chatters<small>Bots and alert services: never shown in the on-screen chat and left out of the statistics. Twitch logins, commas or spaces.</small></div>
|
||||
<input type="text" name="chat_hidden_users" value="<%= settings.chat_hidden_users || '' %>" placeholder="streamelements, nightbot, …">
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Hide ! commands<small>!discord, !lurk … are not shown. Add the bot to Hidden chatters to hide its answer too.</small></div>
|
||||
<label><input type="checkbox" name="chat_hide_commands" role="switch" <%= settings.chat_hide_commands ? 'checked' : '' %>></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Gap sound</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Play a sound after silence<small>When a message arrives after chat was quiet for a while.</small></div>
|
||||
<label><input type="checkbox" name="gap_audio_enabled" role="switch" <%= settings.gap_audio_enabled ? 'checked' : '' %>></label>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Sound<small>From your <a href="/media">Media</a> library (upload new sounds there).</small></div>
|
||||
<div class="set-inline">
|
||||
<select name="gap_audio_url" id="gap-sound" style="flex:1; min-width:220px;">
|
||||
<option value="">— none —</option>
|
||||
<% for (const m of sounds) { %><option value="<%= m.url %>" <%= m.url === settings.gap_audio_url ? 'selected' : '' %>><%= m.label %></option><% } %>
|
||||
<% if (settings.gap_audio_url && !sounds.some(m => m.url === settings.gap_audio_url)) { %><option value="<%= settings.gap_audio_url %>" selected>link: <%= settings.gap_audio_url.split('/').pop() %></option><% } %>
|
||||
</select>
|
||||
<button type="button" class="outline btn-auto" id="gap-play" title="Play">▶</button>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('gap-play').addEventListener('click', () => {
|
||||
const u = document.getElementById('gap-sound').value;
|
||||
if (u) { const a = new Audio(u); a.volume = parseFloat(document.querySelector('[name=gap_audio_max_volume]').value) || 1; a.play(); }
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Quiet for at least<small>Seconds of silence before the sound plays.</small></div>
|
||||
<input type="number" name="gap_audio_min_silence" value="<%= settings.gap_audio_min_silence %>" min="0" style="max-width:8rem;">
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Volume<small>Quiet right after the minimum silence, louder the longer chat was quiet.</small></div>
|
||||
<div class="set-inline">
|
||||
<label>from <input type="number" name="gap_audio_min_volume" value="<%= settings.gap_audio_min_volume %>" min="0" max="1" step="0.05" style="max-width:6rem;"></label>
|
||||
<label>to <input type="number" name="gap_audio_max_volume" value="<%= settings.gap_audio_max_volume %>" min="0" max="1" step="0.05" style="max-width:6rem;"></label>
|
||||
<label>full after <input type="number" name="gap_audio_loud_after" value="<%= settings.gap_audio_loud_after %>" min="0" style="max-width:7rem;"> s</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="savebar-set"><button type="submit">Save</button></div>
|
||||
</form>
|
||||
64
views/settings/connections.ejs
Normal file
64
views/settings/connections.ejs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<h2 class="set-h">Connections</h2>
|
||||
<p class="set-intro">Services HeyStreamer talks to.</p>
|
||||
<%- include('_flash') %>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Twitch</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Account</div>
|
||||
<div><%= user ? (user.display_name || user.login) : 'not logged in' %></div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Events (EventSub)<small>Follows, subs, bits, rewards, raids, chat, stream on / off.</small></div>
|
||||
<div>
|
||||
<% if (eventsub.connected) { %><span class="badge badge-green">connected</span>
|
||||
<% } else if (eventsub.running) { %><span class="badge badge-grey">connecting…</span>
|
||||
<% } else { %><span class="badge badge-red">not running</span><% } %>
|
||||
<% if (eventsub.lastEventAt) { %> <small>last event <%= eventsub.lastEventAt.slice(0, 16).replace('T', ' ') %> UTC</small><% } %>
|
||||
<% if (eventsub.failed.length) { %><p><small style="color:#f88">Not allowed: <%= eventsub.failed.join(', ') %>. Log in again to give HeyStreamer the missing permission.</small></p><% } %>
|
||||
<% if (eventsub.subscribed.length) { %><details style="margin:.4rem 0 0;"><summary><small>Listening to <%= eventsub.subscribed.length %> events</small></summary><small><%= eventsub.subscribed.join(', ') %></small></details><% } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Fix it<small>Log in again after new features ask for more permissions, or reconnect if alerts stop.</small></div>
|
||||
<div class="set-inline">
|
||||
<a href="/auth/twitch" role="button" class="btn-auto">Log in again with Twitch</a>
|
||||
<form method="POST" action="/settings/connections/reconnect"><button type="submit" class="outline btn-auto">Reconnect</button></form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>StreamElements tips</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Status</div>
|
||||
<div>
|
||||
<% if (!se.enabled) { %><span class="badge badge-grey">off</span> <small>no token</small>
|
||||
<% } else if (se.subscribed) { %><span class="badge badge-green">connected</span><% if (se.lastTipAt) { %> <small>last tip <%= se.lastTipAt %></small><% } %>
|
||||
<% } else { %><span class="badge badge-grey">connecting…</span><% } %>
|
||||
<% if (se.error) { %><br><small style="color:#f88"><%= se.error %></small><% } %>
|
||||
<% if (se.source === 'env') { %><br><small>Token comes from <code>.env</code> (SE_JWT). Saving one here replaces it.</small><% } %>
|
||||
</div>
|
||||
</div>
|
||||
<form method="POST" action="/settings/connections/se" class="set-row">
|
||||
<div class="lbl">JWT token<small>StreamElements → your avatar → Channel settings → Show secrets → JWT Token. Kept secret: it is never shown again here.</small></div>
|
||||
<div class="set-inline">
|
||||
<input type="password" id="se-jwt" name="se_jwt" autocomplete="off" placeholder="<%= settings.se_jwt ? '•••••••• (saved: paste a new one to replace it)' : 'paste the JWT token' %>" style="flex:1; min-width:220px;">
|
||||
<button type="button" class="outline eye" data-reveal="#se-jwt" title="Show what you typed">👁</button>
|
||||
<button type="submit" class="btn-auto">Save and connect</button>
|
||||
<% if (settings.se_jwt) { %><button type="submit" name="clear" value="1" class="outline btn-auto" data-confirm="Really remove?">Remove token</button><% } %>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="/settings/hudfx" class="set-card">
|
||||
<h3>HUDFX</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">HUDFX overlay URL<small>Then add <code>&ext=hudfx</code> to an OBS source link: HUDFX effects play inside that overlay. Empty = off.</small></div>
|
||||
<div class="set-inline">
|
||||
<input type="password" id="hudfx-url" name="hudfx_overlay_url" value="<%= settings.hudfx_overlay_url || '' %>" placeholder="https://overlays.hudfx.io/overlay/…" autocomplete="off" style="flex:1; min-width:220px;">
|
||||
<button type="button" class="outline eye" data-reveal="#hudfx-url" title="Show">👁</button>
|
||||
<button type="submit" class="btn-auto">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
22
views/settings/general.ejs
Normal file
22
views/settings/general.ejs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<h2 class="set-h">General</h2>
|
||||
<p class="set-intro">Basics about your channel.</p>
|
||||
<%- include('_flash') %>
|
||||
<form method="POST" action="/settings/general">
|
||||
<div class="set-card">
|
||||
<div class="set-row">
|
||||
<div class="lbl">Twitch channel<small>The chat shown on the overlay. Usually your own channel name.</small></div>
|
||||
<input type="text" name="channel" value="<%= settings.channel || '' %>" placeholder="yourchannel" required pattern="#?[A-Za-z0-9_]{2,25}">
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Time zone<small>Used for times and days on the stats pages.</small></div>
|
||||
<div>
|
||||
<input type="text" name="timezone" value="<%= settings.timezone || 'UTC' %>" list="tz-list" placeholder="Europe/London">
|
||||
<datalist id="tz-list">
|
||||
<% let zones = []; try { zones = Intl.supportedValuesOf('timeZone'); } catch {} %>
|
||||
<% for (const z of zones) { %><option value="<%= z %>"><% } %>
|
||||
</datalist>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="savebar-set"><button type="submit">Save</button></div>
|
||||
</form>
|
||||
64
views/settings/obs.ejs
Normal file
64
views/settings/obs.ejs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<h2 class="set-h">OBS sources</h2>
|
||||
<p class="set-intro">The links are hidden (anyone with one can open your overlay): 👁 shows one, Copy copies it either way. Add them as <strong>Browser Source</strong> in OBS (1920 × 1080, transparent). Pick what one source shows, then copy its link.</p>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Ready-made links</h3>
|
||||
<% const links = [
|
||||
['Everything except chat', '?parts=nochat', 'Alerts, redeems, poll, Hype Train bar, raid send-off.'],
|
||||
['Chat only', '?parts=chat', 'Set its audio to “Monitor Only (mute output)” so chat sounds stay off stream.'],
|
||||
['Full-screen videos', '?parts=video', 'Video redeems / Power-ups. 2560 × 1440 source looks sharpest.'],
|
||||
['Everything in one source', '', 'Simplest, but chat and alert sounds share one fader.'],
|
||||
]; %>
|
||||
<% links.forEach(([title, q, hint], i) => { %>
|
||||
<div class="set-row">
|
||||
<div class="lbl"><%= title %><small><%= hint %></small></div>
|
||||
<div class="copy"><code id="obs-<%= i %>" class="secret"><%= overlayUrl + q %></code><button type="button" class="outline eye" data-reveal="#obs-<%= i %>" title="Show">👁</button><button type="button" class="outline" data-copy-from="#obs-<%= i %>">Copy</button></div>
|
||||
</div>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Build your own</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Parts</div>
|
||||
<div class="set-inline" id="obs-parts">
|
||||
<% for (const [p, l] of [['alerts', 'Alerts and redeems'], ['chat', 'Chat'], ['poll', 'Poll'], ['hypebar', 'Hype Train bar'], ['raid', 'Raid send-off'], ['video', 'Videos']]) { %>
|
||||
<label><input type="checkbox" value="<%= p %>" <%= p !== 'video' ? 'checked' : '' %>> <%= l %></label>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Chat box<small>Optional: left, top, width, height in px of the 1920 × 1080 page. Empty = default place.</small></div>
|
||||
<div class="set-inline">
|
||||
<input type="text" id="obs-box" placeholder="130,640,700,360" style="max-width:12rem;">
|
||||
<label><input type="checkbox" id="obs-up"> newest at the bottom</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Extras</div>
|
||||
<div class="set-inline"><label title="Needs the HUDFX URL in Settings → Connections"><input type="checkbox" id="obs-hudfx"> HUDFX effects</label></div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Link</div>
|
||||
<div class="copy"><code id="obs-built" class="secret"></code><button type="button" class="outline eye" data-reveal="#obs-built" title="Show">👁</button><button type="button" class="outline" data-copy-from="#obs-built">Copy</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(() => {
|
||||
const base = <%- JSON.stringify(overlayUrl) %>;
|
||||
const all = ['alerts', 'chat', 'poll', 'hypebar', 'raid'];
|
||||
const build = () => {
|
||||
const picked = [...document.querySelectorAll('#obs-parts input:checked')].map(i => i.value);
|
||||
const std = picked.filter(p => p !== 'video');
|
||||
const q = [];
|
||||
if (!(std.length === all.length && !picked.includes('video'))) q.push('parts=' + picked.join(','));
|
||||
const box = document.getElementById('obs-box').value.trim();
|
||||
if (picked.includes('chat') && /^\d+,\d+,\d+,\d+$/.test(box)) q.push('chat=' + box);
|
||||
if (picked.includes('chat') && document.getElementById('obs-up').checked) q.push('chatflow=up');
|
||||
if (document.getElementById('obs-hudfx').checked) q.push('ext=hudfx');
|
||||
document.getElementById('obs-built').textContent = base + (q.length ? '?' + q.join('&') : '');
|
||||
};
|
||||
document.querySelectorAll('#obs-parts input, #obs-box, #obs-up, #obs-hudfx').forEach(i => i.addEventListener('input', build));
|
||||
build();
|
||||
})();
|
||||
</script>
|
||||
38
views/settings/stats.ejs
Normal file
38
views/settings/stats.ejs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<h2 class="set-h">Stats and data</h2>
|
||||
<p class="set-intro">The public stats page, and data copied from Twitch.</p>
|
||||
<%- include('_flash') %>
|
||||
<form method="POST" action="/settings/stats" class="set-card">
|
||||
<h3>Public stats page</h3>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Public page on<small>Off: it answers “not found” for everyone except you (preview below). Never shows message text, bots, or viewers who typed !hideme.</small></div>
|
||||
<label><input type="checkbox" name="public_stats_enabled" role="switch" <%= settings.public_stats_enabled ? 'checked' : '' %>></label>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Host name<small>Its own address. Needs a DNS record to this server, a certificate, and the web server sending it to HeyStreamer. On that host only the public page answers.</small></div>
|
||||
<input type="text" name="public_stats_host" value="<%= settings.public_stats_host || '' %>" placeholder="stats.example.com">
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl"></div>
|
||||
<div class="set-inline"><button type="submit" class="btn-auto">Save</button><a href="/public" target="_blank" rel="noopener">Preview ↗</a></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="set-card">
|
||||
<h3>Twitch</h3>
|
||||
<% const bad = Object.entries(sync.parts || {}).filter(([, v]) => !String(v).startsWith('ok')); %>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Sync with Twitch<small>Followers with follow dates, current subs, mods, VIPs, all-time bits, your emotes, past streams (VODs). Runs every 6 hours and after each stream.</small></div>
|
||||
<div>
|
||||
<form method="POST" action="/stats/sync?back=settings" class="set-inline"><button type="submit" class="outline btn-auto">Sync now</button>
|
||||
<small><%= sync.at ? `last ${sync.at.slice(0, 16).replace('T', ' ')} UTC` : 'never' %></small></form>
|
||||
<% if (sync.at) { %><small><% for (const [k, v] of Object.entries(sync.parts || {})) { %><%= k %>: <span style="<%= String(v).startsWith('ok') ? '' : 'color:#f88' %>"><%= v %></span> · <% } %></small><% } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Twitch analytics (CSV)<small>Creator Dashboard → Analytics → export “Analytics and Revenue by day”. Fills in your history before HeyStreamer, and numbers only Twitch has. Importing again only updates days. Revenue is never public.</small></div>
|
||||
<form method="POST" action="/stats/import-twitch?back=settings" enctype="multipart/form-data" class="set-inline">
|
||||
<label role="button" class="outline btn-auto">Choose CSV files…<input type="file" name="files" accept=".csv,text/csv" multiple hidden onchange="this.form.requestSubmit()"></label>
|
||||
<small><%= csv.days ? `${csv.days} days imported (${csv.from_day} – ${csv.to_day})` : 'none imported yet' %></small>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
20
views/settings/tts.ejs
Normal file
20
views/settings/tts.ejs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<h2 class="set-h">Text to speech</h2>
|
||||
<p class="set-intro">For redeem variations with a TTS voice (set on Actions → Redeems; voices are made on Actions → TTS voices).</p>
|
||||
<%- include('_flash') %>
|
||||
<form method="POST" action="/settings/tts">
|
||||
<div class="set-card">
|
||||
<div class="set-row">
|
||||
<div class="lbl">Max length<small>Characters. Longer messages are cut at a word.</small></div>
|
||||
<input type="number" name="tts_max_chars" value="<%= settings.tts_max_chars %>" min="20" max="500" style="max-width:8rem;">
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Say the name first<small>“ChickenWhisperer says: …”</small></div>
|
||||
<label><input type="checkbox" name="tts_say_name" role="switch" <%= settings.tts_say_name ? 'checked' : '' %>></label>
|
||||
</div>
|
||||
<div class="set-row">
|
||||
<div class="lbl">Blocked words<small>One per line or comma-separated. A message containing one is not read (“message removed”). Whole words, not case-sensitive, plurals and swaps like 0→o, $→s, k y s included. Links are always removed.</small></div>
|
||||
<textarea name="tts_blocklist" rows="10"><%= settings.tts_blocklist %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="savebar-set"><button type="submit">Save</button></div>
|
||||
</form>
|
||||
148
views/stats.ejs
148
views/stats.ejs
|
|
@ -1,44 +1,11 @@
|
|||
<style>
|
||||
/* colours for the shared stats body (_statsbody.ejs), from Pico */
|
||||
main { --muted:var(--pico-muted-color); --line:var(--pico-muted-border-color); --accent:var(--pico-primary-background);
|
||||
--accent-hover:var(--pico-primary-hover-background); --card:transparent; --card-solid:var(--pico-card-background-color); }
|
||||
.meta { color:var(--pico-muted-color); font-size:.85rem; }
|
||||
.tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:.6rem; margin:.6rem 0 1.2rem; }
|
||||
.tile { border:1px solid var(--pico-muted-border-color); border-radius:12px; padding:.7rem .9rem; }
|
||||
.tile .v { font-size:1.7rem; font-weight:700; line-height:1.1; }
|
||||
.tile .k { font-size:.8rem; color:var(--pico-muted-color); }
|
||||
.charts { display:grid; grid-template-columns:repeat(auto-fit, minmax(320px, 1fr)); gap:1rem; margin-bottom:1.2rem; }
|
||||
.chart { border:1px solid var(--pico-muted-border-color); border-radius:12px; padding:.7rem .9rem; position:relative; }
|
||||
.chart h4 { margin:0 0 .4rem; font-size:.95rem; }
|
||||
.chart svg { width:100%; height:auto; display:block; }
|
||||
.chart .bar { fill:var(--pico-primary); }
|
||||
.chart .bar:hover, .chart .hit:hover + .bar { fill:var(--pico-primary-hover); }
|
||||
.chart .grid { stroke:var(--pico-muted-border-color); stroke-width:1; }
|
||||
.chart .ax { fill:var(--pico-muted-color); font-size:10px; }
|
||||
.tip { position:absolute; pointer-events:none; background:var(--pico-card-background-color); border:1px solid var(--pico-muted-border-color);
|
||||
border-radius:8px; padding:.25rem .5rem; font-size:.8rem; box-shadow:0 4px 12px rgba(0,0,0,.35); white-space:nowrap; display:none; z-index:5; }
|
||||
.boards { display:grid; grid-template-columns:repeat(auto-fill, minmax(320px, 1fr)); gap:1rem; }
|
||||
.board { border:1px solid var(--pico-muted-border-color); border-radius:12px; padding:.6rem .8rem; }
|
||||
.board h4 { margin:0 0 .3rem; font-size:.95rem; }
|
||||
.board ol { list-style:none; margin:0; padding:0; }
|
||||
.board li { list-style:none; display:grid; grid-template-columns:1.6rem minmax(0, 1fr) var(--nw, 4.6rem); align-items:center; gap:.5rem;
|
||||
height:2rem; margin:0; padding:0 .2rem; border-bottom:1px solid var(--pico-muted-border-color); font-size:.88rem; }
|
||||
.board li:last-child { border-bottom:0; }
|
||||
.board .r { color:var(--pico-muted-color); text-align:right; font-variant-numeric:tabular-nums; }
|
||||
.board .who { display:flex; align-items:center; gap:.4rem; min-width:0; }
|
||||
.board .who a { text-decoration:none; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
|
||||
.board .lvl { flex:none; font-size:.66rem; padding:.02rem .45rem; border-radius:99px; border:1px solid var(--pico-muted-border-color);
|
||||
color:var(--pico-muted-color); white-space:nowrap; }
|
||||
.board .n { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
|
||||
/* points: the main board, twice as wide, level in its own column so the pills line up */
|
||||
.board.wide { grid-column:span 2; }
|
||||
.board.wide li { grid-template-columns:1.6rem minmax(0, 1fr) 5.5rem var(--nw, 4.6rem); }
|
||||
.board.wide .lvl { justify-self:start; }
|
||||
@media (max-width: 700px) { .board.wide { grid-column:auto; } }
|
||||
.emotes { display:flex; flex-wrap:wrap; gap:.5rem; }
|
||||
.emote { display:flex; align-items:center; gap:.35rem; border:1px solid var(--pico-muted-border-color); border-radius:99px; padding:.15rem .6rem .15rem .25rem; font-size:.8rem; }
|
||||
.emote img { width:26px; height:26px; object-fit:contain; }
|
||||
.search { display:flex; gap:.5rem; max-width:420px; }
|
||||
.search input, .search button { margin:0; }
|
||||
.search button { width:auto; }
|
||||
.empty { color:var(--pico-muted-color); font-size:.85rem; font-style:italic; }
|
||||
.warn { color:#e6b800; }
|
||||
</style>
|
||||
|
||||
|
|
@ -50,100 +17,23 @@
|
|||
<button type="submit" class="outline">Find</button>
|
||||
</form>
|
||||
</div>
|
||||
<p class="meta" title="Bots (Settings → Hidden chatters) are counted but left out of everything shown here. Chat is counted from the first restart after 2026-11-22; watch time from the first stream after the chatter-list permission was approved.">
|
||||
<%= overview.since ? `Counting since ${overview.since.slice(0, 10)}` : 'Nothing counted yet: stats start with the next stream.' %>
|
||||
· <%= hiddenCount %> hidden bot<%= hiddenCount === 1 ? '' : 's' %> left out ⓘ
|
||||
<p class="meta">
|
||||
<span title="Bots (Settings → Hidden chatters) are counted but left out of everything shown here. Days are UTC. Watch time from before HeyStreamer counted comes from StreamElements (or Twitch's analytics export) and only shows under All time."><%= since ? `Counting since ${since}` : 'Nothing counted yet: stats start with the next stream.' %>
|
||||
· <%= hiddenCount %> hidden bot<%= hiddenCount === 1 ? '' : 's' %> left out ⓘ</span>
|
||||
· <% if (publicUrl) { %><a href="<%= publicUrl %>" target="_blank" rel="noopener" title="What viewers see: no message text, bots and !hideme viewers not named">Public page ↗</a><% } else { %><a href="/public" target="_blank" rel="noopener" title="Public page is off (Settings → Public stats page). This preview works while you are logged in.">Public page preview ↗</a><% } %>
|
||||
</p>
|
||||
|
||||
<%
|
||||
const syncBad = Object.entries(sync.parts || {}).filter(([, v]) => !String(v).startsWith('ok'));
|
||||
const syncTip = sync.at ? `Last sync ${sync.at.slice(0, 16).replace('T', ' ')} UTC: ` + Object.entries(sync.parts).map(([k, v]) => `${k} ${v}`).join(', ') : 'Not synced yet';
|
||||
%>
|
||||
<p class="meta" style="margin-top:-.4rem;">
|
||||
<span title="<%= syncTip %>">Twitch sync: <%= sync.at ? `${sync.at.slice(0, 16).replace('T', ' ')} UTC` : 'never' %><% if (syncBad.length) { %> · <span class="warn"><%= syncBad.map(([k]) => k).join(', ') %> failed</span><% } %> ⓘ</span>
|
||||
· analytics: <%= csv.days ? `${csv.days} days imported` : 'none imported' %>
|
||||
· <a href="/settings/stats">Sync, import and the public page: Settings → Stats and data</a>
|
||||
</p>
|
||||
|
||||
<% if (msg) { %><p class="<%= /failed/i.test(msg) ? 'warn' : '' %>" style="font-weight:600;"><%= msg %></p><% } %>
|
||||
<% if (se.configured) { %>
|
||||
<form method="POST" action="/stats/import-se" style="display:flex; gap:.6rem; align-items:center; flex-wrap:wrap; margin:.2rem 0 .8rem;">
|
||||
<button type="submit" class="outline" style="width:auto; margin:0; padding:.3rem .9rem; font-size:.85rem;"
|
||||
title="Copies StreamElements' watch time (per viewer) into HeyStreamer once. It counts like our own watch time (5 points per 5 minutes). Importing again replaces the previous import.<%= se.ownTicks ? ' HeyStreamer is already counting watch time itself: StreamElements has counted those streams too, so importing again now counts them twice.' : '' %>">
|
||||
<%= se.n ? 'Import again from StreamElements' : 'Import watch time from StreamElements' %></button>
|
||||
<span class="meta"><%= se.n ? `Imported ${se.n} viewers · ${Math.round(se.m / 60)} h on ${String(se.at).slice(0, 10)}` : 'Not imported yet: best done before the first stream HeyStreamer counts.' %>
|
||||
<% if (se.n && se.ownTicks) { %><span class="warn"> · importing again would double-count streams since then</span><% } %></span>
|
||||
</form>
|
||||
<% } %>
|
||||
<div class="tiles">
|
||||
<div class="tile"><div class="v"><%= overview.viewers.toLocaleString() %></div><div class="k">viewers seen</div></div>
|
||||
<div class="tile"><div class="v"><%= overview.messages.toLocaleString() %></div><div class="k">chat messages</div></div>
|
||||
<div class="tile"><div class="v"><%= overview.watchHours.toLocaleString() %></div><div class="k">hours watched</div></div>
|
||||
<div class="tile"><div class="v"><%= overview.streams %></div><div class="k">streams</div></div>
|
||||
<div class="tile"><div class="v"><%= overview.checkins.toLocaleString() %></div><div class="k">check-ins</div></div>
|
||||
</div>
|
||||
|
||||
<%
|
||||
// one single-series bar chart (no legend: the title names it); x = last 30 days
|
||||
const chart = (title, key, unit) => {
|
||||
const W = 600, H = 150, L = 34, B = 18, T = 8, n = perDay.length, max = Math.max(1, ...perDay.map(d => d[key]));
|
||||
const nice = (() => { const p = Math.pow(10, Math.floor(Math.log10(max))); return [1, 2, 2.5, 5, 10].map(m => m * p).find(v => v >= max); })();
|
||||
const slot = (W - L) / n, bw = Math.max(2, slot - 2), y = v => T + (H - T - B) * (1 - v / nice);
|
||||
let s = `<svg viewBox="0 0 ${W} ${H}" role="img" aria-label="${title}">`;
|
||||
for (const g of [0, nice / 2, nice]) s += `<line class="grid" x1="${L}" x2="${W}" y1="${y(g)}" y2="${y(g)}"/><text class="ax" x="${L - 4}" y="${y(g) + 3}" text-anchor="end">${g}</text>`;
|
||||
perDay.forEach((d, i) => {
|
||||
const x = L + i * slot + 1, v = d[key], top = y(v), h = (H - B) - top;
|
||||
const label = `${d.day.slice(5)} · ${v} ${unit}`;
|
||||
s += `<rect class="hit" x="${x - 1}" y="${T}" width="${slot}" height="${H - T - B}" fill="transparent" data-tip="${label}"/>`;
|
||||
if (v > 0) s += `<path class="bar" d="M${x},${H - B} V${top + Math.min(4, h)} Q${x},${top} ${x + Math.min(4, bw / 2)},${top} H${x + bw - Math.min(4, bw / 2)} Q${x + bw},${top} ${x + bw},${top + Math.min(4, h)} V${H - B} Z"/>`;
|
||||
if (i % 7 === 0 && i < n - 4) s += `<text class="ax" x="${x + bw / 2}" y="${H - 4}" text-anchor="middle">${d.day.slice(5)}</text>`;
|
||||
if (i === n - 1) s += `<text class="ax" x="${x + bw}" y="${H - 4}" text-anchor="end">${d.day.slice(5)}</text>`;
|
||||
});
|
||||
return `<div class="chart"><h4>${title}</h4>${s}</svg><div class="tip"></div></div>`;
|
||||
};
|
||||
%>
|
||||
<div class="charts">
|
||||
<%- chart('Chat messages per day', 'messages', 'messages') %>
|
||||
<%- chart('Watch hours per day', 'watchHours', 'h') %>
|
||||
</div>
|
||||
|
||||
<h3>Leaderboards</h3>
|
||||
<%
|
||||
const board = (title, rows, fmt, extra, nw) => {
|
||||
let s = `<div class="board${extra ? ' wide' : ''}"${nw ? ` style="--nw:${nw}"` : ''}><h4>${title}</h4>`;
|
||||
if (!rows.length) return s + '<p class="empty">nothing yet</p></div>';
|
||||
s += '<ol>';
|
||||
rows.forEach((r, i) => {
|
||||
const name = (r.name || r.login || '?').replace(/[<>&"]/g, '');
|
||||
s += `<li><span class="r">${i + 1}</span><span class="who"><a href="/stats/viewer?q=${encodeURIComponent(r.login || '')}" title="${name}">${name}</a></span>`
|
||||
+ `${extra ? `<span class="lvl">${extra(r)}</span>` : ''}<span class="n">${fmt(r.n)}</span></li>`;
|
||||
});
|
||||
return s + '</ol></div>';
|
||||
};
|
||||
const hm = m => m >= 60 ? `${Math.floor(m / 60)} h ${m % 60} m` : `${m} m`;
|
||||
%>
|
||||
<div class="boards">
|
||||
<%- board('Points', boards.points, n => n.toLocaleString(), r => r.level) %>
|
||||
<%- board('Watch time', boards.watch, hm, null, '6.4rem') %>
|
||||
<%- board('Chat messages', boards.chat, n => n.toLocaleString()) %>
|
||||
<%- board('Bits', boards.bits, n => n.toLocaleString()) %>
|
||||
<%- board('Channel points spent', boards.channelPoints, n => n.toLocaleString()) %>
|
||||
</div>
|
||||
|
||||
<h3 style="margin-top:1.4rem;">Top emotes</h3>
|
||||
<% if (!emotes.length) { %><p class="empty">nothing yet</p><% } else { %>
|
||||
<div class="emotes">
|
||||
<% for (const e of emotes) {
|
||||
const src = e.source === 'twitch' && e.id ? `https://static-cdn.jtvnw.net/emoticons/v2/${e.id}/default/dark/1.0`
|
||||
: e.source === '7tv' && e.id ? `https://cdn.7tv.app/emote/${e.id}/1x.webp` : null; %>
|
||||
<span class="emote" title="<%= e.emote %> · <%= e.source %>"><% if (src) { %><img src="<%= src %>" alt="" loading="lazy"><% } %><%= e.emote %> <strong><%= e.uses.toLocaleString() %></strong></span>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<h3 style="margin-top:1.4rem;">Top commands</h3>
|
||||
<% if (!commands.length) { %><p class="empty">nothing yet</p><% } else { %>
|
||||
<div class="emotes"><% for (const c of commands) { %><span class="emote" style="padding-left:.6rem;"><code><%= c.command %></code> <strong><%= c.uses.toLocaleString() %></strong></span><% } %></div>
|
||||
<% } %>
|
||||
|
||||
<script>
|
||||
// bar hover tooltips (per day)
|
||||
document.querySelectorAll('.chart').forEach(ch => {
|
||||
const tip = ch.querySelector('.tip');
|
||||
ch.querySelectorAll('.hit').forEach(h => {
|
||||
h.addEventListener('mouseenter', () => { tip.textContent = h.dataset.tip; tip.style.display = 'block'; });
|
||||
h.addEventListener('mousemove', e => { const r = ch.getBoundingClientRect(); tip.style.left = (e.clientX - r.left + 12) + 'px'; tip.style.top = (e.clientY - r.top - 28) + 'px'; });
|
||||
h.addEventListener('mouseleave', () => { tip.style.display = 'none'; });
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<%- include('_statsbody', { s, q, base: '/stats', viewerHref: '/stats/viewer?q=', mode: 'admin', view, ranks, tz,
|
||||
extraBoards: [{ title: 'Points · all time', rows: pointsBoard, level: x => x.level, wide: true }] }) %>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<style>
|
||||
.meta { color:var(--pico-muted-color); font-size:.85rem; }
|
||||
.card { border:1px solid var(--pico-muted-border-color); border-radius:12px; padding:.8rem 1rem; margin-bottom:1rem; }
|
||||
.tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:.6rem; }
|
||||
.tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(175px, 1fr)); gap:.6rem; }
|
||||
.tile { border:1px solid var(--pico-muted-border-color); border-radius:12px; padding:.6rem .8rem; }
|
||||
.tile .v { font-size:1.5rem; font-weight:700; line-height:1.1; }
|
||||
.tile .v { font-size:1.2rem; font-weight:700; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||
.tile .k { font-size:.8rem; color:var(--pico-muted-color); }
|
||||
.parts { display:flex; flex-wrap:wrap; gap:.4rem; margin-top:.6rem; }
|
||||
.part { border:1px solid var(--pico-muted-border-color); border-radius:99px; padding:.1rem .6rem; font-size:.8rem; }
|
||||
|
|
@ -12,31 +12,119 @@
|
|||
.emote img { width:24px; height:24px; object-fit:contain; }
|
||||
table { font-size:.85rem; }
|
||||
.btn-sm { margin:0; padding:.25rem .7rem; font-size:.8rem; width:auto; }
|
||||
.head { display:flex; align-items:flex-start; gap:1rem; }
|
||||
.head h2 { margin:0 0 .2rem; }
|
||||
.roles { display:flex; flex-wrap:wrap; gap:.35rem; margin:.3rem 0 .8rem; align-items:center; }
|
||||
.role { font-size:.72rem; font-weight:700; padding:.12rem .55rem; border-radius:99px; border:1px solid var(--pico-muted-border-color); }
|
||||
.role.broadcaster { background:#7a1a1a; border-color:#7a1a1a; color:#f6c8c8; }
|
||||
.role.moderator { background:#0d5d22; border-color:#0d5d22; color:#b9f0c6; }
|
||||
.role.vip { background:#7a1a6e; border-color:#7a1a6e; color:#f3c4ec; }
|
||||
.role.subscriber, .role.founder { background:#3b2a7a; border-color:#3b2a7a; color:#d6ccff; }
|
||||
/* ⋯ menu: rarely used things (public page, rename, forget) */
|
||||
.more { position:relative; margin-left:auto; }
|
||||
.more > summary { list-style:none; cursor:pointer; padding:.1rem .7rem; border:1px solid var(--pico-muted-border-color); border-radius:8px; font-size:1.2rem; line-height:1.3; }
|
||||
.more > summary::-webkit-details-marker { display:none; }
|
||||
.more > summary::after { display:none !important; }
|
||||
.more .menu { position:absolute; right:0; top:calc(100% + .3rem); z-index:10; width:320px; background:var(--pico-card-background-color);
|
||||
border:1px solid var(--pico-muted-border-color); border-radius:12px; box-shadow:0 10px 24px rgba(0,0,0,.4); padding:.4rem; }
|
||||
.menu form { margin:0; padding:.5rem .55rem; border-bottom:1px solid var(--pico-muted-border-color); }
|
||||
.menu form:last-child { border-bottom:0; }
|
||||
.menu .lbl { display:block; font-size:.78rem; color:var(--pico-muted-color); margin-bottom:.35rem; }
|
||||
.menu .row { display:flex; gap:.4rem; align-items:center; }
|
||||
.menu input { margin:0; padding:.25rem .5rem; font-size:.85rem; height:auto; }
|
||||
</style>
|
||||
|
||||
<p><a href="/stats">← Stats</a></p>
|
||||
<% if (!viewer) { %>
|
||||
<h2><%= q %></h2>
|
||||
<p class="meta">No statistics for this viewer (yet). Names are Twitch logins, e.g. <code>channel</code>.</p>
|
||||
<p class="meta">No statistics for this viewer (yet). Names are Twitch logins, e.g. <code>some_viewer</code>.</p>
|
||||
<% } else {
|
||||
const hm = m => m >= 60 ? `${Math.floor(m / 60)} h ${m % 60} m` : `${m} m`;
|
||||
const minutes = (viewer.watch.ticks || 0) * 5 + (viewer.importedMinutes || 0); %>
|
||||
<h2 style="margin-bottom:.2rem;"><%= viewer.name %> <span class="meta">@<%= viewer.login %></span></h2>
|
||||
<p class="meta"><%= viewer.level.name %>
|
||||
<% if (viewer.hidden) { %> · <span class="badge badge-grey" title="In Settings → Hidden chatters: counted, but not shown in leaderboards">hidden bot</span><% } %>
|
||||
<% if (viewer.chat.first_seen) { %> · first chat <%= viewer.chat.first_seen.slice(0, 10) %>, last <%= viewer.chat.last_seen.slice(0, 10) %><% } %>
|
||||
</p>
|
||||
const num = n => Number(n || 0).toLocaleString('en-US');
|
||||
const minutes = (viewer.watch.ticks || 0) * 5 + (viewer.importedMinutes || 0);
|
||||
const tw = viewer.twitch, b = viewer.badges;
|
||||
// how long ago, in words: "2 years 3 months", "5 months", "12 days"
|
||||
const ago = iso => {
|
||||
const a = new Date(iso), n = new Date();
|
||||
let months = (n.getUTCFullYear() - a.getUTCFullYear()) * 12 + n.getUTCMonth() - a.getUTCMonth() - (n.getUTCDate() < a.getUTCDate() ? 1 : 0);
|
||||
if (months < 1) { const d = Math.floor((n - a) / 864e5); return `${d} day${d === 1 ? '' : 's'}`; }
|
||||
const y = Math.floor(months / 12), m = months % 12;
|
||||
return [y ? `${y} y` : '', m ? `${m} mo` : ''].filter(Boolean).join(' ');
|
||||
};
|
||||
const TIER = { 1000: 'Tier 1', 2000: 'Tier 2', 3000: 'Tier 3' };
|
||||
// roles: synced from Twitch (mods / VIPs / subs) + chat badges from their last message (founder, artist, ...)
|
||||
const roles = new Map();
|
||||
const BADGE = { broadcaster: 'Broadcaster', moderator: 'Moderator', vip: 'VIP', founder: 'Founder', 'artist-badge': 'Artist', subscriber: 'Subscriber', 'lead_moderator': 'Lead moderator' };
|
||||
for (const x of b.list) if (BADGE[x.set]) roles.set(x.set, `${BADGE[x.set]} (chat badge${b.at ? `, ${b.at.slice(0, 10)}` : ''})`);
|
||||
for (const r of tw.roles) roles.set(r, `${BADGE[r] || r} (from Twitch)`);
|
||||
if (tw.sub) roles.set('subscriber', `${TIER[tw.sub.tier] || 'Subscriber'}${tw.sub.is_gift ? ` · gifted by ${tw.sub.gifter_name || tw.sub.gifter_login}` : ''} (from Twitch)`);
|
||||
const subMonths = b.subMonths || viewer.given.subMonths || null; %>
|
||||
|
||||
<div class="head">
|
||||
<div>
|
||||
<h2><%= viewer.name %> <span class="meta">@<%= viewer.login %></span></h2>
|
||||
<div class="roles">
|
||||
<a href="https://twitch.tv/<%= encodeURIComponent(viewer.login) %>" target="_blank" rel="noopener" class="meta">twitch.tv/<%= viewer.login %> ↗</a>
|
||||
<span class="role" title="Level by watch time"><%= viewer.level.name %></span>
|
||||
<% for (const [set, tip] of roles) { %><span class="role <%= set %>" title="<%= tip %>"><%= set === 'subscriber' && tw.sub ? (TIER[tw.sub.tier] || 'Sub') + ' sub' : BADGE[set] || set %></span><% } %>
|
||||
<% if (viewer.hidden) { %><span class="role" title="In Settings → Hidden chatters: counted, but not shown in leaderboards">hidden bot</span><% } %>
|
||||
<% if (viewer.publicHidden) { %><span class="role" title="Opted out of the public stats page (!hideme)">not on public page</span><% } %>
|
||||
</div>
|
||||
</div>
|
||||
<details class="more">
|
||||
<summary title="More">⋯</summary>
|
||||
<div class="menu">
|
||||
<form method="POST" action="/stats/viewer/public"
|
||||
title="The public stats page never names viewers who opted out (they typed !hideme in chat, or you set it here). They still count in the totals. !showme brings them back.">
|
||||
<input type="hidden" name="login" value="<%= viewer.login %>">
|
||||
<input type="hidden" name="user_id" value="<%= viewer.user_id || '' %>">
|
||||
<input type="hidden" name="hide" value="<%= viewer.publicHidden ? '0' : '1' %>">
|
||||
<span class="lbl">Public page: <strong><%= viewer.publicHidden ? 'not named (opted out)' : viewer.hidden ? 'not shown (hidden bot)' : 'shown' %></strong> ⓘ</span>
|
||||
<button type="submit" class="outline btn-sm"><%= viewer.publicHidden ? 'Show again' : 'Leave out of the public page' %></button>
|
||||
</form>
|
||||
<% if (viewer.importedMinutes && !viewer.user_id) { %>
|
||||
<form method="POST" action="/stats/viewer/rename"
|
||||
title="This viewer is only known from StreamElements' watch time (by name, from before HeyStreamer counted). If they renamed on Twitch, those minutes move to the new name.">
|
||||
<input type="hidden" name="from" value="<%= viewer.login %>">
|
||||
<span class="lbl">Renamed on Twitch? ⓘ</span>
|
||||
<div class="row"><input name="to" required pattern="@?\w{2,25}" placeholder="new Twitch login"><button type="submit" class="outline btn-sm">Move</button></div>
|
||||
</form>
|
||||
<% } %>
|
||||
<form method="POST" action="/stats/viewer/forget">
|
||||
<input type="hidden" name="login" value="<%= viewer.login %>">
|
||||
<input type="hidden" name="user_id" value="<%= viewer.user_id || '' %>">
|
||||
<span class="lbl" title="For removal requests: deletes all of this viewer's statistics, watch time, stored chat and activity-log entries. Cannot be undone.">Removal request ⓘ</span>
|
||||
<button type="button" data-confirm class="outline btn-sm" style="color:#f88; border-color:#f88;">Forget this viewer</button>
|
||||
</form>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="tiles">
|
||||
<div class="tile"><div class="v"><%= viewer.total.toLocaleString() %></div><div class="k">points</div></div>
|
||||
<div class="tile" title="<%= viewer.importedMinutes ? `includes ${hm(viewer.importedMinutes)} imported from StreamElements` : '' %>"><div class="v"><%= hm(minutes) %></div><div class="k">watched<%= viewer.importedMinutes ? ' · incl. StreamElements' : '' %></div></div>
|
||||
<div class="tile"><div class="v"><%= (viewer.chat.messages || 0).toLocaleString() %></div><div class="k">chat messages</div></div>
|
||||
<div class="tile"><div class="v"><%= num(viewer.total) %></div><div class="k">points</div></div>
|
||||
<div class="tile" title="<%= viewer.importedMinutes ? `includes ${hm(viewer.importedMinutes)} counted by StreamElements before HeyStreamer counted` : '' %>"><div class="v"><%= hm(minutes) %></div><div class="k">watched<%= viewer.importedMinutes ? ' · incl. StreamElements ⓘ' : '' %></div></div>
|
||||
<div class="tile"><div class="v"><%= num(viewer.chat.messages) %></div><div class="k">chat messages</div></div>
|
||||
<div class="tile"><div class="v"><%= viewer.checkins %></div><div class="k">check-ins</div></div>
|
||||
<div class="tile" title="<%= tw.follower ? `Following since ${tw.follower.followed_at.slice(0, 10)}${tw.follower.unfollowed_at ? `; unfollowed around ${tw.follower.unfollowed_at.slice(0, 10)}` : ''}` : 'Not in the follower list from the last sync with Twitch' %>">
|
||||
<div class="v"><%= tw.follower && !tw.follower.unfollowed_at ? ago(tw.follower.followed_at) : tw.follower ? 'unfollowed' : '—' %></div>
|
||||
<div class="k"><%= tw.follower && !tw.follower.unfollowed_at ? `following since ${tw.follower.followed_at.slice(0, 10)}` : 'not following' %> ⓘ</div>
|
||||
</div>
|
||||
<div class="tile" title="<%= tw.sub ? `Subscribed now (${TIER[tw.sub.tier] || tw.sub.tier}${tw.sub.is_gift ? `, gift from ${tw.sub.gifter_name || tw.sub.gifter_login}` : ''})` : 'Not subscribed at the last sync with Twitch' %>. Months come from their sub badge in chat or their resub messages; Twitch has no sub history for other viewers.">
|
||||
<div class="v"><%= tw.sub ? (TIER[tw.sub.tier] || 'Sub') : 'no sub' %><%= subMonths ? ` · ${subMonths} mo` : '' %></div>
|
||||
<div class="k"><%= tw.sub ? (tw.sub.is_gift ? 'gifted sub' : 'subscribed now') : subMonths ? 'subscribed before' : 'subscription' %> ⓘ</div>
|
||||
</div>
|
||||
<div class="tile" title="<%= tw.bits ? `Twitch all-time leaderboard: rank ${tw.bits.rank}` : 'Not in Twitch\'s top 100 all-time cheerers' %>. Counted by HeyStreamer: <%= num(viewer.given.bits) %> bits.">
|
||||
<div class="v"><%= num(Math.max(tw.bits?.score || 0, viewer.given.bits)) %></div><div class="k">bits given<%= tw.bits ? ` · #${tw.bits.rank}` : '' %> ⓘ</div>
|
||||
</div>
|
||||
<div class="tile"><div class="v"><%= num(viewer.given.gifts) %></div><div class="k">subs gifted</div></div>
|
||||
</div>
|
||||
<div class="parts" title="Where the points come from (values in docs/PLANS.md)">
|
||||
<% for (const [k, v] of Object.entries(viewer.parts).sort((a, b) => b[1] - a[1])) { %><span class="part"><%= k %>: <strong><%= v.toLocaleString() %></strong></span><% } %>
|
||||
<% for (const [k, v] of Object.entries(viewer.parts).sort((a, b) => b[1] - a[1])) { %><span class="part"><%= k %>: <strong><%= num(v) %></strong></span><% } %>
|
||||
</div>
|
||||
<p class="meta" style="margin:.6rem 0 0;">
|
||||
<% if (viewer.chat.first_seen) { %>First chat <%= viewer.chat.first_seen.slice(0, 10) %>, last <%= viewer.chat.last_seen.slice(0, 10) %>.<% } %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<% if (viewer.emotes.length) { %>
|
||||
|
|
@ -67,20 +155,4 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<% } %>
|
||||
|
||||
<% if (viewer.importedMinutes && !viewer.user_id) { %>
|
||||
<form method="POST" action="/stats/viewer/rename" style="display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-top:1.5rem;"
|
||||
title="This viewer is only known from the StreamElements import (by name). If they renamed on Twitch, their imported watch time moves to the new name, and importing again later applies the rename too.">
|
||||
<input type="hidden" name="from" value="<%= viewer.login %>">
|
||||
<span class="meta">Renamed on Twitch? New name:</span>
|
||||
<input name="to" required pattern="@?\w{2,25}" placeholder="new Twitch login" style="width:14rem; margin:0; padding:.25rem .5rem; font-size:.85rem; height:auto;">
|
||||
<button type="submit" class="outline btn-sm">Move</button>
|
||||
</form>
|
||||
<% } %>
|
||||
<form method="POST" action="/stats/viewer/forget" style="margin-top:1rem;">
|
||||
<input type="hidden" name="login" value="<%= viewer.login %>">
|
||||
<input type="hidden" name="user_id" value="<%= viewer.user_id || '' %>">
|
||||
<button type="button" data-confirm class="outline btn-sm" style="color:#f88; border-color:#f88;"
|
||||
title="For removal requests: deletes all of this viewer's statistics, watch time, stored chat and activity-log entries. Cannot be undone.">Forget this viewer</button>
|
||||
</form>
|
||||
<% } %>
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
<div>
|
||||
<div class="card">
|
||||
<h4>Test</h4>
|
||||
<textarea id="text" rows="3" maxlength="<%= maxChars %>">Streamer! Hydrate check. Also, nice shot. I was totally not camping that container.</textarea>
|
||||
<textarea id="text" rows="3" maxlength="<%= maxChars %>">Hydrate check! Also, nice shot. I was totally not camping that container.</textarea>
|
||||
<div class="row">
|
||||
<button type="button" id="play" class="btn-sm">▶ Play</button>
|
||||
<button type="button" id="stop" class="outline secondary btn-sm">■ Stop</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue