Skip to content
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: 1 addition & 1 deletion src/content-script/menu-tools/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const config = {
summarizePage: {
label: 'Summarize Page',
genPrompt: async () => {
return `The following is the text content of a web page, analyze the core content and summarize:\n${getCoreContentText()}`
return `You are an expert summarizer. Carefully analyze the following web page content and provide a concise summary focusing on the key points:\n${getCoreContentText()}`
},
},
openConversationPage: {
Expand Down
23 changes: 14 additions & 9 deletions src/content-script/selection-tools/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const createGenPrompt =
}

let fullMessage = isTranslation
? `Translate the following into ${preferredLanguage} and only show me the translated content`
? `You are a professional translator. Translate the following text into ${preferredLanguage}, preserving meaning, tone, and formatting. Only provide the translated result.`
: message
if (enableBidirectional) {
fullMessage += `. If it is already in ${preferredLanguage}, translate it into English and only show me the translated content`
fullMessage += ` If the text is already in ${preferredLanguage}, translate it into English instead following the same requirements. Only provide the translated result.`
}
const prefix = includeLanguagePrefix ? `Reply in ${preferredLanguage}.` : ''
return `${prefix}${fullMessage}:\n'''\n${selection}\n'''`
Expand All @@ -41,7 +41,8 @@ export const config = {
icon: <ChatText />,
label: 'Explain',
genPrompt: createGenPrompt({
message: 'Explain the following',
message:
'You are an expert teacher. Explain the following content in simple terms and highlight the key points',
includeLanguagePrefix: true,
}),
},
Expand Down Expand Up @@ -80,7 +81,8 @@ export const config = {
icon: <CardHeading />,
label: 'Summary',
genPrompt: createGenPrompt({
message: 'Summarize the following as concisely as possible',
message:
'You are a professional summarizer. Summarize the following content in a few sentences, focusing on the key points',
includeLanguagePrefix: true,
}),
},
Expand All @@ -89,38 +91,41 @@ export const config = {
label: 'Polish',
genPrompt: createGenPrompt({
message:
'Check the following content for possible diction and grammar problems, and polish it carefully',
'Act as a skilled editor. Correct grammar and word choice in the following text, improve readability and flow while preserving the original meaning, and return only the polished version',
}),
},
sentiment: {
icon: <EmojiSmile />,
label: 'Sentiment Analysis',
genPrompt: createGenPrompt({
message:
'Analyze the sentiments expressed in the following content and make a brief summary of the sentiments',
'You are an expert in sentiment analysis. Analyze the following content and provide a brief summary of the overall emotional tone, labeling it with a short descriptive word or phrase',
includeLanguagePrefix: true,
}),
},
divide: {
icon: <CardList />,
label: 'Divide Paragraphs',
genPrompt: createGenPrompt({
message: 'Divide the following into paragraphs that are easy to read and understand',
message:
'You are a skilled editor. Divide the following text into clear, easy-to-read and easy-to-understand paragraphs',
}),
},
code: {
icon: <Braces />,
label: 'Code Explain',
genPrompt: createGenPrompt({
message: 'Explain the following code',
message:
'You are a senior software engineer and system architect. Break down the following code step by step, explain how each part works and why it was designed that way, note any potential issues, and summarize the overall purpose',
includeLanguagePrefix: true,
}),
},
ask: {
icon: <QuestionCircle />,
label: 'Ask',
genPrompt: createGenPrompt({
message: 'Analyze the following content and express your opinion, or give your answer',
message:
'Analyze the following content carefully and provide a concise answer or opinion with a short explanation',
includeLanguagePrefix: true,
}),
},
Expand Down
10 changes: 8 additions & 2 deletions src/content-script/site-adapters/arxiv/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ export default {
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.` +
`\n${title}\n${authors}\n${abstract}`,
`You are a research assistant skilled in academic paper analysis. ` +
`Based on the provided paper abstract from a preprint site, generate a structured summary. ` +
`The summary should clearly outline: key findings, methodology, and conclusions. ` +
`Pay special attention to highlighting the main contributions of the paper. ` +
`Ensure the summary is concise and maintains an academic tone.\n` +
`Title: ${title}\n` +
`Authors: ${authors}\n` +
`Abstract: ${abstract}`,
)
} catch (e) {
console.log(e)
Expand Down
5 changes: 4 additions & 1 deletion src/content-script/site-adapters/bilibili/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export default {
}

return await cropText(
`用尽量简练的语言,联系视频标题,对视频进行内容摘要,同时仍要保留重要细节和标题信息,如果可能的话,使用markdown语法将视频内容总结为结构化信息,视频标题为:"${title}",字幕内容为:\n${subtitleContent}`,
`You are an expert video summarizer. Create a comprehensive summary of the following Bilibili video in markdown format, ` +
`highlighting key takeaways, crucial information, and main topics. Include the video title.\n` +
`Video Title: "${title}"\n` +
`Subtitle content:\n${subtitleContent}`,
)
} catch (e) {
console.log(e)
Expand Down
15 changes: 11 additions & 4 deletions src/content-script/site-adapters/followin/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ export default {
const title = document.querySelector('main article h1')?.textContent
if (title) {
return await cropText(
`以下是一篇文章,请给出文章的结论和3到5个要点.标题是:"${title}",作者是:"${author}",内容是:\n"${description}".
`,
`You are an expert content summarizer. Please carefully read the following article. ` +
`Provide a conclusion and 3 to 5 main points, presented as a markdown list. ` +
`The summary should be concise, clear, and accurately reflect the core content.\n` +
`Title: "${title}"\n` +
`Author: "${author}"\n` +
`Content:\n"${description}"`,
)
} else {
return await cropText(
`以下是一篇长推文,请给出文章的结论和3到5个要点.作者是:"${author}",内容是:\n"${description}".
`,
`You are an expert content summarizer. Please carefully read the following long tweet. ` +
`Provide a conclusion and 3 to 5 main points, presented as a markdown list. ` +
`The summary should be concise, clear, and accurately reflect the core content.\n` +
`Author: "${author}"\n` +
`Content:\n"${description}"`,
)
}
}
Expand Down
18 changes: 14 additions & 4 deletions src/content-script/site-adapters/github/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,16 @@ function createChatGPtSummaryPrompt(issueData, isIssue = true) {

if (isIssue) {
prompt =
'Please summarize the following GitHub issue thread.\nWhat is the main issue and key points discussed in this thread?\n\n'
`You are an expert in analyzing GitHub discussions. ` +
`Please provide a concise summary of the following GitHub issue thread. ` +
`Identify the main problem reported, key points discussed by participants, proposed solutions (if any), and the current status or next steps. ` +
`Present the summary in a structured markdown format.\n\n`
} else {
prompt =
'Please summarize the following GitHub pull request thread.\nWhat is the main issue this pull request is trying to solve?\n\n'
`You are an expert in analyzing GitHub discussions and code reviews. ` +
`Please provide a concise summary of the following GitHub pull request thread. ` +
`Identify the main problem this pull request aims to solve, the proposed changes, key discussion points from the review, and the overall status of the PR (e.g., approved, needs changes, merged). ` +
`Present the summary in a structured markdown format.\n\n`
}

prompt += '---\n\n'
Expand Down Expand Up @@ -153,8 +159,12 @@ export default {
if (!patchData) return

return await cropText(
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
`The patch contents of this commit are as follows:\n${patchData}`,
`You are an expert in analyzing git commits and crafting clear, concise commit messages. ` +
`Based on the following git patch, please perform two tasks:\n` +
`1. Generate a suitable commit message. It should follow standard conventions: a short imperative subject line (max 50 chars), ` +
`followed by a blank line and a more detailed body if necessary, explaining the "what" and "why" of the changes.\n` +
`2. Provide a brief summary of the changes introduced in this commit, highlighting the main purpose and impact.\n\n` +
`The patch contents are as follows:\n${patchData}`,
)
} catch (e) {
console.log(e)
Expand Down
16 changes: 12 additions & 4 deletions src/content-script/site-adapters/gitlab/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,25 @@ export default {
if (!fileData) return

return await cropText(
`Analyze the following file content and explain it. Use markdown syntax to make your answer more readable, such as code blocks, bold, list:` +
`\n\`\`\`\n${fileData}\n\`\`\``,
`You are a senior software engineer and code reviewer. ` +
`Analyze the following file content thoroughly. ` +
`Explain its purpose, main functionalities, and how different parts of the code contribute to its overall behavior. ` +
`Identify any potential issues, areas for improvement, or notable design patterns. ` +
`Use markdown syntax (e.g., code blocks, bolding, lists) to structure your explanation for better readability.\n\n` +
`File content:\n\`\`\`\n${fileData}\n\`\`\``,
)
} else {
const patchUrl = await getPatchUrl()
const patchData = await getPatchData(patchUrl)
if (!patchData) return

return await cropText(
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
`The patch contents of this commit are as follows:\n${patchData}`,
`You are an expert in analyzing git commits and crafting clear, concise commit messages. ` +
`Based on the following git patch, please perform two tasks:\n` +
`1. Generate a suitable commit message. It should follow standard conventions: a short imperative subject line (max 50 chars), ` +
`followed by a blank line and a more detailed body if necessary, explaining the "what" and "why" of the changes.\n` +
`2. Provide a brief summary of the changes introduced in this commit, highlighting the main purpose and impact.\n\n` +
`The patch contents are as follows:\n${patchData}`,
)
}
} catch (e) {
Expand Down
13 changes: 6 additions & 7 deletions src/content-script/site-adapters/juejin/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ export default {
comment += `answer${i}: ${comment[i - 1].textContent}|`
}
return await cropText(
`以下是一篇文章,标题是:"${title}",作者是:"${author}",内容是:\n"${description}".各个评论如下:\n${comment}.请以如下格式输出你的回答:
{文章摘要和文章作者}
======
{文章总结和对文章的看法}
======
{对评论的总结}
`,
`You are an expert content analyst and summarizer. ` +
`Please analyze the following Juejin article and its comments. Provide a summary of the article (including author), your opinion on it, and a summary of the comments.\n` +
`Article Title: "${title}"\n` +
`Author: "${author}"\n` +
`Content:\n"${description}"\n\n` +
`Selected comments:\n${comment}`,
)
}
} catch (e) {
Expand Down
7 changes: 4 additions & 3 deletions src/content-script/site-adapters/quora/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export default {
}

return await cropText(
`Below is the content from a question and answer platform,giving the corresponding summary and your opinion on it.` +
`The question is:'${title}',` +
`Some answers are as follows:\n${answers}`,
`You are an insightful analyst of Q&A discussions. ` +
`Below is content from a Q&A platform. Please provide a summary of the discussion and your opinion on it.\n` +
`Question: '${title}'\n` +
`Answers:\n${answers}`,
)
} catch (e) {
console.log(e)
Expand Down
8 changes: 5 additions & 3 deletions src/content-script/site-adapters/reddit/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export default {
}

return await cropText(
`Below is the content from a social forum,giving the corresponding summary and your opinion on it.` +
`The title is:'${title}',and the further description of the title is:'${description}'.` +
`Some answers are as follows:\n${answers}`,
`You are an expert in analyzing online forum discussions. ` +
`Below is content from a social forum (Reddit). Please provide a summary of the discussion and your opinion on it.\n` +
`Title: '${title}'\n` +
`Description: '${description}'\n` +
`Comments:\n${answers}`,
)
} catch (e) {
console.log(e)
Expand Down
13 changes: 10 additions & 3 deletions src/content-script/site-adapters/stackoverflow/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ export default {
}

return await 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}`,
`You are an expert software developer and technical problem solver. ` +
`The following content is from a developer Q&A platform (Stack Overflow).\n\n` +
`Question: "${title}"\n` +
`Question Description: "${description}"\n\n` +
`Provided Answers:\n${answer}\n\n` +
`Please perform the following tasks:\n` +
`1. **Direct Solution:** Based on the provided answers, formulate a concise and effective solution to the question. ` +
`If applicable, include a brief code snippet (using markdown for formatting).\n` +
`2. **Overview of Answers:** Provide an overview of the different approaches or key points mentioned in the provided answers. ` +
`You can highlight any notable variations, pros, or cons if apparent.`,
)
}
} catch (e) {
Expand Down
12 changes: 5 additions & 7 deletions src/content-script/site-adapters/weixin/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ export default {
}

return await cropText(
`以下是一篇文章,标题是:"${title}",文章来源是:"${author}公众号",内容是:\n"${description}".请以如下格式输出你的回答:
{文章来源和文章摘要}
======
{文章总结}
======
{对文章的看法}
`,
`You are an expert article analyst and summarizer. ` +
`Please analyze the following WeChat Official Account article. Provide the source, a summary of the article, its main conclusions, and your opinion on it.\n` +
`Article Title: "${title}"\n` +
`Source: "${author} Official Account"\n` +
`Content:\n"${description}"`,
)
}
} catch (e) {
Expand Down
6 changes: 4 additions & 2 deletions src/content-script/site-adapters/youtube/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ export default {
subtitleContent = replaceHtmlEntities(subtitleContent)

return await cropText(
`Provide a structured summary of the following video in markdown format, focusing on key takeaways and crucial information, and ensuring to include the video title. The summary should be easy to read and concise, yet comprehensive.` +
`The video title is "${title}". The subtitle content is as follows:\n${subtitleContent}`,
`You are an expert video summarizer. Create a comprehensive summary of the following YouTube video in markdown format, ` +
`highlighting key takeaways, crucial information, and main topics. Include the video title.\n` +
`Video Title: "${title}"\n` +
`Subtitle content:\n${subtitleContent}`,
)
} catch (e) {
console.log(e)
Expand Down
19 changes: 14 additions & 5 deletions src/content-script/site-adapters/zhihu/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@ export default {
if (location.pathname.includes('answer')) {
answer = document.querySelector(answerQuery)?.textContent
return await cropText(
`以下是一个问答平台的提问与回答内容,给出相应的摘要,以及你对此的看法.问题是:"${title}",问题的进一步描述是:"${description}".` +
`其中一个回答如下:\n${answer}`,
`You are an insightful analyst of Q&A discussions. ` +
`Below is content from Zhihu, a Q&A platform. Please provide a summary of the question and answer, and your opinion on them.\n` +
`Question: "${title}"\n` +
`Description: "${description}"\n` +
`Answer:\n${answer}`,
)
} else {
const answers = document.querySelectorAll(answerQuery)
for (let i = 1; i <= answers.length && i <= 4; i++) {
answer += `answer${i}: ${answers[i - 1].textContent}|`
}
return await cropText(
`以下是一个问答平台的提问与回答内容,给出相应的摘要,以及你对此的看法.问题是:"${title}",问题的进一步描述是:"${description}".` +
`各个回答如下:\n${answer}`,
`You are an insightful analyst of Q&A discussions. ` +
`Below is content from Zhihu, a Q&A platform. Please provide a summary of the question and answers, and your opinion on them.\n` +
`Question: "${title}"\n` +
`Description: "${description}"\n` +
`Answers:\n${answer}`,
)
}
} else {
Expand All @@ -31,7 +37,10 @@ export default {

if (title) {
return await cropText(
`以下是一篇文章,给出相应的摘要,以及你对此的看法.标题是:"${title}",内容是:\n"${description}"`,
`You are an expert article analyst. ` +
`Below is an article from Zhihu. Please provide a summary of the article and your opinion on it.\n` +
`Title: "${title}"\n` +
`Content:\n"${description}"`,
)
}
}
Expand Down