支持的平台
AI-SideChat 目前支持两个主流 AI 对话平台。本文档详细介绍各平台的支持情况。
Google Gemini
基本信息
- 网址:https://gemini.google.com
- 主题色:
#8850e5(紫色) - 支持状态:✅ 完全支持
适配详情
DOM 选择器
javascript
// 侧边栏对话列表
const convList = document.querySelectorAll('.conversation-title, .conversation')
// 用户提问气泡
const userBubbles = document.querySelectorAll('user-query')
// AI 回答内容
const answers = document.querySelectorAll('.model-response-text, message-content, model-response')特点
- 使用 自定义元素 (
user-query,message-content) - Shadow DOM 包裹部分内容
- 动态渲染,需要 MutationObserver 监听
已知问题
注意
- Gemini 的 DOM 结构可能随更新变化
- 部分实验性功能可能不稳定
OpenAI ChatGPT
基本信息
- 网址:https://chatgpt.com
- 主题色:
#10a37f(绿色) - 支持状态:✅ 完全支持
适配详情
DOM 选择器
javascript
// 侧边栏对话列表
const convList = document.querySelectorAll('nav a')
// 用户提问气泡
const userBubbles = document.querySelectorAll('[data-message-author-role="user"]')
// AI 回答内容
const answers = document.querySelectorAll('.markdown')特点
- 使用 data 属性 标识角色
- Markdown 渲染,内容格式丰富
- 虚拟滚动,长对话性能优化
已知问题
注意
- ChatGPT 使用虚拟滚动,历史消息可能未渲染
- 跳转到很早的消息可能需要等待加载
平台对比
| 特性 | Gemini | ChatGPT |
|---|---|---|
| 收藏功能 | ✅ | ✅ |
| 智能跳转 | ✅ | ✅ |
| 预览功能 | ✅ | ✅ |
| 标签管理 | ✅ | ✅ |
| 代码高亮 | ✅ | ✅ |
| 图片支持 | ⏳ 规划中 | ⏳ 规划中 |
| 附件支持 | ⏳ 规划中 | ⏳ 规划中 |
适配代码
平台检测
javascript
function detectPlatform() {
const url = window.location.href
if (url.includes('gemini.google.com')) {
return {
name: 'Gemini',
color: '#8850e5',
selectors: {
userBubble: 'user-query',
answer: '.model-response-text, message-content'
}
}
}
if (url.includes('chatgpt.com')) {
return {
name: 'ChatGPT',
color: '#10a37f',
selectors: {
userBubble: '[data-message-author-role="user"]',
answer: '.markdown'
}
}
}
return null
}统一接口
javascript
class PlatformAdapter {
getUserBubbles() {
return document.querySelectorAll(this.platform.selectors.userBubble)
}
getAnswer(bubble) {
const next = bubble.nextElementSibling
return next?.querySelector(this.platform.selectors.answer)
}
extractQuestion(bubble) {
return bubble.innerText || bubble.textContent
}
extractAnswer(answerEl) {
return {
text: answerEl.innerText,
html: answerEl.innerHTML
}
}
}计划支持的平台
Claude (Anthropic)
- 网址:https://claude.ai
- 状态:⏳ 规划中
- 预计:v6.0
Perplexity
- 网址:https://perplexity.ai
- 状态:⏳ 规划中
- 预计:v6.0
Microsoft Copilot
- 网址:https://copilot.microsoft.com
- 状态:⏳ 研究中
- 预计:v7.0
文心一言
- 网址:https://yiyan.baidu.com
- 状态:⏳ 规划中
- 预计:v7.0
通义千问
- 网址:https://tongyi.aliyun.com
- 状态:⏳ 规划中
- 预计:v7.0
添加新平台
贡献指南
如果你想为 AI-SideChat 添加新平台支持:
- Fork 项目
- 创建分支:
git checkout -b feature/add-platform-xxx - 修改配置:在
manifest.json添加 host_permissions - 实现适配器:在
content.js添加平台选择器 - 测试功能:确保所有功能正常
- 提交 PR
所需信息
添加新平台需要提供:
javascript
{
name: '平台名称',
color: '主题色',
url: '平台 URL 模式',
selectors: {
userBubble: '用户气泡选择器',
answer: 'AI 回答选择器',
convTitle: '对话标题选择器'
}
}兼容性
浏览器要求
- Chrome >= 88
- Edge >= 88
- 其他基于 Chromium 的浏览器
平台版本
- Gemini:支持当前所有版本
- ChatGPT:支持 GPT-3.5、GPT-4、GPT-4 Turbo
故障排除
Gemini 按钮不显示
可能原因:
- DOM 结构已更新
- 使用了实验性功能
解决方法:
- 更新到最新版 AI-SideChat
- 提交 Issue 报告问题
ChatGPT 跳转失败
可能原因:
- 虚拟滚动未加载目标消息
- 对话 ID 已变化
解决方法:
- 手动滚动到目标位置附近
- 刷新页面重试
反馈问题
如果你在使用某个平台时遇到问题:
- 打开浏览器控制台(F12)
- 查看错误信息
- 在 GitHub 提交 Issue
- 提供平台、浏览器版本等信息
