-
Notifications
You must be signed in to change notification settings - Fork 855
Expand file tree
/
Copy pathindex.mjs
More file actions
27 lines (24 loc) · 806 Bytes
/
index.mjs
File metadata and controls
27 lines (24 loc) · 806 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 {
if (location.pathname === '/') return
const texts = document.querySelectorAll('.q-box.qu-userSelect--text')
let title
if (texts.length > 0) title = texts[0].textContent
let answers = ''
if (texts.length > 1)
for (let i = 1; i < texts.length; i++) {
answers += `answer${i}:${texts[i].textContent}|`
}
return await cropText(
`You are an insightful analyst of Q&A discussions. ` +
`Below is content from a Q&A platform. Please provide a summary of the discussion and your opinion on it.\n` +
`Question: '${title}'\n` +
`Answers:\n${answers}`,
)
} catch (e) {
console.log(e)
}
},
}