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

Function captureAndSendToChat

contents/chat-integration.ts:117–149  ·  view source on GitHub ↗
(prompt?: string)

Source from the content-addressed store, hash-verified

115
116// 截图并发送到聊天
117async function captureAndSendToChat(prompt?: string) {
118 try {
119 // 使用 Chrome API 截图
120 const dataUrl = await chrome.runtime.sendMessage({
121 action: "captureVisibleTab"
122 })
123
124 if (dataUrl) {
125 // 发送图片到聊天
126 sendMessageToChat({
127 type: "CHAT_INSERT_IMAGE",
128 payload: {
129 images: [dataUrl]
130 }
131 })
132
133 // 如果有提示文本,也发送
134 if (prompt) {
135 setTimeout(() => {
136 sendMessageToChat({
137 type: "CHAT_INPUT",
138 payload: {
139 text: prompt,
140 autoSend: false
141 }
142 })
143 }, 100)
144 }
145 }
146 } catch (error) {
147 console.error("[Chat Integration] 截图失败:", error)
148 }
149}
150
151// 导出工具函数供其他 content scripts 使用
152export function sendTextToChat(text: string, autoSend = false) {

Callers 1

Calls 1

sendMessageToChatFunction · 0.85

Tested by

no test coverage detected