feat: add more adatper

This commit is contained in:
liujuntao
2023-04-25 17:58:21 +08:00
committed by josc146
parent ca708b19cf
commit 70fd7754eb
4 changed files with 80 additions and 0 deletions
+4
View File
@@ -127,6 +127,8 @@ export const defaultConfig = {
'youtube',
'zhihu',
'stackoverflow',
'juejin',
'mp.weixin.qq',
],
accessToken: '',
tokenSavedOn: 0,
@@ -166,6 +168,8 @@ export const defaultConfig = {
'youtube',
'zhihu',
'stackoverflow',
'juejin',
'mp.weixin.qq',
],
}
@@ -7,6 +7,8 @@ import zhihu from './zhihu'
import reddit from './reddit'
import quora from './quora'
import stackoverflow from './stackoverflow'
import juejin from './juejin'
import weixin from './weixin'
/**
* @typedef {object} SiteConfigAction
@@ -171,4 +173,16 @@ export const config = {
appendContainerQuery: [],
resultsContainerQuery: ['#sidebar'],
},
juejin: {
inputQuery: juejin.inputQuery,
sidebarContainerQuery: ['div.sidebar'],
appendContainerQuery: [],
resultsContainerQuery: ['div.main-area.article-area > article > div.article-content'],
},
'mp.weixin.qq': {
inputQuery: weixin.inputQuery,
sidebarContainerQuery: [],
appendContainerQuery: [],
resultsContainerQuery: ['#js_content'],
},
}
@@ -0,0 +1,37 @@
import { cropText } from '../../../utils'
export default {
inputQuery: async () => {
try {
const title = document.querySelector(
'#juejin > div.view-container > main > div > div.main-area.article-area > article > h1',
)?.textContent
const description = document.querySelector(
'#juejin > div.view-container > main > div > div.main-area.article-area > article > div.article-content',
)?.textContent
if (title && description) {
const author = document.querySelector(
'#juejin > div.view-container > main > div > div.main-area.article-area > article > div.author-info-block > div > div.author-name > a > span.name',
)?.textContent
const comments = document.querySelectorAll(
'div.content-box > div.comment-main > div.content',
)
let comment = ''
for (let i = 1; i <= comments.length && i <= 4; i++) {
comment += `answer${i}: ${comment[i - 1].textContent}|`
}
return cropText(
`以下是一篇文章,标题是:"${title}",作者是:"${author}",内容是:\n"${description}".各个评论如下:\n${comment}.请以如下格式输出你的回答:
{文章摘要和文章作者}
======
{文章总结和对文章的看法}
======
{对评论的总结}
`,
)
}
} catch (e) {
console.log(e)
}
},
}
@@ -0,0 +1,25 @@
import { cropText } from '../../../utils'
export default {
inputQuery: async () => {
try {
const title = document.querySelector('#activity-name')?.textContent
const description = document.querySelector('#js_content')?.textContent
if (title && description) {
const author = document.querySelector('#js_name')?.textContent
return cropText(
`以下是一篇文章,标题是:"${title}",文章来源是:"${author}公众号",内容是:\n"${description}".请以如下格式输出你的回答:
{文章来源和文章摘要}
======
{文章总结}
======
{对文章的看法}
`,
)
}
} catch (e) {
console.log(e)
}
},
}