MCPcopy Index your code
hub / github.com/aircloud/sync-to-github / sendMessageToContentScript

Function sendMessageToContentScript

apps/chrome-ext/src/utils/message.ts:3–23  ·  view source on GitHub ↗
(
  message: ConvertInstructionRequest,
)

Source from the content-addressed store, hash-verified

1import type { ConvertInstructionRequest, ConvertInstructionRespnse } from '../schema'
2
3export const sendMessageToContentScript = (
4 message: ConvertInstructionRequest,
5): Promise<ConvertInstructionRespnse> => {
6 return new Promise((rs) => {
7 chrome.tabs.query(
8 {
9 active: true,
10 currentWindow: true,
11 },
12 (tabs) => {
13 chrome.tabs.sendMessage(
14 tabs[0]!.id! as number,
15 message,
16 (res: ConvertInstructionRespnse) => {
17 rs(res)
18 },
19 )
20 },
21 )
22 })
23}

Callers 2

syncFunction · 0.90
SyncPanelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected