-
Notifications
You must be signed in to change notification settings - Fork 855
Expand file tree
/
Copy pathindex.mjs
More file actions
35 lines (34 loc) · 1.41 KB
/
index.mjs
File metadata and controls
35 lines (34 loc) · 1.41 KB
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
28
29
30
31
32
33
34
35
import { cropText } from '../../../utils'
export default {
inputQuery: async () => {
try {
const author = document.querySelector('main article a > span')?.textContent
const description =
document.querySelector('#article-content')?.textContent ||
document.querySelector('#thead-gallery')?.textContent
if (author && description) {
const title = document.querySelector('main article h1')?.textContent
if (title) {
return await cropText(
`You are an expert content summarizer. Please carefully read the following article. ` +
`Provide a conclusion and 3 to 5 main points, presented as a markdown list. ` +
`The summary should be concise, clear, and accurately reflect the core content.\n` +
`Title: "${title}"\n` +
`Author: "${author}"\n` +
`Content:\n"${description}"`,
)
} else {
return await cropText(
`You are an expert content summarizer. Please carefully read the following long tweet. ` +
`Provide a conclusion and 3 to 5 main points, presented as a markdown list. ` +
`The summary should be concise, clear, and accurately reflect the core content.\n` +
`Author: "${author}"\n` +
`Content:\n"${description}"`,
)
}
}
} catch (e) {
console.log(e)
}
},
}