function textOf(node) { return ((node && (node.innerText || node.textContent || '')) || '').replace(/\s+/g, ' ').trim(); } function attrsText(el) { if (!el || !el.attributes) return ''; return Array.from(el.attributes).map((attr) => `${attr.name}=${attr.value}`).join(' '); } function isVisible(el) { if (!el || !el.getBoundingClientRect) return false; const rect = el.getBoundingClientRect(); const style = window.getComputedStyle(el); return rect.width > 0 && rect.height > 0 && style.display !== 'none' && style.visibility !== 'hidden'; } function walkRoots(root, rows, seen) { if (!root || seen.has(root)) return; seen.add(root); const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT); let node = walker.currentNode; while (node) { if (node.nodeType === Node.ELEMENT_NODE && node.tagName) rows.push(node); if (node.shadowRoot) walkRoots(node.shadowRoot, rows, seen); if ((node.tagName || '').toLowerCase() === 'slot' && node.assignedElements) { for (const assigned of node.assignedElements({ flatten: true })) { walkRoots(assigned, rows, seen); } } node = walker.nextNode(); } } const rows = []; walkRoots(document, rows, new Set()); const seen = new Set(); return rows .filter((el) => { const haystack = `${el.tagName || ''} ${attrsText(el)} ${textOf(el)}`; return isVisible(el) && /kat-alert|alert|toast|notification|已删除|已经删除|15\s*分钟|success/i.test(haystack); }) .map((el) => textOf(el) || attrsText(el)) .filter((text) => text && !seen.has(text) && seen.add(text)) .slice(0, 30);