Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement arxiv adapter #711

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export const defaultConfig = {
'juejin',
'mp.weixin.qq',
'followin',
'arxiv',
],
accessToken: '',
tokenSavedOn: 0,
Expand Down Expand Up @@ -330,6 +331,7 @@ export const defaultConfig = {
'juejin',
'mp.weixin.qq',
'followin',
'arxiv',
],
}

Expand Down
19 changes: 18 additions & 1 deletion src/content-script/site-adapters/arxiv/index.mjs
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
//TODO
import { cropText } from '../../../utils'

export default {
inputQuery: async () => {
try {
const title = document.querySelector('.title')?.textContent.trim()
const authors = document.querySelector('.authors')?.textContent
const abstract = document.querySelector('blockquote.abstract')?.textContent.trim()

return await cropText(
`Below is the paper abstract from a preprint site, summarize the key findings, methodology, and conclusions, especially highlight the contributions.` +
`${title}\n${authors}\n${abstract}`,
)
} catch (e) {
console.log(e)
}
},
}
7 changes: 7 additions & 0 deletions src/content-script/site-adapters/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import weixin from './weixin'
import followin from './followin'
import duckduckgo from './duckduckgo'
import brave from './brave'
import arxiv from './arxiv'

/**
* @typedef {object} SiteConfigAction
Expand Down Expand Up @@ -208,4 +209,10 @@ export const config = {
appendContainerQuery: [],
resultsContainerQuery: ['#article-content', '#thead-gallery'],
},
arxiv: {
inputQuery: arxiv.inputQuery,
sidebarContainerQuery: ['.extra-services'],
appendContainerQuery: [],
resultsContainerQuery: ['.extra-services'],
},
}