-
-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathseptapus.html
671 lines (586 loc) · 20.5 KB
/
septapus.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chat Overlay - Septapus CSS Compatible</title>
<meta name="title" content="Social Stream - Septapus compatible overlay" />
<link rel="icon" href="./favicon.ico" />
<link href="https://fonts.googleapis.com/css2?family=Changa+One:ital@0;1&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Changa+One:ital@0;1&family=Imprima&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<style>
yt-live-chat-renderer {
height: 100%;
display: block;
outline: 1px #999 dashed;
overflow: hidden; /* Add this */
}
yt-live-chat-item-list-renderer {
overflow-y: auto;
height: calc(100% - 32px); /* Change from max-height: 100vh */
display: flex;
flex-direction: column-reverse;
}
body, html {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
font-family: 'Arial', sans;
}
yt-live-chat-text-message-renderer {
position: relative;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: row;
-webkit-flex-direction: row;
flex-direction: row;
-ms-flex-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
padding: 4px 24px;
}
yt-live-chat-text-message-renderer #content {
-ms-align-self: center;
-webkit-align-self: center;
align-self: center;
overflow: hidden;
}
yt-live-chat-text-message-renderer #timestamp {
display: none;
margin-right: 8px;
}
yt-live-chat-text-message-renderer #author-name {
margin-right: 8px;
font-weight: 500;
}
yt-live-chat-text-message-renderer #author-photo {
display: inline-block;
background-color: red;
-ms-flex: none;
-webkit-flex: none;
flex: none;
}
yt-live-chat-text-message-renderer #author-badges {
vertical-align: text-bottom;
display: -ms-inline-flexbox;
display: -webkit-inline-flex;
display: inline-flex;
}
yt-live-chat-text-message-renderer #message {
color: #fff;
font-size: 12px;
line-height: 16px;
word-wrap: break-word;
}
yt-live-chat-author-badge-renderer {
display: block;
width: 16px;
height: 16px;
background-color: currentColor;
margin-right: 4px;
border-radius: 16px;
}
yt-live-chat-legacy-paid-message-renderer {
position: relative;
overflow: hidden;
margin: 8px 24px;
padding: 8px 16px;
background-color: #0f9d58;
border-radius: 4px;
color: #fff;
font-size: 14px;
min-height: 40px;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: row;
-webkit-flex-direction: row;
flex-direction: row;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
yt-live-chat-moderation-message-renderer {
display: none;
}
yt-live-chat-legacy-paid-message-renderer #author-photo {
background-color: red;
margin-right: 16px;
overflow: hidden;
-ms-flex: none;
-webkit-flex: none;
flex: none;
-ms-align-self: flex-start;
-webkit-align-self: flex-start;
align-self: flex-start;
}
yt-live-chat-legacy-paid-message-renderer #content {
-ms-flex: 1 1 0.000000001px;
-webkit-flex: 1;
flex: 1;
-webkit-flex-basis: 0.000000001px;
flex-basis: 0.000000001px;
}
yt-live-chat-legacy-paid-message-renderer #event-text {
font-weight: 500;
}
yt-live-chat-legacy-paid-message-renderer #detail-text {
word-wrap: break-word;
}
yt-live-chat-paid-message-renderer {
position: relative;
border-radius: 4px;
margin: 8px 24px;
font-size: 15px;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: column;
-webkit-flex-direction: column;
flex-direction: column;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
yt-live-chat-paid-message-renderer #header {
position: relative;
font-weight: 500;
padding: 8px 16px;
min-height: 20px;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: row;
-webkit-flex-direction: row;
flex-direction: row;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
yt-live-chat-paid-message-renderer #header-content {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: column;
-webkit-flex-direction: column;
flex-direction: column;
-ms-flex-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
-ms-flex: 1 1 0.000000001px;
-webkit-flex: 1;
flex: 1;
-webkit-flex-basis: 0.000000001px;
flex-basis: 0.000000001px;
}
yt-live-chat-paid-message-renderer #author-photo {
background-color: red;
-ms-flex: none;
-webkit-flex: none;
flex: none;
}
yt-live-chat-paid-message-renderer #author-name {
font-size: 14px;
}
yt-live-chat-paid-message-renderer #content {
padding: 4px 16px 8px 16px;
word-wrap: break-word;
word-break: break-word;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
yt-live-chat-ticker-paid-message-item-renderer {
display: inline-block;
height: 24px;
border-radius: 200px;
padding: 4px;
}
yt-live-chat-ticker-paid-message-item-renderer #content {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: row;
-webkit-flex-direction: row;
flex-direction: row;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
margin-right: 4px;
opacity: 1;
transition: opacity 0.5s ease-out;
}
img,
svg {
max-height: 1em;
width: auto;
vertical-align: text-bottom;
}
.setup-container {
max-width: 600px;
margin: 20px auto;
padding: 20px;
font-family: 'Roboto', sans-serif;
overflow-y: auto;
height: 100%;
margin-bottom: 40px;
}
.setup-container input, .setup-container textarea {
width: 100%;
margin: 8px 0;
padding: 8px;
}
.setup-container textarea {
height: 200px;
font-family: monospace;
}
.setup-container button:hover {
background: #0b8043;
}
.setup-container h2 {
margin-top: 20px;
}
.setup-container .notes {
margin-top: 30px;
padding: 15px;
background: #f5f5f5;
border-left: 4px solid #0f9d58;
font-size: 14px;
line-height: 1.4;
margin-bottom: 100px;
}
.setup-container .notes p {
margin: 8px 0;
}
.setup-container .notes strong {
color: #0f9d58;
}
.notes {
font-family: 'YouTube Noto', Roboto, Arial, sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 20px;
background: rgba(0, 0, 0, 0.05);
border-radius: 8px;
color: #0f0f0f;
}
.notes h2 {
font-size: 18px;
margin-bottom: 16px;
color: #0f0f0f;
font-weight: 500;
}
.notes ul {
list-style: none;
padding: 0;
margin: 0;
}
.notes li {
margin-bottom: 12px;
line-height: 1.4;
padding-left: 24px;
position: relative;
}
.notes li::before {
content: "•";
position: absolute;
left: 8px;
color: #065fd4;
}
.notes .sub-list {
margin: 8px 0 12px 24px;
}
.notes .sub-list li::before {
content: "–";
}
.notes a {
color: #065fd4;
text-decoration: none;
font-weight: 500;
transition: color 0.2s;
}
.notes a:hover {
color: #0143a3;
text-decoration: underline;
}
.notes .highlight {
background: #ffd70020;
padding: 2px 4px;
border-radius: 3px;
}
</style>
</head>
<yt-live-chat-renderer>
<yt-live-chat-ticker-renderer></yt-live-chat-ticker-renderer>
<yt-live-chat-item-list-renderer></yt-live-chat-item-list-renderer>
</yt-live-chat-renderer>
<script>
function minifyCSS(css) {
if (typeof css !== 'string') {
return '';
}
const preserveTokens = {
mediaQueries: /@media[^{]+\{([\s\S]+?\})\s*\}/g,
keyframes: /@(?:-webkit-)?keyframes[^{]+\{([\s\S]+?\})\s*\}/g,
urls: /url\([^\)]+\)/g,
imports: /@import[^;]+;/g
};
let preserved = [];
let cssString = css;
// Preserve special blocks by replacing them with placeholders
Object.entries(preserveTokens).forEach(([key, regex]) => {
cssString = cssString.replace(regex, match => {
preserved.push(match);
return `___${preserved.length - 1}___`;
});
});
// Main minification
cssString = cssString
.replace(/\/\*(?!\*\/)[\s\S]*?\*\//g, '') // Remove comments safely
.replace(/\s*([\{\}\:\;\,])\s*/g, '$1') // Remove spaces around special characters
.replace(/\s+/g, ' ') // Consolidate spaces
.replace(/\s*([>+~])\s*/g, '$1') // Clean combinators
.replace(/;(?=\s*})/g, '') // Remove last semicolons
.replace(/\s*(!important)/g, '$1') // Clean important
.replace(/\s*([{:;,])\s*/g, '$1') // Clean special chars
.replace(/^\s+|\s+$/g, ''); // Trim
// Restore preserved blocks
preserved.forEach((block, i) => {
cssString = cssString.replace(`___${i}___`, block);
});
return cssString.trim();
}
function loadGoogleFont(fontName) {
const formattedFontName = fontName.replace(/\s/g, "+");
const link = document.createElement("link");
link.href = `https://fonts.googleapis.com/css2?family=${formattedFontName}&display=swap`;
link.rel = "stylesheet";
document.head.appendChild(link);
var currentFont = getComputedStyle(document.documentElement).getPropertyValue("--font-family").trim();
document.documentElement.style.setProperty("--font-family", "'" + fontName.replaceAll("+", " ") + "', " + currentFont);
}
function applySettings() {
const sessionId = document.getElementById('sessionId').value.trim();
const password = document.getElementById('password').value.trim();
const css = document.getElementById('customCss').value.trim();
if (!sessionId) {
alert('Please enter a Session ID');
return;
}
let url = '?' + new URLSearchParams({session: sessionId}).toString();
if (password) {
url += '&password=' + encodeURIComponent(password);
}
if (css) {
const base64Css = btoa(encodeURIComponent(minifyCSS(css)));
url += '&base64css=' + base64Css;
}
if (url.length>2000){
url = url.slice(0, 2000); // trim
alert("URL is too long; trimming it down to fit..\n\nConsider inserting the style via OBS browser's style section instead or shortening the CSS injected.");
}
window.location.href = url;
}
var urlParams = new URLSearchParams(window.location.search);
const hasSession = urlParams.has("session");
if (!hasSession) {
document.body.innerHTML = `
<div class="setup-container">
<h1>YouTube Structured Chat Overlay</h1>
<p>Need help creating custom CSS? Visit:
<a href="https://chatv2.septapus.com/" target="_blank">https://chatv2.septapus.com/</a>
</p>
<h2>Configuration</h2>
<input type="text" id="sessionId" placeholder="Enter Session ID" />
<input type="text" id="password" placeholder="Password (optional)" />
<h2>Custom CSS</h2>
<textarea id="customCss" placeholder="Paste your CSS here"></textarea>
<br><br>
<button onclick="applySettings()">Load Overlay</button>
<div class="notes">
<h2>Important Notes</h2>
<ul>
<li>This overlay renders messages in a YouTube-style format, allowing YouTube CSS to be applied directly.</li>
<li>Messages come from <a href="https://socialstream.ninja" target="_blank" rel="noopener noreferrer">SocialStream.Ninja</a> - visit the website to get started.</li>
<li>This overlay differs from the standard SocialStream.Ninja dock.html, using YouTube's structure for enhanced style compatibility.</li>
<li>Most URL parameters commonly used with dock.html are <span class="highlight">not compatible</span> with this overlay, although <b>&googlefont=xxx</b> is compatible</li>
<li>Message formatting may not exactly match YouTube's structure due to SocialStream.Ninja consolidating content from multiple platforms.</li>
<li>If the CSS you're injecting is too long, it might not work via the URL. It should still work via OBS's style section however..</li>
<li>Some features have limited support:
<ul class="sub-list">
<li>7TV zero-width emotes may not display correctly</li>
<li>Membership displays may be inconsistent</li>
<li>Platform-specific features might not translate perfectly</li>
</ul>
</li>
</ul>
</div>
</div>`;
} else {
var roomID = "iWWnKL28tQ";
if (urlParams.has("session")) {
roomID = urlParams.get("session");
}
var password = "false";
var featuredMode = false;
const chatList = document.querySelector('yt-live-chat-item-list-renderer');
const tickerList = document.querySelector('yt-live-chat-ticker-renderer');
const MAX_VISIBLE_TICKERS = 6;
const BASE_DISPLAY_DURATION = 10000; // 10 seconds base duration
const DURATION_PER_DOLLAR = 1000; // Additional 1 second per dollar
if (urlParams.get("font")) {
document.documentElement.style.setProperty("--font-family", urlParams.get("font") + ", Avenir Next, Sora, Roboto, Helvetica, Geneva, Verdana, Arial, sans-serif");
}
if (urlParams.get("googlefont")) {
loadGoogleFont(urlParams.get("googlefont"));
}
if (urlParams.has("css")) {
var cssURL = urlParams.get("css");
try {
cssURL = decodeURI(cssURL);
} catch (e) {}
document.addEventListener('DOMContentLoaded', () => {
if (cssURL.startsWith("http")) {
var cssStylesheet = document.createElement("link");
cssStylesheet.rel = "stylesheet";
cssStylesheet.type = "text/css";
cssStylesheet.media = "screen";
cssStylesheet.href = cssURL;
document.body.appendChild(cssStylesheet);
} else {
var cssStylesheet = document.createElement("style");
cssStylesheet.innerHTML = cssURL;
document.body.appendChild(cssStylesheet);
}
});
}
if (urlParams.has("base64css") || urlParams.has("b64css") || urlParams.has("cssbase64") || urlParams.has("cssb64")) {
try {
var base64Css = urlParams.get("base64css") || urlParams.get("b64css") || urlParams.get("cssbase64") || urlParams.get("cssb64");
try {
base64Css = atob(base64Css);
} catch (e) {}
try {
base64Css = decodeURIComponent(base64Css);
} catch (e) {}
document.addEventListener('DOMContentLoaded', () => {
var cssStyleSheet = document.createElement("style");
cssStyleSheet.innerText = base64Css;
document.body.appendChild(cssStyleSheet);
});
} catch (e) {
console.error(e);
}
}
// Modified addMessageToOverlay function, focusing on the ticker part
function addMessageToOverlay(data) {
let messageElement;
if (data.hasDonation) {
const amount = parseFloat(data.hasDonation.replace(/[^0-9.]/g, ""));
if (amount >= 5) {
const tickerItem = document.createElement('yt-live-chat-ticker-paid-message-item-renderer');
tickerItem.style.backgroundColor = amount >= 100 ? 'rgba(208,0,0,1)' : 'rgba(0,184,212,1)';
tickerItem.innerHTML = `
<div id="content">
<span id="fake-avatar"></span>
<span>${data.hasDonation}</span>
</div>`;
// Add transition for smooth fade out
tickerItem.style.transition = 'opacity 0.5s ease-out';
// Calculate display duration based on donation amount
const displayDuration = BASE_DISPLAY_DURATION + (amount * DURATION_PER_DOLLAR);
tickerList.appendChild(tickerItem);
// Remove excess tickers
const tickers = Array.from(tickerList.children);
if (tickers.length > MAX_VISIBLE_TICKERS) {
tickers.slice(MAX_VISIBLE_TICKERS).forEach(ticker => {
ticker.style.opacity = '0';
setTimeout(() => ticker.remove(), 500);
});
}
// Set auto-hide timeout
setTimeout(() => {
tickerItem.style.opacity = '0';
setTimeout(() => tickerItem.remove(), 500);
}, displayDuration);
}
messageElement = document.createElement('yt-live-chat-paid-message-renderer');
const color = amount >= 100 ? 'rgba(208,0,0,1)' : 'rgba(0,184,212,1)';
const contentColor = amount >= 100 ? 'rgba(230,33,23,1)' : 'rgba(0,229,255,1)';
messageElement.innerHTML = `
<div id="header" style="background-color: ${color};">
<div id="author-photo" ${data.chatimg ? `style="background-image: url('${data.chatimg}')"` : ''}></div>
<div id="header-content">
<div id="author-name" ${data.nameColor ? `style="color: ${data.nameColor}"` : ''}>${data.chatname}</div>
<div id="purchase-amount">${data.hasDonation}</div>
</div>
</div>
<div id="content" style="background-color: ${contentColor};">
<div id="message" dir="auto">${data.chatmessage || ''}</div>
</div>`;
} else if (data.membership) {
messageElement = document.createElement('yt-live-chat-legacy-paid-message-renderer');
messageElement.innerHTML = `
<div id="author-photo" ${data.chatimg ? `style="background-image: url('${data.chatimg}')"` : ''}></div>
<div id="content">
<div id="event-text">NEW SPONSOR!</div>
<div id="detail-text">Welcome <span class="mention">${data.chatname}</span>!</div>
</div>`;
} else {
messageElement = document.createElement('yt-live-chat-text-message-renderer');
let authorType = '';
if (data.moderator || data.mod) authorType = 'moderator';
else if (data.admin || data.host || data.owner) authorType = 'owner';
else if (data.membership || data.hasMembership || data.member) authorType = 'member';
else if (data.bot ) authorType = 'bot';
if (authorType) messageElement.setAttribute('author-type', authorType);
messageElement.innerHTML = `
<div id="author-photo" ${data.chatimg ? `style="background-image: url('${data.chatimg}')"` : ''}></div>
<div id="content">
<span id="timestamp">12:00</span>
${authorType ? `<span id="author-badges"><yt-live-chat-author-badge-renderer type="${authorType}"></yt-live-chat-author-badge-renderer></span>` : ''}
${data.chatbadges ? data.chatbadges.map(badge => {
if (typeof badge === "object") {
if (badge.type === "img" && badge.src) {
return `<img class='badge' src='${badge.src}' />`;
} else if (badge.type === "svg" && badge.html) {
return `<span class='badge svg'>${badge.html}</span>`;
}
} else {
return `<img class='badge' src='${badge}' />`;
}
return '';
}).join('') : ''}
<span id="author-name" ${authorType ? `type="${authorType}"` : ''} ${data.nameColor ? `style="color: ${data.nameColor}"` : ''}>${data.chatname}</span>
<span id="message" ${data.textColor ? `style="color: ${data.textColor}"` : ''}>${data.chatmessage || ''}</span>
</div>`;
}
if (data.mid) {
messageElement.id = data.mid;
}
chatList.prepend(messageElement);
while (chatList.children.length > 20) {
chatList.removeChild(chatList.lastChild);
}
}
document.addEventListener('DOMContentLoaded', () => {
var iframe = document.createElement("iframe");
if (featuredMode) {
iframe.src = `https://vdo.socialstream.ninja/?ln&password=${password}&salt=vdo.ninja&label=overlay&exclude=${roomID}&scene&novideo&noaudio&cleanoutput&room=${roomID}`;
} else {
iframe.src = "https://vdo.socialstream.ninja/?ln&salt=vdo.ninja&password="+password+"&push&label=dock&vd=0&ad=0&novideo&noaudio&autostart&cleanoutput&room="+roomID;
}
iframe.style.cssText = "width: 0px; height: 0px; position: fixed; left: -100px; top: -100px;";
document.body.appendChild(iframe);
window.addEventListener("message", function (e) {
if (e.source != iframe.contentWindow) return;
if (e.data.dataReceived && e.data.dataReceived.overlayNinja) {
addMessageToOverlay(e.data.dataReceived.overlayNinja);
}
});
});
}
</script>
</html>