MCPcopy Create free account
hub / github.com/027xiguapi/code-box / findChatWindow

Function findChatWindow

contents/chat-integration.ts:77–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75
76// 查找聊天应用窗口
77function findChatWindow(): Window | null {
78 // 检查是否有特定的 iframe
79 const chatIframe = document.querySelector(
80 'iframe[src*="chat"], iframe[name="chat"]'
81 ) as HTMLIFrameElement
82
83 if (chatIframe && chatIframe.contentWindow) {
84 return chatIframe.contentWindow
85 }
86
87 // 检查所有 iframe
88 const iframes = document.querySelectorAll("iframe")
89 for (const iframe of iframes) {
90 if (iframe.contentWindow) {
91 return iframe.contentWindow
92 }
93 }
94
95 // 如果没有 iframe,返回当前窗口
96 return window
97}
98
99// 监听来自聊天应用的响应
100window.addEventListener("message", (event) => {

Callers 1

sendMessageToChatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected