debug: check if message-author-name is inside or outside chat-pane-message
This commit is contained in:
parent
b69398803c
commit
19c5b2ce17
@ -138,16 +138,25 @@ class Monitor:
|
||||
|
||||
def poll_new_messages(self) -> list[ChatMessage]:
|
||||
result = self._page.evaluate(r"""() => {
|
||||
const counts = {
|
||||
const isVisible = el => { const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0; };
|
||||
const chatMsgs = Array.from(document.querySelectorAll("[data-tid='chat-pane-message']")).filter(isVisible);
|
||||
const authorNames = Array.from(document.querySelectorAll("[data-tid='message-author-name']"));
|
||||
const sample = chatMsgs.slice(0, 3).map(msg => ({
|
||||
hasAuthorInside: !!msg.querySelector("[data-tid='message-author-name']"),
|
||||
text: msg.innerText.trim().substring(0, 40),
|
||||
}));
|
||||
return {
|
||||
channelAll: document.querySelectorAll("[data-tid='channel-pane-message']").length,
|
||||
chatAll: document.querySelectorAll("[data-tid='chat-pane-message']").length,
|
||||
channelVisible: Array.from(document.querySelectorAll("[data-tid='channel-pane-message']")).filter(isVisible).length,
|
||||
chatVisible: chatMsgs.length,
|
||||
authorNamesTotal: authorNames.length,
|
||||
sample,
|
||||
};
|
||||
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']})")
|
||||
print(f" [DOM] channel={result['channelAll']}(vis:{result['channelVisible']}) chat={result['chatAll']}(vis:{result['chatVisible']}) authors={result['authorNamesTotal']}")
|
||||
for s in result['sample']:
|
||||
print(f" msg hasAuthor={s['hasAuthorInside']} text={s['text']!r}")
|
||||
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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user