Skip to content

Commit 85f583e

Browse files
committed
Update DeepSeek and Qwen selectors to fix functionality and remove the unused Meta chatbot file
1 parent 99f1139 commit 85f583e

4 files changed

Lines changed: 67 additions & 72 deletions

File tree

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ import { report_initialization_error } from '../utils/report-initialization-erro
88

99
export const deepseek: Chatbot = {
1010
set_options: async (chat) => {
11-
const options = chat.options
12-
if (!options) return
13-
1411
const deep_think_button = Array.from(
1512
document.querySelectorAll('button')
1613
).find(
1714
(button) =>
18-
button.textContent === 'DeepThink' || button.textContent === '深度思考'
15+
button.textContent == 'DeepThink' || button.textContent == '深度思考'
1916
)
2017
if (!deep_think_button) {
2118
report_initialization_error({
@@ -27,7 +24,7 @@ export const deepseek: Chatbot = {
2724

2825
const search_button = Array.from(document.querySelectorAll('button')).find(
2926
(button) =>
30-
button.textContent === 'Search' || button.textContent === '联网搜索'
27+
button.textContent == 'Search' || button.textContent == '联网搜索'
3128
)
3229
if (!search_button) {
3330
report_initialization_error({
@@ -40,28 +37,30 @@ export const deepseek: Chatbot = {
4037
// Uncheck deep think
4138
const deep_think_button_style = window.getComputedStyle(deep_think_button)
4239
if (
43-
deep_think_button_style.getPropertyValue('color') !== 'rgb(15, 17, 21)' &&
44-
deep_think_button_style.getPropertyValue('color') !== 'rgb(249, 250, 251)'
40+
deep_think_button_style.getPropertyValue('color') != 'rgb(15, 17, 21)' &&
41+
deep_think_button_style.getPropertyValue('color') != 'rgb(249, 250, 251)'
4542
) {
4643
deep_think_button.click()
4744
}
4845

4946
// Uncheck search
5047
const search_button_style = window.getComputedStyle(search_button)
5148
if (
52-
search_button_style.getPropertyValue('color') !== 'rgb(15, 17, 21)' &&
53-
search_button_style.getPropertyValue('color') !== 'rgb(249, 250, 251)'
49+
search_button_style.getPropertyValue('color') != 'rgb(15, 17, 21)' &&
50+
search_button_style.getPropertyValue('color') != 'rgb(249, 250, 251)'
5451
) {
5552
search_button.click()
5653
}
5754

5855
await new Promise((r) => requestAnimationFrame(r))
5956

57+
const options = chat.options
58+
if (!options) return
6059
const supported_options = CHATBOTS.DeepSeek.supported_options
6160
for (const option of options) {
62-
if (option === 'deep-think' && supported_options?.['deep-think']) {
61+
if (option == 'deep-think' && supported_options?.['deep-think']) {
6362
deep_think_button.click()
64-
} else if (option === 'search' && supported_options?.search) {
63+
} else if (option == 'search' && supported_options?.search) {
6564
search_button.click()
6665
}
6766
}

‎packages/browser/src/content-scripts/send-prompt-content-script/chatbots/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export * from './github-copilot'
99
export * from './hugging-chat'
1010
export * from './lmarena'
1111
export * from './minimax'
12-
export * from './meta'
1312
export * from './mistral'
1413
export * from './open-webui'
1514
export * from './openrouter'

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

Lines changed: 56 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,24 @@ export const qwen: Chatbot = {
1111
await new Promise((resolve) => {
1212
const check_for_element = () => {
1313
const model_selector_button = document.querySelector(
14-
'button#model-selector-0-button'
14+
'.ant-dropdown-trigger'
1515
) as HTMLElement
1616

17-
if (
18-
model_selector_button &&
19-
model_selector_button.textContent &&
20-
Object.values(CHATBOTS['Qwen'].models ?? {})
21-
.map((model) => model.label)
22-
.includes(model_selector_button.textContent.trim())
23-
) {
17+
if (model_selector_button) {
2418
resolve(null)
2519
} else {
2620
setTimeout(check_for_element, 100)
2721
}
2822
}
2923
check_for_element()
3024
})
25+
await new Promise((resolve) => setTimeout(resolve, 500))
3126
},
3227
set_model: async (chat) => {
3328
const model = chat.model
3429
if (!model) return
3530
const model_selector_button = document.querySelector(
36-
'button#model-selector-0-button'
31+
'.header-left .ant-dropdown-trigger'
3732
) as HTMLElement
3833
if (!model_selector_button) {
3934
report_initialization_error({
@@ -52,8 +47,9 @@ export const qwen: Chatbot = {
5247

5348
model_selector_button.click()
5449
await new Promise((r) => requestAnimationFrame(r))
50+
5551
const expand_more = document.querySelector(
56-
'div[aria-labelledby="model-selector-0-button"] div.expand-more'
52+
'[class*="index-module__model-selector-view-more__"]'
5753
) as HTMLElement
5854
if (expand_more) {
5955
expand_more.click()
@@ -66,14 +62,15 @@ export const qwen: Chatbot = {
6662
return
6763
}
6864
const model_buttons = document.querySelectorAll(
69-
'div[aria-labelledby="model-selector-0-button"] button[aria-label="model-item"]'
65+
'[class*="index-module__model-selector-dropdown-menu-item___"]'
7066
) as NodeListOf<HTMLButtonElement>
7167
for (const button of Array.from(model_buttons)) {
72-
const model_name_element = (button.querySelector('div.text-sm') ||
73-
button.querySelector('div.text-15')) as HTMLDivElement
68+
const model_name_element = (button.querySelector(
69+
'[class*="index-module__model-name-text___"]'
70+
) || button.querySelector('div.text-15')) as HTMLDivElement
7471
if (
7572
model_name_element &&
76-
model_name_element.textContent ===
73+
model_name_element.textContent ==
7774
CHATBOTS['Qwen'].models?.[model]?.label
7875
) {
7976
button.click()
@@ -139,45 +136,47 @@ export const qwen: Chatbot = {
139136
}
140137
},
141138
enter_message_and_send: async (params) => {
142-
let instructions = params.message
143-
if (params.message.includes('<files>')) {
144-
instructions = params.message.split('<files>')[0].trim()
145-
const context = params.message
146-
.split('<files>')[1]
147-
.split('</files>')[0]
148-
.trim()
139+
const instructions = params.message
140+
// Commented out because doesn't work anymore
141+
// if (params.message.includes('<files>')) {
142+
// instructions = params.message.split('<files>')[0].trim()
143+
// const context = params.message
144+
// .split('<files>')[1]
145+
// .split('</files>')[0]
146+
// .trim()
149147

150-
// Upload file
151-
const file_input = document.querySelector(
152-
'input#filesUpload'
153-
) as HTMLInputElement
154-
if (!file_input) {
155-
report_initialization_error({
156-
function_name: 'enter_message_and_send',
157-
log_message: 'File input not found'
158-
})
159-
return
160-
}
161-
const blob = new Blob([`<files>\n${context}\n</files>`], {
162-
type: 'text/plain'
163-
})
164-
const file = new File([blob], 'files.txt', { type: 'text/plain' })
165-
const data_transfer = new DataTransfer()
166-
data_transfer.items.add(file)
167-
file_input.files = data_transfer.files
168-
file_input.dispatchEvent(new Event('change', { bubbles: true }))
169-
await new Promise((r) => requestAnimationFrame(r))
170-
await new Promise((resolve) => {
171-
const check_for_element = () => {
172-
if (document.querySelector('i.icontxt1')) {
173-
resolve(null)
174-
} else {
175-
setTimeout(check_for_element, 100)
176-
}
177-
}
178-
check_for_element()
179-
})
180-
}
148+
// // Upload file
149+
// const file_input = document.querySelector(
150+
// 'input#filesUpload'
151+
// ) as HTMLInputElement
152+
// if (!file_input) {
153+
// report_initialization_error({
154+
// function_name: 'enter_message_and_send',
155+
// log_message: 'File input not found'
156+
// })
157+
// return
158+
// }
159+
// const blob = new Blob([`<files>\n${context}\n</files>`], {
160+
// type: 'text/plain'
161+
// })
162+
// const file = new File([blob], 'files.txt', { type: 'text/plain' })
163+
// const data_transfer = new DataTransfer()
164+
// data_transfer.items.add(file)
165+
// file_input.files = data_transfer.files
166+
// file_input.dispatchEvent(new Event('change', { bubbles: true }))
167+
// file_input.dispatchEvent(new Event('input', { bubbles: true }))
168+
// await new Promise((r) => requestAnimationFrame(r))
169+
// await new Promise((resolve) => {
170+
// const check_for_element = () => {
171+
// if (document.querySelector('i.icontxt1')) {
172+
// resolve(null)
173+
// } else {
174+
// setTimeout(check_for_element, 100)
175+
// }
176+
// }
177+
// check_for_element()
178+
// })
179+
// }
181180

182181
// Enter instructions
183182
const input_element = document.querySelector(
@@ -199,7 +198,7 @@ export const qwen: Chatbot = {
199198

200199
// Submit
201200
const submit_button = document.querySelector(
202-
'button#send-message-button'
201+
'button.send-button'
203202
) as HTMLButtonElement
204203
if (!submit_button) {
205204
report_initialization_error({
@@ -222,13 +221,11 @@ export const qwen: Chatbot = {
222221
edit_format,
223222
footer,
224223
get_chat_turn: (f) =>
225-
f.parentElement?.parentElement?.querySelector(
226-
'#response-content-container'
227-
) as HTMLElement,
224+
f.closest('.chat-response-message') as HTMLElement,
228225
get_code_from_block: (b) => b.querySelector('.cm-line')?.textContent,
229226
perform_copy: (f) => {
230227
const copy_button = f.querySelector(
231-
'button.copy-response-button'
228+
'div.qwen-chat-package-comp-new-action-control-container-copy'
232229
) as HTMLElement
233230
if (!copy_button) {
234231
report_initialization_error({
@@ -253,8 +250,8 @@ export const qwen: Chatbot = {
253250

254251
observe_for_responses({
255252
chatbot_name: 'Qwen',
256-
is_generating: () => !!document.querySelector('i.icon-StopIcon'),
257-
footer_selector: '.message-footer-buttons',
253+
is_generating: () => !document.querySelector('.send-button.disabled'),
254+
footer_selector: '.qwen-chat-package-comp-new-action-control-icons',
258255
add_buttons
259256
})
260257
}

‎packages/browser/src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "Code Web Chat Connector",
55
"short_name": "CWC",
66
"description": "Connect your editor with free chatbots. Parse websites for context.",
7-
"version": "1.69.0",
7+
"version": "1.70.0",
88
"homepage_url": "https://github.com/robertpiosik/CodeWebChat",
99
"icons": {
1010
"16": "icons/icon-16.png",

0 commit comments

Comments
 (0)