Skip to content

Commit 592b41b

Browse files
committed
For Streamer.bot 1.0.5 beta.6
1 parent eaba2a0 commit 592b41b

5 files changed

Lines changed: 100 additions & 94 deletions

File tree

beta/chat.html

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/simple-notify.min.css">
1414
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/animate.min.css">
1515

16-
<link rel="stylesheet" href="css/chatrd.css?nocache=14">
16+
<link rel="stylesheet" href="css/chatrd.css?nocache=15">
1717
<link id="chatrd-skins" rel="stylesheet" href="css/skin-default.css">
1818

1919
<meta name="robots" content="noindex, nofollow">
@@ -173,47 +173,47 @@
173173
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web/pusher.min.js"></script>
174174
<script src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
175175

176-
<script src="js/i18n-chatrd.js?nocache=14"></script>
176+
<script src="js/i18n-chatrd.js?nocache=15"></script>
177177

178-
<script src="js/speakerbot.js?nocache=14"></script>
179-
<script src="js/sb.js?nocache=14"></script>
180-
<script src="js/queue.js?nocache=14"></script>
178+
<script src="js/speakerbot.js?nocache=15"></script>
179+
<script src="js/sb.js?nocache=15"></script>
180+
<script src="js/queue.js?nocache=15"></script>
181181

182-
<script src="js/chatrd.js?nocache=14"></script>
182+
<script src="js/chatrd.js?nocache=15"></script>
183183

184-
<script src="js/modules/twitch/addon-seventv-paint.js?nocache=14"></script>
185-
<script src="js/modules/twitch/addon-message-effects-canvas.js?nocache=14"></script>
186-
<script src="js/modules/twitch/addon-on-screen-celebration.js?nocache=14"></script>
184+
<script src="js/modules/twitch/addon-seventv-paint.js?nocache=15"></script>
185+
<script src="js/modules/twitch/addon-message-effects-canvas.js?nocache=15"></script>
186+
<script src="js/modules/twitch/addon-on-screen-celebration.js?nocache=15"></script>
187187

188-
<link href="js/modules/twitch/module.css?nocache=14" rel="stylesheet">
189-
<script src="js/modules/twitch/module.js?nocache=14"></script>
188+
<link href="js/modules/twitch/module.css?nocache=15" rel="stylesheet">
189+
<script src="js/modules/twitch/module.js?nocache=15"></script>
190190

191-
<link href="js/modules/youtube/module.css?nocache=14" rel="stylesheet">
192-
<script src="js/modules/youtube/module.js?nocache=14"></script>
191+
<link href="js/modules/youtube/module.css?nocache=15" rel="stylesheet">
192+
<script src="js/modules/youtube/module.js?nocache=15"></script>
193193

194-
<link href="js/modules/tiktok/module.css?nocache=14" rel="stylesheet">
195-
<script src="js/modules/tiktok/module.js?nocache=14"></script>
194+
<link href="js/modules/tiktok/module.css?nocache=15" rel="stylesheet">
195+
<script src="js/modules/tiktok/module.js?nocache=15"></script>
196196

197-
<link href="js/modules/kick/module.css?nocache=14" rel="stylesheet">
198-
<script src="js/modules/kick/module.js?nocache=14"></script>
197+
<link href="js/modules/kick/module.css?nocache=15" rel="stylesheet">
198+
<script src="js/modules/kick/module.js?nocache=15"></script>
199199

200-
<link href="js/modules/streamelements/module.css?nocache=14" rel="stylesheet">
201-
<script src="js/modules/streamelements/module.js?nocache=14"></script>
200+
<link href="js/modules/streamelements/module.css?nocache=15" rel="stylesheet">
201+
<script src="js/modules/streamelements/module.js?nocache=15"></script>
202202

203-
<link href="js/modules/streamlabs/module.css?nocache=14" rel="stylesheet">
204-
<script src="js/modules/streamlabs/module.js?nocache=14"></script>
203+
<link href="js/modules/streamlabs/module.css?nocache=15" rel="stylesheet">
204+
<script src="js/modules/streamlabs/module.js?nocache=15"></script>
205205

206-
<link href="js/modules/patreon/module.css?nocache=14" rel="stylesheet">
207-
<script src="js/modules/patreon/module.js?nocache=14"></script>
206+
<link href="js/modules/patreon/module.css?nocache=15" rel="stylesheet">
207+
<script src="js/modules/patreon/module.js?nocache=15"></script>
208208

209-
<link href="js/modules/tipeeestream/module.css?nocache=14" rel="stylesheet">
210-
<script src="js/modules/tipeeestream/module.js?nocache=14"></script>
209+
<link href="js/modules/tipeeestream/module.css?nocache=15" rel="stylesheet">
210+
<script src="js/modules/tipeeestream/module.js?nocache=15"></script>
211211

212-
<link href="js/modules/kofi/module.css?nocache=14" rel="stylesheet">
213-
<script src="js/modules/kofi/module.js?nocache=14"></script>
212+
<link href="js/modules/kofi/module.css?nocache=15" rel="stylesheet">
213+
<script src="js/modules/kofi/module.js?nocache=15"></script>
214214

215-
<link href="js/modules/fourthwall/module.css?nocache=14" rel="stylesheet">
216-
<script src="js/modules/fourthwall/module.js?nocache=14"></script>
215+
<link href="js/modules/fourthwall/module.css?nocache=15" rel="stylesheet">
216+
<script src="js/modules/fourthwall/module.js?nocache=15"></script>
217217

218218
<script src="js/testmode.js"></script>
219219

beta/css/chatrd.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,15 @@ body {
605605
}
606606

607607
.chat .item.streamer-mentioned .message {
608+
display: block;
608609
background: rgba(255,255,255,0.15);
609610
padding: 10px;
610611
border-radius: 5px;
611612
border: 1px inset rgba(255,255,255,0.1);
612613
}
613614

614615
.chat .item.first-chatter .message {
616+
display: block;
615617
background: rgba(255,255,255,0.15);
616618
padding: 10px;
617619
border-radius: 5px;

beta/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,9 +1866,9 @@ <h3><span data-i18n="modal.streamerbot.title">⚠️ Streamer.bot Actions Not Fo
18661866
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js"></script>
18671867
<script src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
18681868

1869-
<script src="js/i18n-settings.js?nocache=14"></script>
1870-
<script src="js/speakerbot.js?nocache=14"></script>
1869+
<script src="js/i18n-settings.js?nocache=15"></script>
1870+
<script src="js/speakerbot.js?nocache=15"></script>
18711871

1872-
<script type="module" src="js/settings.js?nocache=14"></script>
1872+
<script type="module" src="js/settings.js?nocache=15"></script>
18731873
</body>
18741874
</html>

beta/js/chatrd.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ const loadedEmotes = new Set();
7979

8080

8181
const SKINS = {
82-
default: "skin-default.css?nocache=14",
83-
nutting: "skin-nutting.css?nocache=14",
84-
kimballs: "skin-kimballs.css?nocache=14",
85-
bubbles: "skin-bubbles.css?nocache=14",
86-
'star-wars': "skin-star-wars.css?nocache=14"
82+
default: "skin-default.css?nocache=15",
83+
nutting: "skin-nutting.css?nocache=15",
84+
kimballs: "skin-kimballs.css?nocache=15",
85+
bubbles: "skin-bubbles.css?nocache=15",
86+
'star-wars': "skin-star-wars.css?nocache=15"
8787
};
8888

8989
const skinFile = SKINS[skin] || SKINS.default;

beta/js/modules/twitch/addon-on-screen-celebration.js

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
* emote sobem pela tela como balões de hélio, balançando em zigue-zague,
88
* com variação de tamanho, velocidade e opacidade.
99
*
10+
* IMPLEMENTAÇÃO: em vez de desenhar em <canvas> (o que congela GIF/WebP
11+
* animado no Chromium/CEF, usado pelo OBS Browser Source), cada emote é
12+
* um elemento <img> real, posicionado via CSS transform e animado a cada
13+
* requestAnimationFrame. Como é uma <img> de verdade, o navegador anima o
14+
* GIF/WebP nativamente — sem congelar.
15+
*
1016
* Uso básico:
1117
* onScreenCelebration("https://static-cdn.jtvnw.net/emoticons/.../3.0");
1218
*
@@ -85,9 +91,13 @@ function onScreenCelebration(emoteUrl, options = {}) {
8591
// zona de fade-out perto da borda de saída (px)
8692
edgeFadeZone = 140,
8793

88-
// elemento canvas já existente para reaproveitar (opcional).
89-
// Se não for passado, um canvas full-screen é criado e removido
90-
// automaticamente ao final da animação.
94+
// elemento container já existente para reaproveitar (opcional).
95+
// Se não for passado, um <div> full-screen é criado e removido
96+
// automaticamente ao final da animação. Aceita também "canvas" por
97+
// compatibilidade com a versão anterior (nesse caso o valor passado
98+
// é ignorado e um novo container próprio é criado, já que não dá
99+
// pra usar um <canvas> como pai de <img>s).
100+
container = null,
91101
canvas = null,
92102

93103
// callback disparado quando a animação termina naturalmente
@@ -105,37 +115,28 @@ function onScreenCelebration(emoteUrl, options = {}) {
105115

106116
const rand = (min, max) => Math.random() * (max - min) + min;
107117

108-
// ---- canvas: usa o fornecido ou cria um overlay full-screen próprio ----
109-
let ownCanvas = false;
110-
let cvs = canvas;
111-
if (!cvs) {
112-
ownCanvas = true;
113-
cvs = document.createElement("canvas");
114-
cvs.style.position = "fixed";
115-
cvs.style.inset = "0";
116-
cvs.style.width = "100%";
117-
cvs.style.height = "100%";
118-
cvs.style.pointerEvents = "none";
119-
cvs.style.zIndex = "2147483647";
120-
//document.body.appendChild(cvs);
121-
document.getElementById("chat").appendChild(cvs);
122-
}
123-
const ctx = cvs.getContext("2d");
124-
125-
function resize() {
126-
const w = cvs.clientWidth || window.innerWidth;
127-
const h = cvs.clientHeight || window.innerHeight;
128-
cvs.width = w * devicePixelRatio;
129-
cvs.height = h * devicePixelRatio;
130-
ctx.setTransform(devicePixelRatio, 0, 0, devicePixelRatio, 0, 0);
118+
// ---- container: usa o fornecido ou cria um overlay full-screen próprio ----
119+
let ownContainer = false;
120+
let root = container && container.nodeType === 1 ? container : null;
121+
if (!root) {
122+
ownContainer = true;
123+
root = document.createElement("div");
124+
root.style.position = "fixed";
125+
root.style.inset = "0";
126+
root.style.width = "100%";
127+
root.style.height = "100%";
128+
root.style.overflow = "hidden";
129+
root.style.pointerEvents = "none";
130+
root.style.zIndex = "2147483647";
131+
(document.getElementById("chat") || document.body).appendChild(root);
131132
}
132-
resize();
133-
window.addEventListener("resize", resize);
134133

135-
// ---- carrega o emote ----
136-
const img = new Image();
137-
img.crossOrigin = "anonymous";
138-
img.src = emoteUrl;
134+
function containerSize() {
135+
return {
136+
w: root.clientWidth || window.innerWidth,
137+
h: root.clientHeight || window.innerHeight
138+
};
139+
}
139140

140141
let emotes = [];
141142
let rafId = null;
@@ -144,11 +145,23 @@ function onScreenCelebration(emoteUrl, options = {}) {
144145

145146
function spawnEmote() {
146147
const size = rand(minSize, maxSize);
147-
const w = cvs.clientWidth || window.innerWidth;
148-
const h = cvs.clientHeight || window.innerHeight;
148+
const { w, h } = containerSize();
149149
const goingUp = direction === "up";
150150

151+
const el = document.createElement("img");
152+
el.src = emoteUrl;
153+
el.crossOrigin = "anonymous";
154+
el.style.position = "absolute";
155+
el.style.left = "0";
156+
el.style.top = "0";
157+
el.style.width = size + "px";
158+
el.style.height = size + "px";
159+
el.style.willChange = "transform, opacity";
160+
el.style.opacity = "0";
161+
root.appendChild(el);
162+
151163
emotes.push({
164+
el,
152165
baseX: rand(0, w),
153166
y: goingUp ? h + size : -size,
154167
size,
@@ -166,10 +179,7 @@ function onScreenCelebration(emoteUrl, options = {}) {
166179
}
167180

168181
function tick(now) {
169-
const w = cvs.clientWidth || window.innerWidth;
170-
const h = cvs.clientHeight || window.innerHeight;
171-
ctx.clearRect(0, 0, w, h);
172-
182+
const { h } = containerSize();
173183
const goingUp = direction === "up";
174184

175185
emotes.forEach((e) => {
@@ -189,20 +199,22 @@ function onScreenCelebration(emoteUrl, options = {}) {
189199
alpha = e.opacityMax;
190200
}
191201

192-
if (alpha <= 0) return;
202+
alpha = Math.min(1, Math.max(0, alpha));
193203

194-
ctx.save();
195-
ctx.globalAlpha = Math.min(1, Math.max(0, alpha));
196-
ctx.translate(x, e.y);
197-
ctx.rotate(e.rot);
198-
ctx.drawImage(img, -e.size / 2, -e.size / 2, e.size, e.size);
199-
ctx.restore();
204+
// translate posiciona o centro do emote em (x, e.y); o segundo
205+
// translate(-50%, -50%) centraliza a <img> nesse ponto, e rotate
206+
// gira em torno do próprio centro.
207+
e.el.style.transform =
208+
`translate(${x}px, ${e.y}px) rotate(${e.rot}rad) translate(-50%, -50%)`;
209+
e.el.style.opacity = String(alpha);
200210
});
201211

202212
emotes = emotes.filter((e) => {
203213
const alive = (now - e.born) < e.life;
204214
const onScreen = goingUp ? (e.y + e.size > -20) : (e.y - e.size < h + 20);
205-
return alive && onScreen;
215+
const keep = alive && onScreen;
216+
if (!keep && e.el.parentNode) e.el.parentNode.removeChild(e.el);
217+
return keep;
206218
});
207219

208220
if (spawning || emotes.length) {
@@ -218,9 +230,8 @@ function onScreenCelebration(emoteUrl, options = {}) {
218230
}
219231

220232
function cleanup() {
221-
window.removeEventListener("resize", resize);
222-
if (ownCanvas && cvs.parentNode) {
223-
cvs.parentNode.removeChild(cvs);
233+
if (ownContainer && root.parentNode) {
234+
root.parentNode.removeChild(root);
224235
}
225236
if (typeof onComplete === "function") onComplete();
226237
}
@@ -240,14 +251,7 @@ function onScreenCelebration(emoteUrl, options = {}) {
240251
}, effectiveSpawnInterval);
241252
}
242253

243-
if (img.complete) {
244-
start();
245-
} else {
246-
img.onload = start;
247-
img.onerror = () => {
248-
throw new Error(`onScreenCelebration: falha ao carregar o emote em "${emoteUrl}".`);
249-
};
250-
}
254+
start();
251255

252256
// controlador: permite interromper novos spawns manualmente
253257
return {

0 commit comments

Comments
 (0)