File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -35,22 +35,23 @@ export async function getWebpageTitleAndText(url: string, html_str = ''): Promis
35
35
}
36
36
}
37
37
html = await response . text ( )
38
-
39
38
}
40
39
41
40
42
41
const doc = parseHTML ( html ) . document
43
42
const parsed = new Readability ( doc ) . parse ( )
44
43
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 }
47
46
}
48
-
49
- let text = cleanText ( parsed . textContent )
50
47
48
+ console . log ( "text" , parsed . textContent ) ;
49
+ let text = cleanText ( parsed . textContent )
50
+
51
51
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.]"
54
55
}
55
56
return { title : parsed . title , body : text , url }
56
57
}
You can’t perform that action at this time.
0 commit comments