Skip to content

Commit 0a1e789

Browse files
committed
Summarized page URL is now sent to server
1 parent 1a3d65f commit 0a1e789

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

background.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ chrome.runtime.onMessage.addListener(
104104
fetchPageHTML(request.url, domain, sectionTitle).then(pageContent => {
105105
// Send the content for summarization
106106
setWaitState();
107-
summarizeDocument(pageContent, domain, sectionTitle)
107+
summarizeDocument(pageContent, domain, sectionTitle, request.url)
108108
.then(summary => {
109109
clearWaitState();
110110
logMessage(`Summary returning for ${sectionTitle} on ${domain}`);
@@ -346,7 +346,33 @@ function fetchPageHTML(url, domain, sectionTitle) {
346346
}
347347

348348

349-
function summarizeDocument(document, url, sectionTitle) {
349+
350+
// function fetchPageHTML(url, domain, sectionTitle) {
351+
// return new Promise((resolve, reject) => {
352+
// fetch('https://docdecoder.app/fetch_html', { // Replace with your Flask server URL
353+
// method: 'POST',
354+
// headers: {
355+
// 'Content-Type': 'application/json'
356+
// },
357+
// body: JSON.stringify({ url: url })
358+
// })
359+
// .then(response => {
360+
// if (!response.ok) {
361+
// throw new Error('Failed to fetch page HTML. Please check the URL and try again.');
362+
// }
363+
// return response.text();
364+
// })
365+
// .then(text => resolve(text))
366+
// .catch(error => {
367+
// handleSummaryError(domain, sectionTitle, error.toString());
368+
// reject(error);
369+
// });
370+
// });
371+
// }
372+
373+
374+
375+
function summarizeDocument(document, url, sectionTitle, pageURL) {
350376
let domain = url;
351377
logMessage(`Sending summary request for ${sectionTitle} on ${domain}`);
352378

@@ -360,7 +386,8 @@ function summarizeDocument(document, url, sectionTitle) {
360386
body: JSON.stringify({
361387
document: document,
362388
domain: domain,
363-
document_type: sectionTitle
389+
document_type: sectionTitle,
390+
url: pageURL,
364391
}),
365392
})
366393
.then(response => {

0 commit comments

Comments
 (0)