Skip to content

Commit 827f897

Browse files
committed
~UI
1 parent a76c22e commit 827f897

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/content-scripts/api.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,23 @@ export async function getWebpageTitleAndText(url: string, html_str = ''): Promis
3535
}
3636
}
3737
html = await response.text()
38-
3938
}
4039

4140

4241
const doc = parseHTML(html).document
4342
const parsed = new Readability(doc).parse()
4443

45-
if (!parsed) {
46-
return { title: "Could not parse the page.", body: "", url }
44+
if (!parsed || !parsed.textContent) {
45+
return { title: "Could not parse the page.", body: "Could not parse the page.", url }
4746
}
48-
49-
let text = cleanText(parsed.textContent)
5047

48+
console.log("text", parsed.textContent);
49+
let text = cleanText(parsed.textContent)
50+
5151
const userConfig = await getUserConfig()
52-
if (userConfig.trimLongText) {
53-
text = text.slice(0, 14500)
52+
if (userConfig.trimLongText && text.length > 14400) {
53+
text = text.slice(0, 14400)
54+
text += "\n\n[Text has been trimmed to 14,500 characters. You can disable this on WebChatGPT's options page.]"
5455
}
5556
return { title: parsed.title, body: text, url }
5657
}

0 commit comments

Comments
 (0)