From 2ded10ce54829dbd3ea50cf9c026cb7019c5f835 Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Wed, 12 Aug 2026 16:11:59 +1000 Subject: [PATCH] update colours automatically --- widgets/horizontal/scripts/tasklist-view.js | 17 +++++++++++++++++ widgets/shared/scripts/streamerbot.js | 1 + widgets/streamer-only/scripts/tasklist-view.js | 17 +++++++++++++++++ widgets/vertical/scripts/tasklist-view.js | 17 +++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/widgets/horizontal/scripts/tasklist-view.js b/widgets/horizontal/scripts/tasklist-view.js index ff50539..be4b19f 100644 --- a/widgets/horizontal/scripts/tasklist-view.js +++ b/widgets/horizontal/scripts/tasklist-view.js @@ -95,6 +95,23 @@ class TaskList { return this; } + updateUserColor(sectionId, color) { + const section = this.#data.find((s) => s.id === sectionId); + if (!section) return this; + + section.color = color; + document + .querySelectorAll(".section") + .forEach((el) => { + if (el.dataset.key !== sectionId) return; + const title = el.querySelector(":scope > .section-title"); + if (!title) return; + title.style.setProperty("--user-color", color); + title.classList.add("has-user-color"); + }); + return this; + } + addTask(sectionId, task, sectionTitle) { if (!this.#data.find((s) => s.id === sectionId)) { this.addSection({ diff --git a/widgets/shared/scripts/streamerbot.js b/widgets/shared/scripts/streamerbot.js index 3c08bcb..0443eee 100644 --- a/widgets/shared/scripts/streamerbot.js +++ b/widgets/shared/scripts/streamerbot.js @@ -46,6 +46,7 @@ async function onChatMessage(data) { localStorage.setItem(`${key}-color`, userColor); userColors[`${key}-color`] = userColor; + taskList?.updateUserColor(key, userColor); } } diff --git a/widgets/streamer-only/scripts/tasklist-view.js b/widgets/streamer-only/scripts/tasklist-view.js index 80e2aed..17c12dc 100644 --- a/widgets/streamer-only/scripts/tasklist-view.js +++ b/widgets/streamer-only/scripts/tasklist-view.js @@ -72,6 +72,23 @@ class TaskList { return this; } + updateUserColor(sectionId, color) { + const section = this.#data.find((s) => s.id === sectionId); + if (!section) return this; + + section.color = color; + document + .querySelectorAll(".section") + .forEach((el) => { + if (el.dataset.key !== sectionId) return; + const title = el.querySelector(":scope > .section-title"); + if (!title) return; + title.style.setProperty("--user-color", color); + title.classList.add("has-user-color"); + }); + return this; + } + addTask(sectionId, task, sectionTitle) { if (!this.#data.find((s) => s.id === sectionId)) { this.addSection({ diff --git a/widgets/vertical/scripts/tasklist-view.js b/widgets/vertical/scripts/tasklist-view.js index 37519c9..ff992a9 100644 --- a/widgets/vertical/scripts/tasklist-view.js +++ b/widgets/vertical/scripts/tasklist-view.js @@ -95,6 +95,23 @@ class TaskList { return this; } + updateUserColor(sectionId, color) { + const section = this.#data.find((s) => s.id === sectionId); + if (!section) return this; + + section.color = color; + document + .querySelectorAll(".section") + .forEach((el) => { + if (el.dataset.key !== sectionId) return; + const title = el.querySelector(":scope > .section-title"); + if (!title) return; + title.style.setProperty("--user-color", color); + title.classList.add("has-user-color"); + }); + return this; + } + addTask(sectionId, task, sectionTitle) { if (!this.#data.find((s) => s.id === sectionId)) { this.addSection({