Skip to content

Commit 067b2fa

Browse files
committed
Update chatbot integrations and configurations for Qwen, Yuanbao, and Z
- refrom qwen, remove options: thinking, search - keep pressing the temporary button until aria-pressed="true". use interval 100ms without any limit on tries. - qwen should have two models: 'Fast' and 'Thinking'. Model selector show up on click on [Pasted text]. popup with Fast and Thinking options: [Pasted text] - remove the interval when setting temporary qwen - to copy in `apps/browser/src/content-scripts/send-prompt-content-script/chatbots/yuanbao.ts`, you first need to click on [Pasted text] (located in the footer), then popup appears: [Pasted text] and you need 'copy as markdown'. Note strings can be translated to chinese here so don't use aria label. - from z.ai, remove deep think option ├── 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 └── packages └── shared └── src └── constants └── chatbots.ts
1 parent 721c84e commit 067b2fa

5 files changed

Lines changed: 50 additions & 96 deletions

File tree

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

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const qwen: Chatbot = {
1111
await new Promise((resolve) => {
1212
const check_for_element = () => {
1313
const model_selector_button = document.querySelector(
14-
'.ant-dropdown-trigger'
14+
'textarea.message-input-textarea'
1515
) as HTMLElement
1616

1717
if (model_selector_button) {
@@ -22,13 +22,13 @@ export const qwen: Chatbot = {
2222
}
2323
check_for_element()
2424
})
25-
await new Promise((resolve) => setTimeout(resolve, 500))
25+
await new Promise((resolve) => setTimeout(resolve, 1500))
2626
},
2727
set_model: async (chat) => {
2828
const model = chat.model
2929
if (!model) return
3030
const model_selector_button = document.querySelector(
31-
'.header-left .ant-dropdown-trigger'
31+
'.qwen-chat-v2-dropdown-menu-select'
3232
) as HTMLElement
3333
if (!model_selector_button) {
3434
report_initialization_error({
@@ -47,30 +47,18 @@ export const qwen: Chatbot = {
4747

4848
model_selector_button.click()
4949
await new Promise((r) => requestAnimationFrame(r))
50+
await new Promise((r) => setTimeout(r, 100))
5051

51-
const expand_more = document.querySelector(
52-
'[class*="index-module__model-selector-view-more__"]'
53-
) as HTMLElement
54-
if (expand_more) {
55-
expand_more.click()
56-
await new Promise((r) => setTimeout(r, 300))
57-
} else {
58-
report_initialization_error({
59-
function_name: 'set_model',
60-
log_message: 'Expand more button not found'
61-
})
62-
return
63-
}
6452
const model_buttons = document.querySelectorAll(
65-
'[class*="index-module__model-selector-dropdown-menu-item___"]'
66-
) as NodeListOf<HTMLButtonElement>
53+
'.qwen-chat-v2-dropdown-menu-item'
54+
) as NodeListOf<HTMLElement>
6755
for (const button of Array.from(model_buttons)) {
68-
const model_name_element = (button.querySelector(
69-
'[class*="index-module__model-name-text___"]'
70-
) || button.querySelector('div.text-15')) as HTMLDivElement
56+
const model_name_element = button.querySelector(
57+
'.qwen-chat-v2-dropdown-menu-item-label'
58+
) as HTMLSpanElement
7159
if (
7260
model_name_element &&
73-
model_name_element.textContent ==
61+
model_name_element.textContent?.trim() ==
7462
CHATBOTS['Qwen'].models?.[model]?.label
7563
) {
7664
button.click()
@@ -88,41 +76,12 @@ export const qwen: Chatbot = {
8876
const temporary_button = document.querySelector(
8977
'.temporary-chat-entry'
9078
) as HTMLButtonElement
91-
if (!temporary_button) {
92-
report_initialization_error({
93-
function_name: 'set_options',
94-
log_message: 'Temporary chat button not found'
95-
})
96-
return
97-
}
98-
temporary_button.click()
99-
await new Promise((r) => requestAnimationFrame(r))
100-
} else if (option == 'thinking' && supported_options?.['thinking']) {
101-
const thinking_button = document.querySelector(
102-
'.chat-message-input-thinking-budget-btn > div'
103-
) as HTMLDivElement
104-
if (!thinking_button) {
105-
report_initialization_error({
106-
function_name: 'set_options',
107-
log_message: 'Thinking button not found'
108-
})
109-
return
110-
}
111-
thinking_button.click()
112-
await new Promise((r) => requestAnimationFrame(r))
113-
} else if (option == 'search' && supported_options?.['search']) {
114-
const search_button = document.querySelector(
115-
'.chat-message-input-thinking-budget-btn + div'
116-
) as HTMLDivElement
117-
if (!search_button) {
118-
report_initialization_error({
119-
function_name: 'set_options',
120-
log_message: 'Search button not found'
121-
})
122-
return
79+
if (
80+
temporary_button &&
81+
temporary_button.getAttribute('aria-pressed') !== 'true'
82+
) {
83+
temporary_button.click()
12384
}
124-
search_button.click()
125-
await new Promise((r) => requestAnimationFrame(r))
12685
}
12786
}
12887
},
@@ -150,7 +109,7 @@ export const qwen: Chatbot = {
150109
get_code_from_block: (b) => b.querySelector('.cm-line')?.textContent,
151110
perform_copy: (f) => {
152111
const copy_button = f.querySelector(
153-
'div.qwen-chat-package-comp-new-action-control-container-copy'
112+
'button:first-child'
154113
) as HTMLElement
155114
if (!copy_button) {
156115
report_initialization_error({
@@ -168,8 +127,8 @@ export const qwen: Chatbot = {
168127
}
169128
copy_button.click()
170129
},
171-
insert_button: (f, b) => f.insertBefore(b, f.children[0]),
172-
customize_button: (b) => (b.style.order = '7')
130+
insert_button: (f, b) =>
131+
f.insertBefore(b, f.children[f.children.length])
173132
})
174133
}
175134

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const yuanbao: Chatbot = {
99
wait_until_ready: async () => {
1010
await new Promise((resolve) => {
1111
const check_for_element = () => {
12-
if (document.querySelector('.input-guide-v2')) {
12+
if (document.querySelector('div[contenteditable="true"]')) {
1313
resolve(null)
1414
} else {
1515
setTimeout(check_for_element, 100)
@@ -41,18 +41,34 @@ export const yuanbao: Chatbot = {
4141
client_id: params.client_id,
4242
raw_instructions: params.raw_instructions,
4343
footer,
44-
perform_copy: (f) => {
45-
const copy_button = f.querySelector(
46-
'.agent-chat__toolbar__copy'
44+
perform_copy: async (f) => {
45+
const copy_dropdown_arrow = f.querySelector(
46+
'div[class*="ToolbarCopy_arrowIconWrap"]'
4747
) as HTMLElement
48-
if (!copy_button) {
48+
if (!copy_dropdown_arrow) {
4949
report_initialization_error({
5050
function_name: 'yuanbao.perform_copy',
51-
log_message: 'Copy button not found'
51+
log_message: 'Copy dropdown arrow not found'
5252
})
5353
return
5454
}
55-
copy_button.click()
55+
copy_dropdown_arrow.click()
56+
57+
await new Promise((resolve) => setTimeout(resolve, 100))
58+
59+
const dropdown_items = document.querySelectorAll(
60+
'.t-popup__content[class*="ToolbarCopy_dropdown-menu"] .t-dropdown__item'
61+
)
62+
const copy_markdown_option = dropdown_items[1] as HTMLElement
63+
64+
if (!copy_markdown_option) {
65+
report_initialization_error({
66+
function_name: 'yuanbao.perform_copy',
67+
log_message: 'Copy as markdown option not found'
68+
})
69+
return
70+
}
71+
copy_markdown_option.click()
5672
},
5773
insert_button: (f, b) => f.insertBefore(b, f.children[6])
5874
})

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,6 @@ export const z_ai: Chatbot = {
1818
check_for_element()
1919
})
2020
},
21-
set_options: async (chat) => {
22-
const options = chat.options
23-
24-
const deep_think_button = document.querySelector(
25-
'button[data-autothink]'
26-
) as HTMLButtonElement
27-
if (!deep_think_button) {
28-
report_initialization_error({
29-
function_name: 'z_ai.set_options',
30-
log_message: 'Auto think button not found'
31-
})
32-
return
33-
}
34-
35-
const should_be_on = options?.includes('deep-think') || false
36-
const is_on = deep_think_button.getAttribute('data-autothink') == 'true'
37-
38-
if (should_be_on != is_on) {
39-
deep_think_button.click()
40-
await new Promise((r) => requestAnimationFrame(r))
41-
}
42-
},
4321
enter_message: async (params) => {
4422
const input_element = document.querySelector(
4523
'textarea'
@@ -80,7 +58,8 @@ export const z_ai: Chatbot = {
8058
chatbot_name: 'Z.AI',
8159
is_generating: () =>
8260
!document.querySelector('button[id="send-message-button"]'),
83-
footer_selector: '.chat-assistant + div',
61+
footer_selector:
62+
'div[id="messages-container"] > div > div > div > div > div:last-child > div > div:last-child > div > div:last-child',
8463
add_buttons: params.inject_button ? add_buttons : undefined
8564
})
8665
}

‎apps/browser/src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"https://openrouter.ai/chat*",
4444
"https://chat.qwen.ai/*",
4545
"https://chat.together.ai/",
46-
"https://yuanbao.tencent.com/chat*",
46+
"https://yuanbao.tencent.com/*",
4747
"https://chat.z.ai/",
4848
"http://localhost/"
4949
],

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,13 @@ export const CHATBOTS = {
168168
url: 'https://chat.qwen.ai/',
169169
supports_url_override: true,
170170
url_override_label: 'Project URL',
171+
url_override_disabled_options: ['temporary'],
171172
supported_options: {
172-
thinking: 'Thinking',
173-
search: 'Search',
174173
temporary: 'Temporary'
174+
},
175+
models: {
176+
fast: { label: 'Fast' },
177+
thinking: { label: 'Thinking' }
175178
}
176179
} as Chatbot,
177180
Together: {
@@ -181,9 +184,6 @@ export const CHATBOTS = {
181184
url: 'https://yuanbao.tencent.com/chat'
182185
} as Chatbot,
183186
Z: {
184-
url: 'https://chat.z.ai/',
185-
supported_options: {
186-
'deep-think': 'Deep Think'
187-
}
187+
url: 'https://chat.z.ai/'
188188
} as Chatbot
189189
}

0 commit comments

Comments
 (0)