Skip to content

Commit 7675c8f

Browse files
committed
truncate long reply context if wrapped, small fixes, meta tags
1 parent 15531d7 commit 7675c8f

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

tchat.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<!doctype html>
22
<html lang=en>
33
<meta charset=utf-8>
4+
<meta name=application-name content="tChat – Chat overlay for Twitch">
5+
<meta name=author content=crazysmc>
6+
<meta name=description
7+
content="Twitch chat overlay with all emotes and pronouns support">
8+
<meta name=keywords
9+
content=twitch,shared,chat,stream,overlay,7tv,bttv,ffz,betterttv,frankerfacez,pronouns,alejo,emotes,effects,badges,paints
10+
>
411
<meta name=viewport content="width=device-width">
12+
<meta name=robots content=index>
513
<title>crazysmc – tChat – Chat overlay for Twitch</title>
614
<base target=_blank>
715
<link rel=stylesheet href=tchat/style.css>
@@ -172,8 +180,9 @@ <h1>tChat – Twitch chat overlay for OBS or browser</h1>
172180
animated ones if enabled in 7TV.
173181
You can also join several channels simultaneously and get a combined view.
174182

175-
<p><a href=https://github.com/crazysmc/crazysmc.github.io/tree/master/tchat
176-
>Open source</a>
183+
<p>Runs without a backend, fully in Javascript.
184+
<a href=https://github.com/crazysmc/crazysmc.github.io/tree/master/tchat
185+
>Open source</a>
177186

178187
<hr>
179188

@@ -378,8 +387,8 @@ <h2>Custom Styles</h2>
378387
<p>The structure of the document generated by the chat overlay should allow
379388
for great customisability using added CSS snippets.
380389

381-
<p>Adding a new browser source in OBS will give you a default CSS that looks
382-
like this:
390+
<p>Adding a new browser source in OBS will give you a <strong>default</strong>
391+
CSS that looks like this:
383392

384393
<blockquote><code>
385394
body {
@@ -390,7 +399,8 @@ <h2>Custom Styles</h2>
390399

391400
<p>This will make the overlay transparent and make sure it has no scrollbars.
392401

393-
<p>You can add more CSS rules to this; here are some examples.
402+
<p>You can <strong>add</strong> more CSS rules to this; here are some
403+
examples.
394404
Just pick the one you want and append them in the Custom CSS option.
395405
(To make the textbox bigger, you can drag the divider below the preview at the
396406
top upwards.)

tchat/style.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ img {
154154
}
155155

156156
.reply i {
157-
font-size: 0.8em;
158157
float: left;
158+
font-size: 0.8em;
159+
line-height: initial;
160+
margin-top: 0.777778em;
159161
width: 100%;
160162
}
161163

@@ -174,6 +176,10 @@ img {
174176
grid-row-start: 1;
175177
}
176178

179+
.delete {
180+
text-decoration: line-through 0.24em #ff00007f;
181+
}
182+
177183
@media (max-width: 40rem) {
178184
.chat-line { display: block; }
179185
.reply i { float: none; }

tchat/twitch.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const conf = {
77
nick: 'justinfan64537', // same as anonymous chatterino
88
joins: opt.getAll ('join'),
99
timeout: parseInt (opt.get ('time'), 10) * 1000,
10+
maxReplyLen: 100,
1011
emoteStyle: opt.has ('static') ? 'static' : 'default',
1112
emoteScale: ({ 2: '2', 3: '3' })[opt.get ('scale')] ?? '1',
1213
avatarSize: ({ 2: '50x50', 3: '70x70' })[opt.get ('scale')] ?? '28x28',
@@ -99,7 +100,7 @@ function receive (event)
99100
{
100101
for (const del of conf.chat.querySelectorAll
101102
(`.chat-line[data-room-id="${rid}"][data-user-id="${uid}"]`))
102-
del.remove ();
103+
deleteMessage (del);
103104
const seconds = msg.tags['ban-duration'];
104105
const action = seconds
105106
? 'timed out for ' + conf.duration.format ({ seconds })
@@ -111,7 +112,7 @@ function receive (event)
111112
{
112113
for (const del of conf.chat.querySelectorAll
113114
(`.chat-line[data-room-id="${rid}"]`))
114-
del.remove ();
115+
deleteMessage (del);
115116
msg.source = '';
116117
msg.params[1] = 'The chat has been cleared.';
117118
}
@@ -120,8 +121,7 @@ function receive (event)
120121
break;
121122

122123
case 'CLEARMSG':
123-
document.getElementById (msg.tags['target-msg-id'])
124-
?.remove ();
124+
deleteMessage (document.getElementById (msg.tags['target-msg-id']));
125125
break;
126126

127127
case 'JOIN':
@@ -173,6 +173,16 @@ function reduceColors ()
173173
delete conf.colors[uid];
174174
}
175175

176+
function deleteMessage (msg)
177+
{
178+
if (!msg)
179+
return;
180+
if (opt.has ('rm'))
181+
msg.classList.add ('delete');
182+
else
183+
msg.remove ();
184+
}
185+
176186
async function joinedRoom (rid)
177187
{
178188
if (conf.joinedRooms.includes (rid))
@@ -407,10 +417,12 @@ function formatChat (msg, p)
407417
if (msg.tags['msg-param-color'] == 'PRIMARY')
408418
p.style.borderRightColor = conf.badges.room[rid]?.primary ?? '';
409419

410-
const replyTo = msg.tags['reply-parent-msg-body'];
420+
let replyTo = msg.tags['reply-parent-msg-body'];
411421
if (replyTo)
412422
{
413423
const reply = conf.template.reply.cloneNode (true);
424+
if (opt.has ('style', 'wrap') && replyTo.length > conf.maxReplyLen)
425+
replyTo = replyTo.slice (0, conf.maxReplyLen) + '…';
414426
reply.firstElementChild.textContent = replyTo;
415427
const replyMsg = reply.querySelector ('.message');
416428
replyMsg.replaceChildren (...message.childNodes);
@@ -556,6 +568,7 @@ function extEmotes (msg, rid, uid, message)
556568
prefix.previousSibling.remove ();
557569
prefix.classList.remove ('prefix');
558570
prefix.nextSibling.classList.add (...prefix.classList);
571+
prefix.nextSibling.title = prefix.alt + ' ' + prefix.nextSibling.title;
559572
prefix.remove ();
560573
}
561574
}
@@ -569,6 +582,7 @@ function extEmotes (msg, rid, uid, message)
569582
{
570583
suffix.classList.remove ('suffix');
571584
suffix.previousSibling.classList.add (...suffix.classList);
585+
suffix.previousSibling.title += ' ' + suffix.alt;
572586
suffix.remove ();
573587
}
574588
}

0 commit comments

Comments
 (0)