Skip to content

Commit 9773a5d

Browse files
committed
chore
1 parent d53d8b8 commit 9773a5d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/content-script/site-adapters/reddit/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { cropText } from '../../../utils'
33
export default {
44
inputQuery: async () => {
55
try {
6-
const title = document.querySelector('[id*="post-title"]').textContent
6+
const title = document.querySelector('[id*="post-title"]')?.textContent
77
const description = document.querySelector(
88
'shreddit-post > div.text-neutral-content',
9-
).textContent
9+
)?.textContent
1010
const texts = document.querySelectorAll('shreddit-comment div.md')
1111
let answers = ''
1212
for (let i = 0; i < texts.length; i++) {

src/utils/crop-text.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function cropText(
3535
tiktoken = true,
3636
) {
3737
const userConfig = await getUserConfig()
38-
const k = Models[userConfig.modelName].desc.match(/[- ]*([0-9]+)k/)?.[1]
38+
const k = Models[userConfig.modelName].desc.match(/[- (]*([0-9]+)k/)?.[1]
3939
if (k) {
4040
maxLength = Number(k) * 1000
4141
maxLength -= 100 + clamp(userConfig.maxResponseTokenLength, 1, maxLength - 1000)

0 commit comments

Comments
 (0)