Skip to content

Commit 2bca34a

Browse files
committed
Add model support for DeepSeek and update selectors for chatbot integrations
- to deepseek, add 'model' instant/expert (note that in 'expert' search option is not available)[Pasted text]  - to deepseek, add vision as well [Pasted text] ├── apps │ └── browser │ └── src │ └── content-scripts │ └── send-prompt-content-script │ ├── chatbots │ │ ├── ai-studio.ts │ │ ├── arena.ts │ │ ├── chatgpt.ts │ │ ├── claude.ts │ │ ├── copilot.ts │ │ ├── deepseek.ts │ │ ├── doubao.ts │ │ ├── gemini.ts │ │ ├── github-copilot.ts │ │ ├── grok.ts │ │ ├── hugging-chat.ts │ │ ├── index.ts │ │ ├── kimi.ts │ │ ├── meta.ts │ │ ├── mistral.ts │ │ ├── open-webui.ts │ │ ├── openrouter.ts │ │ ├── qwen.ts │ │ ├── together.ts │ │ ├── yuanbao.ts │ │ └── z-ai.ts │ └── utils │ ├── add-apply-response-button.ts │ ├── apply-response-styles.ts │ ├── logger.ts │ ├── report-initialization-error.ts │ └── show-response-ready-notification.ts └── packages └── shared └── src └── constants └── chatbots.ts
1 parent 95c27cc commit 2bca34a

4 files changed

Lines changed: 63 additions & 35 deletions

File tree

‎apps/browser/src/content-scripts/send-prompt-content-script/chatbots/claude.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const claude: Chatbot = {
8989
get_chat_turn: (f) => f.closest('.group'),
9090
perform_copy: (f) => {
9191
const copy_button = f.querySelector(
92-
'button[data-testid="action-bar-copy"]'
92+
'button:first-child'
9393
) as HTMLElement
9494
if (!copy_button) {
9595
report_initialization_error({
@@ -108,7 +108,7 @@ export const claude: Chatbot = {
108108
const stop_button_selector =
109109
'path[d="M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm40-112v56a12,12,0,0,1-12,12H100a12,12,0,0,1-12-12V100a12,12,0,0,1,12-12h56A12,12,0,0,1,168,100Z"]'
110110
const footer_selector =
111-
'div[data-test-render-count] > div > div:nth-child(2) > div > div'
111+
'div[data-test-render-count] > div > div:nth-child(2)'
112112

113113
observe_for_responses({
114114
chatbot_name: 'Claude',

‎apps/browser/src/content-scripts/send-prompt-content-script/chatbots/copilot.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const copilot: Chatbot = {
4141
get_chat_turn: (f) => f.closest('div[data-content="ai-message"]'),
4242
perform_copy: (f) => {
4343
const copy_button = f.querySelector(
44-
'button[data-testid="copy-message-button"]'
44+
'button[data-testid="copy-ai-message-button"]'
4545
) as HTMLElement
4646
if (!copy_button) {
4747
report_initialization_error({

‎apps/browser/src/content-scripts/send-prompt-content-script/chatbots/deepseek.ts‎

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,72 @@ import {
77
import { report_initialization_error } from '../utils/report-initialization-error'
88

99
export const deepseek: Chatbot = {
10+
set_model: async (chat) => {
11+
const model = chat.model
12+
if (!model) return
13+
14+
let target_type = ''
15+
if (model == 'expert') {
16+
target_type = 'expert'
17+
} else if (model == 'instant') {
18+
target_type = 'default'
19+
} else if (model == 'vision') {
20+
target_type = 'vision'
21+
}
22+
23+
if (target_type) {
24+
const model_radio = document.querySelector(
25+
`div[data-model-type="${target_type}"]`
26+
) as HTMLElement
27+
if (model_radio) {
28+
const is_checked = model_radio.getAttribute('aria-checked') == 'true'
29+
if (!is_checked) {
30+
model_radio.click()
31+
await new Promise((r) => requestAnimationFrame(r))
32+
}
33+
} else {
34+
report_initialization_error({
35+
function_name: 'set_model',
36+
log_message: `Model radio button for "${model}" not found`
37+
})
38+
}
39+
}
40+
},
1041
set_options: async (chat) => {
1142
const deep_think_button = Array.from(
12-
document.querySelectorAll('div[role="button"]')
43+
document.querySelectorAll('div.ds-toggle-button')
1344
).find(
1445
(button) =>
1546
button.textContent == 'DeepThink' || button.textContent == '深度思考'
1647
) as HTMLButtonElement
17-
if (!deep_think_button) {
18-
report_initialization_error({
19-
function_name: 'set_options',
20-
log_message: 'DeepThink button not found'
21-
})
22-
return
23-
}
2448

2549
const search_button = Array.from(
26-
document.querySelectorAll('div[role="button"]')
50+
document.querySelectorAll('div.ds-toggle-button')
2751
).find(
2852
(button) =>
2953
button.textContent == 'Search' || button.textContent == '联网搜索'
3054
) as HTMLButtonElement
31-
if (!search_button) {
32-
report_initialization_error({
33-
function_name: 'set_options',
34-
log_message: 'Search button not found'
35-
})
36-
return
37-
}
3855

39-
const deep_think_button_style = window.getComputedStyle(deep_think_button)
40-
if (
41-
deep_think_button_style.getPropertyValue('color') != 'rgb(15, 17, 21)' &&
42-
deep_think_button_style.getPropertyValue('color') != 'rgb(249, 250, 251)'
43-
) {
44-
deep_think_button.click()
56+
if (deep_think_button) {
57+
const deep_think_button_style = window.getComputedStyle(deep_think_button)
58+
if (
59+
deep_think_button_style.getPropertyValue('color') !=
60+
'rgb(15, 17, 21)' &&
61+
deep_think_button_style.getPropertyValue('color') !=
62+
'rgb(249, 250, 251)'
63+
) {
64+
deep_think_button.click()
65+
}
4566
}
4667

47-
const search_button_style = window.getComputedStyle(search_button)
48-
if (
49-
search_button_style.getPropertyValue('color') != 'rgb(15, 17, 21)' &&
50-
search_button_style.getPropertyValue('color') != 'rgb(249, 250, 251)'
51-
) {
52-
search_button.click()
68+
if (search_button) {
69+
const search_button_style = window.getComputedStyle(search_button)
70+
if (
71+
search_button_style.getPropertyValue('color') != 'rgb(15, 17, 21)' &&
72+
search_button_style.getPropertyValue('color') != 'rgb(249, 250, 251)'
73+
) {
74+
search_button.click()
75+
}
5376
}
5477

5578
await new Promise((r) => requestAnimationFrame(r))
@@ -59,9 +82,9 @@ export const deepseek: Chatbot = {
5982
const supported_options = CHATBOTS.DeepSeek.supported_options
6083
for (const option of options) {
6184
if (option == 'deep-think' && supported_options?.['deep-think']) {
62-
deep_think_button.click()
85+
deep_think_button?.click()
6386
} else if (option == 'search' && supported_options?.search) {
64-
search_button.click()
87+
search_button?.click()
6588
}
6689
}
6790
await new Promise((r) => requestAnimationFrame(r))
@@ -128,7 +151,7 @@ export const deepseek: Chatbot = {
128151
) && !textarea.value
129152
)
130153
},
131-
footer_selector: 'div.ds-message + div + div > div.ds-flex',
154+
footer_selector: 'div.ds-message + div > div.ds-flex',
132155
add_buttons: params.inject_button ? add_buttons : undefined
133156
})
134157
}

‎packages/shared/src/constants/chatbots.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ export const CHATBOTS = {
7373
} as Chatbot,
7474
DeepSeek: {
7575
url: 'https://chat.deepseek.com/',
76-
supported_options: { 'deep-think': 'DeepThink', search: 'Search' }
76+
supported_options: { 'deep-think': 'DeepThink', search: 'Search' },
77+
models: {
78+
instant: { label: 'Instant' },
79+
expert: { label: 'Expert', disabled_options: ['search'] },
80+
vision: { label: 'Vision', disabled_options: ['search'] }
81+
}
7782
} as Chatbot,
7883
Doubao: {
7984
url: 'https://www.doubao.com/chat/',

0 commit comments

Comments
 (0)