fix: filter hidden DOM elements (offsetParent) to ignore cached SPA panes
This commit is contained in:
parent
8c91d8839e
commit
eb5d2bb4a2
@ -20,7 +20,10 @@ _POLL_JS = r"""() => {
|
||||
const msgs = [];
|
||||
|
||||
// Channel meeting: channel-pane-message contains reply-message-header + message-body siblings
|
||||
const channelPanes = document.querySelectorAll("[data-tid='channel-pane-message']");
|
||||
// Filter to visible elements only — Teams SPA keeps hidden/cached panes in the DOM
|
||||
const channelPanes = Array.from(
|
||||
document.querySelectorAll("[data-tid='channel-pane-message']")
|
||||
).filter(el => el.offsetParent !== null);
|
||||
if (channelPanes.length > 0) {
|
||||
channelPanes.forEach((pane, paneIdx) => {
|
||||
const els = pane.querySelectorAll(
|
||||
@ -49,8 +52,10 @@ _POLL_JS = r"""() => {
|
||||
return msgs;
|
||||
}
|
||||
|
||||
// Meeting chat: chat-pane-message with message-author-name inside
|
||||
document.querySelectorAll("[data-tid='chat-pane-message']").forEach((msg, idx) => {
|
||||
// Meeting chat: chat-pane-message with message-author-name inside (visible only)
|
||||
Array.from(document.querySelectorAll("[data-tid='chat-pane-message']"))
|
||||
.filter(el => el.offsetParent !== null)
|
||||
.forEach((msg, idx) => {
|
||||
const senderEl = msg.querySelector("[data-tid='message-author-name']");
|
||||
const sender = senderEl ? senderEl.innerText.trim() : '';
|
||||
if (!sender) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user