mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-03 15:42:40 +08:00
feat: support for stackoverflow
This commit is contained in:
+20
-2
@@ -72,7 +72,16 @@ export const defaultConfig = {
|
||||
// others
|
||||
|
||||
activeSelectionTools: Object.keys(toolsConfig),
|
||||
activeSiteAdapters: ['bilibili', 'github', 'gitlab', 'quora', 'reddit', 'youtube', 'zhihu'],
|
||||
activeSiteAdapters: [
|
||||
'bilibili',
|
||||
'github',
|
||||
'gitlab',
|
||||
'quora',
|
||||
'reddit',
|
||||
'youtube',
|
||||
'zhihu',
|
||||
'stackoverflow',
|
||||
],
|
||||
accessToken: '',
|
||||
tokenSavedOn: 0,
|
||||
|
||||
@@ -81,7 +90,16 @@ export const defaultConfig = {
|
||||
userLanguage: navigator.language.substring(0, 2),
|
||||
selectionTools: Object.keys(toolsConfig),
|
||||
// importing configuration will result in gpt-3-encoder being packaged into the output file
|
||||
siteAdapters: ['bilibili', 'github', 'gitlab', 'quora', 'reddit', 'youtube', 'zhihu'],
|
||||
siteAdapters: [
|
||||
'bilibili',
|
||||
'github',
|
||||
'gitlab',
|
||||
'quora',
|
||||
'reddit',
|
||||
'youtube',
|
||||
'zhihu',
|
||||
'stackoverflow',
|
||||
],
|
||||
}
|
||||
|
||||
export async function getUserLanguage() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import gitlab from './gitlab'
|
||||
import zhihu from './zhihu'
|
||||
import reddit from './reddit'
|
||||
import quora from './quora'
|
||||
import stackoverflow from './stackoverflow'
|
||||
|
||||
/**
|
||||
* @typedef {object} SiteConfigAction
|
||||
@@ -164,4 +165,10 @@ export const config = {
|
||||
appendContainerQuery: [],
|
||||
resultsContainerQuery: ['.q-box.PageContentsLayout___StyledBox-d2uxks-0'],
|
||||
},
|
||||
stackoverflow: {
|
||||
inputQuery: stackoverflow.inputQuery,
|
||||
sidebarContainerQuery: ['#sidebar'],
|
||||
appendContainerQuery: [],
|
||||
resultsContainerQuery: ['#sidebar'],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1 +1,26 @@
|
||||
//TODO
|
||||
import { cropText } from '../../../utils'
|
||||
|
||||
export default {
|
||||
inputQuery: async () => {
|
||||
try {
|
||||
const title = document.querySelector('#question-header .question-hyperlink')?.textContent
|
||||
if (title) {
|
||||
const description = document.querySelector('.postcell .s-prose')?.textContent
|
||||
let answer = ''
|
||||
const answers = document.querySelectorAll('.answercell .s-prose')
|
||||
if (answers.length > 0)
|
||||
for (let i = 1; i <= answers.length && i <= 2; i++) {
|
||||
answer += `answer${i}: ${answers[i - 1].textContent}|`
|
||||
}
|
||||
|
||||
return cropText(
|
||||
`Below is the content from a developer Q&A platform. Analyze answers and provide a brief solution that can solve the question first,` +
|
||||
`then give an overview of all answers. The question is: "${title}", and the further description of the question is: "${description}".` +
|
||||
`The answers are as follows:\n${answer}`,
|
||||
)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user