debug: add DOM element counts per poll for diagnosis

This commit is contained in:
Oliver Hofmann 2026-05-17 13:58:03 +02:00
parent 22c6e8febc
commit 24cbea0c97

View File

@ -137,6 +137,17 @@ class Monitor:
return name
def poll_new_messages(self) -> list[ChatMessage]:
result = self._page.evaluate(r"""() => {
const counts = {
channelAll: document.querySelectorAll("[data-tid='channel-pane-message']").length,
chatAll: document.querySelectorAll("[data-tid='chat-pane-message']").length,
};
const isVisible = el => { const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0; };
counts.channelVisible = Array.from(document.querySelectorAll("[data-tid='channel-pane-message']")).filter(isVisible).length;
counts.chatVisible = Array.from(document.querySelectorAll("[data-tid='chat-pane-message']")).filter(isVisible).length;
return counts;
}""")
print(f" [DOM] channel={result['channelAll']}(vis:{result['channelVisible']}) chat={result['chatAll']}(vis:{result['chatVisible']})")
raw = self._page.evaluate(_POLL_JS)
if raw:
print(f" [POLL] {len(raw)} Elemente, davon {sum(1 for r in raw if r['id'] not in self._seen_message_ids)} neu")