-
Notifications
You must be signed in to change notification settings - Fork 855
Expand file tree
/
Copy pathindex.mjs
More file actions
27 lines (25 loc) · 912 Bytes
/
index.mjs
File metadata and controls
27 lines (25 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { cropText } from '../../../utils'
export default {
inputQuery: async () => {
try {
const title = document.querySelector('[id*="post-title"]')?.textContent
const description = document.querySelector(
'shreddit-post > div.text-neutral-content',
)?.textContent
const texts = document.querySelectorAll('shreddit-comment div.md')
let answers = ''
for (let i = 0; i < texts.length; i++) {
answers += `answer${i}:${texts[i].textContent}|`
}
return await cropText(
`You are an expert in analyzing online forum discussions. ` +
`Below is content from a social forum (Reddit). Please provide a summary of the discussion and your opinion on it.\n` +
`Title: '${title}'\n` +
`Description: '${description}'\n` +
`Comments:\n${answers}`,
)
} catch (e) {
console.log(e)
}
},
}