MCPcopy Index your code
hub / github.com/massCodeIO/massCode / captureCurrentPayload

Function captureCurrentPayload

integrations/clipper/src/popup.ts:135–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133}
134
135async function captureCurrentPayload(): Promise<void> {
136 if (!currentPayload) {
137 setStatus('No active page to capture.', true)
138 return
139 }
140
141 settings = readSettingsFromForm()
142 await saveSettings(settings)
143
144 if (!settings.apiToken.trim()) {
145 setStatus('Set the massCode API token first.', true)
146 return
147 }
148
149 if (!canCaptureCurrentTarget()) {
150 setStatus('Select text on the page to save a snippet.', true)
151 return
152 }
153
154 try {
155 const request = buildCaptureRequest(
156 activeTarget,
157 currentPayload,
158 captureNameInput?.value,
159 )
160 const result = await postCapture(settings, request)
161 setStatus(`Saved ${result.target} item #${result.id}.`)
162 }
163 catch (error) {
164 setStatus(getErrorMessage(error), true)
165 }
166}
167
168async function getActiveTabCapture(): Promise<PageCapturePayload> {
169 const [tab] = await chrome.tabs.query({ active: true, currentWindow: true })

Callers 1

bindEventsFunction · 0.85

Calls 7

saveSettingsFunction · 0.90
buildCaptureRequestFunction · 0.90
postCaptureFunction · 0.90
setStatusFunction · 0.85
readSettingsFromFormFunction · 0.85
canCaptureCurrentTargetFunction · 0.85
getErrorMessageFunction · 0.70

Tested by

no test coverage detected