Skip to content

Commit 4543b4d

Browse files
author
whyiyhw
committed
优化聊天服务检测逻辑,增加基于主机名和URL的判断;更新内容脚本以输出当前主机名;修复数据提取器中的聊天标题获取逻辑;调整提示按钮的类名以符合新样式。
1 parent 173bd47 commit 4543b4d

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

src/content/core/chatServices.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@
77
* @returns {String} 聊天服务名称或空字符串
88
*/
99
export function detectChatService() {
10-
// 尝试通过页面内容检测AI聊天服务
10+
// 优先使用URL进行判断
11+
const currentHost = window.location.hostname;
12+
const currentUrl = window.location.href;
13+
14+
// 基于URL的精确检测
15+
if (currentHost.includes('deepseek.com') || currentUrl.includes('deepseek.com')) {
16+
return 'deepseek';
17+
} else if (currentHost.includes('claude.ai') || currentUrl.includes('claude.ai')) {
18+
return 'claude';
19+
} else if (currentHost.includes('chat.openai.com') || currentUrl.includes('chat.openai.com')) {
20+
return 'chatgpt';
21+
} else if (currentHost.includes('gemini.google.com') || currentUrl.includes('gemini.google.com') ||
22+
currentHost.includes('bard.google.com') || currentUrl.includes('bard.google.com')) {
23+
return 'gemini';
24+
} else if (currentHost.includes('yuanbao.tencent.com') || currentUrl.includes('yuanbao.tencent.com')) {
25+
return 'yuanbao';
26+
}
27+
28+
// 如果URL判断不成功,尝试通过页面内容检测
1129
if (document.title.includes('ChatGPT') || document.body.innerHTML.includes('ChatGPT')) {
1230
return 'chatgpt';
1331
} else if (document.title.includes('Claude') || document.body.innerHTML.includes('Claude')) {

src/content/features/data-extractors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ async function extractAllDeepSeekData() {
465465
const allChats = records.map(record => {
466466
let chatData = {
467467
id: record.key || (record.chat_session && record.chat_session.id) || '',
468-
title: record.data.title || '未命名聊天',
468+
title: record.chat_session.title || '未命名聊天',
469469
timestamp: record.data.timestamp || new Date().toISOString(),
470470
messages: []
471471
};

src/content/features/prompt/promptButton.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,13 +738,13 @@ function createYuanbaoPromptButton(searchButton, buttonArea, isChinese) {
738738
});
739739

740740
// 特别设置按钮的类名
741-
promptButton.className = 'style__switch-model--btn___SVFm2 t-button t-button--theme-default t-button--variant-outline';
741+
promptButton.className = 'yb-switch-model-btn yb-button-normal--border style__switch-model--btn___SVFm2 t-button t-button--theme-default t-button--variant-outline';
742742

743743
// 设置内联样式
744744
promptButton.style.fontWeight = '500';
745745
} else {
746746
// 如果没有找到搜索按钮,使用默认样式
747-
promptButton.className = 'style__switch-model--btn___SVFm2 t-button t-button--theme-default t-button--variant-outline';
747+
promptButton.className = 'yb-switch-model-btn yb-button-normal--border style__switch-model--btn___SVFm2 t-button t-button--theme-default t-button--variant-outline';
748748
promptButton.style.fontWeight = '500';
749749
}
750750

src/content/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function createMountPoint() {
2323
function initExtension() {
2424
console.log('Deep Chat Optimize 内容脚本已加载');
2525
console.log('当前URL:', window.location.href);
26+
console.log('当前主机名:', window.location.hostname);
2627

2728
// 检测当前聊天服务
2829
const chatService = detectChatService();

0 commit comments

Comments
 (0)