overhaul config, refactor twitch labels, init satellite

This commit is contained in:
ari melody 2026-07-24 17:24:07 +01:00
parent b2485eda79
commit 097a36ac69
Signed by: ari
GPG key ID: CF99829C92678188
6 changed files with 161 additions and 152 deletions

View file

@ -1,6 +1,6 @@
const labelEl = document.getElementById("label");
const selectedLabel = new URLSearchParams(location.search).get("l");
const label = location.pathname.split("/twitch/labels/")[1];
const labelLatestFollower = "latest-follower"
const labelLatestSubscriber = "latest-subscriber"
const labelLatestCheer = "latest-cheer"
@ -11,14 +11,11 @@ const allowedLabels = [
]
/**
* @param {string} selectedLabel
* @param {string} label
*/
async function sync() {
if (selectedLabel == null) {
const exampleUrl =
location.pathname +
"?l=" +
labelLatestFollower;
if (label == null) {
const exampleUrl = `${location.protocol}//${location.host}/twitch/labels/${labelLatestFollower}`;
labelEl.innerHTML =
"Needs label to listen to, " +
@ -29,7 +26,7 @@ async function sync() {
let eventSource;
try {
eventSource = new EventSource("/twitch/sse?l=" + selectedLabel);
eventSource = new EventSource("/twitch/sse/" + label);
} catch (err) {
console.error("Failed to connect to event source", err);
return;
@ -46,7 +43,7 @@ async function sync() {
});
eventSource.addEventListener("update", event => {
console.log(event.data);
console.log(`[${label}] ${event.data}`);
labelEl.innerText = event.data;
});