From 866dcb0ee684926272f0be5728a995cd193606e8 Mon Sep 17 00:00:00 2001 From: "Shuang Liang (Icer)" Date: Wed, 22 May 2024 09:40:06 +0800 Subject: [PATCH] implement arxiv adapter --- src/config/index.mjs | 2 ++ .../site-adapters/arxiv/index.mjs | 19 ++++++++++++++++++- src/content-script/site-adapters/index.mjs | 7 +++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/config/index.mjs b/src/config/index.mjs index 0510223c..ed6194c9 100644 --- a/src/config/index.mjs +++ b/src/config/index.mjs @@ -279,6 +279,7 @@ export const defaultConfig = { 'juejin', 'mp.weixin.qq', 'followin', + 'arxiv', ], accessToken: '', tokenSavedOn: 0, @@ -330,6 +331,7 @@ export const defaultConfig = { 'juejin', 'mp.weixin.qq', 'followin', + 'arxiv', ], } diff --git a/src/content-script/site-adapters/arxiv/index.mjs b/src/content-script/site-adapters/arxiv/index.mjs index 8ad1dfb5..5af62059 100644 --- a/src/content-script/site-adapters/arxiv/index.mjs +++ b/src/content-script/site-adapters/arxiv/index.mjs @@ -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) + } + }, +} diff --git a/src/content-script/site-adapters/index.mjs b/src/content-script/site-adapters/index.mjs index 7c39c7cb..93a05916 100644 --- a/src/content-script/site-adapters/index.mjs +++ b/src/content-script/site-adapters/index.mjs @@ -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 @@ -208,4 +209,10 @@ export const config = { appendContainerQuery: [], resultsContainerQuery: ['#article-content', '#thead-gallery'], }, + arxiv: { + inputQuery: arxiv.inputQuery, + sidebarContainerQuery: ['.extra-services'], + appendContainerQuery: [], + resultsContainerQuery: ['.extra-services'], + }, }