V1.0.0
This commit is contained in:
@@ -33,6 +33,10 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
handleGetPageContent(message.tabId, sendResponse);
|
||||
return true;
|
||||
}
|
||||
if (message.action === 'OLLAMA_FETCH_JSON') {
|
||||
handleFetchJson(message, sendResponse);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
@@ -53,6 +57,23 @@ function handleGetPageContent(tabId, sendResponse) {
|
||||
});
|
||||
}
|
||||
|
||||
// ── Non-streaming JSON POST ───────────────────────────────────────────────────
|
||||
|
||||
async function handleFetchJson(message, sendResponse) {
|
||||
try {
|
||||
const res = await fetch(message.url, {
|
||||
method: 'POST',
|
||||
headers: message.headers || {},
|
||||
body: message.body
|
||||
});
|
||||
if (!res.ok) { sendResponse({ ok: false, error: 'HTTP ' + res.status }); return; }
|
||||
const data = await res.json();
|
||||
sendResponse({ ok: true, data });
|
||||
} catch (e) {
|
||||
sendResponse({ ok: false, error: e.message });
|
||||
}
|
||||
}
|
||||
|
||||
// ── Non-streaming GET ─────────────────────────────────────────────────────────
|
||||
|
||||
async function handleGet(message, sendResponse) {
|
||||
|
||||
Reference in New Issue
Block a user