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 = [];
|
const msgs = [];
|
||||||
|
|
||||||
// Channel meeting: channel-pane-message contains reply-message-header + message-body siblings
|
// 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) {
|
if (channelPanes.length > 0) {
|
||||||
channelPanes.forEach((pane, paneIdx) => {
|
channelPanes.forEach((pane, paneIdx) => {
|
||||||
const els = pane.querySelectorAll(
|
const els = pane.querySelectorAll(
|
||||||
@ -49,8 +52,10 @@ _POLL_JS = r"""() => {
|
|||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Meeting chat: chat-pane-message with message-author-name inside
|
// Meeting chat: chat-pane-message with message-author-name inside (visible only)
|
||||||
document.querySelectorAll("[data-tid='chat-pane-message']").forEach((msg, idx) => {
|
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 senderEl = msg.querySelector("[data-tid='message-author-name']");
|
||||||
const sender = senderEl ? senderEl.innerText.trim() : '';
|
const sender = senderEl ? senderEl.innerText.trim() : '';
|
||||||
if (!sender) return;
|
if (!sender) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user