overhaul config, refactor twitch labels, init satellite
This commit is contained in:
parent
b2485eda79
commit
097a36ac69
6 changed files with 161 additions and 152 deletions
|
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue