Skip to content

Commit 70fd775

Browse files
liujuntao123josStorer
authored andcommitted
feat: add more adatper
1 parent ca708b1 commit 70fd775

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

src/config/index.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export const defaultConfig = {
127127
'youtube',
128128
'zhihu',
129129
'stackoverflow',
130+
'juejin',
131+
'mp.weixin.qq',
130132
],
131133
accessToken: '',
132134
tokenSavedOn: 0,
@@ -166,6 +168,8 @@ export const defaultConfig = {
166168
'youtube',
167169
'zhihu',
168170
'stackoverflow',
171+
'juejin',
172+
'mp.weixin.qq',
169173
],
170174
}
171175

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import zhihu from './zhihu'
77
import reddit from './reddit'
88
import quora from './quora'
99
import stackoverflow from './stackoverflow'
10+
import juejin from './juejin'
11+
import weixin from './weixin'
1012

1113
/**
1214
* @typedef {object} SiteConfigAction
@@ -171,4 +173,16 @@ export const config = {
171173
appendContainerQuery: [],
172174
resultsContainerQuery: ['#sidebar'],
173175
},
176+
juejin: {
177+
inputQuery: juejin.inputQuery,
178+
sidebarContainerQuery: ['div.sidebar'],
179+
appendContainerQuery: [],
180+
resultsContainerQuery: ['div.main-area.article-area > article > div.article-content'],
181+
},
182+
'mp.weixin.qq': {
183+
inputQuery: weixin.inputQuery,
184+
sidebarContainerQuery: [],
185+
appendContainerQuery: [],
186+
resultsContainerQuery: ['#js_content'],
187+
},
174188
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { cropText } from '../../../utils'
2+
3+
export default {
4+
inputQuery: async () => {
5+
try {
6+
const title = document.querySelector(
7+
'#juejin > div.view-container > main > div > div.main-area.article-area > article > h1',
8+
)?.textContent
9+
const description = document.querySelector(
10+
'#juejin > div.view-container > main > div > div.main-area.article-area > article > div.article-content',
11+
)?.textContent
12+
if (title && description) {
13+
const author = document.querySelector(
14+
'#juejin > div.view-container > main > div > div.main-area.article-area > article > div.author-info-block > div > div.author-name > a > span.name',
15+
)?.textContent
16+
const comments = document.querySelectorAll(
17+
'div.content-box > div.comment-main > div.content',
18+
)
19+
let comment = ''
20+
for (let i = 1; i <= comments.length && i <= 4; i++) {
21+
comment += `answer${i}: ${comment[i - 1].textContent}|`
22+
}
23+
return cropText(
24+
`以下是一篇文章,标题是:"${title}",作者是:"${author}",内容是:\n"${description}".各个评论如下:\n${comment}.请以如下格式输出你的回答:
25+
{文章摘要和文章作者}
26+
======
27+
{文章总结和对文章的看法}
28+
======
29+
{对评论的总结}
30+
`,
31+
)
32+
}
33+
} catch (e) {
34+
console.log(e)
35+
}
36+
},
37+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { cropText } from '../../../utils'
2+
3+
export default {
4+
inputQuery: async () => {
5+
try {
6+
const title = document.querySelector('#activity-name')?.textContent
7+
const description = document.querySelector('#js_content')?.textContent
8+
if (title && description) {
9+
const author = document.querySelector('#js_name')?.textContent
10+
11+
return cropText(
12+
`以下是一篇文章,标题是:"${title}",文章来源是:"${author}公众号",内容是:\n"${description}".请以如下格式输出你的回答:
13+
{文章来源和文章摘要}
14+
======
15+
{文章总结}
16+
======
17+
{对文章的看法}
18+
`,
19+
)
20+
}
21+
} catch (e) {
22+
console.log(e)
23+
}
24+
},
25+
}

0 commit comments

Comments
 (0)