This commit is contained in:
Tyler
2026-05-25 06:19:59 -04:00
parent 68e9faa5af
commit 31b55fd2c3
16 changed files with 3676 additions and 1104 deletions
+21
View File
@@ -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) {