Skip to content

Commit d2cc136

Browse files
committed
Add fallback to enable thinking mode via composer plus button menu when think icon is not found
- below 640px, 'think' button is placed in a dropdown that can be opened by clicking [Pasted text], dropdown is mounted in body: [Pasted text]
1 parent 45353cf commit d2cc136

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

  • apps/browser/src/content-scripts/send-prompt-content-script/chatbots

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,33 @@ export const chatgpt: Chatbot = {
187187
think_button.click()
188188
}
189189
} else {
190-
report_initialization_error({
191-
function_name: 'set_options',
192-
log_message: 'Think button icon not found'
193-
})
190+
const plus_button = document.querySelector(
191+
'[data-testid="composer-plus-btn"]'
192+
) as HTMLButtonElement
193+
if (plus_button) {
194+
plus_button.dispatchEvent(
195+
new PointerEvent('pointerdown', {
196+
bubbles: true
197+
})
198+
)
199+
await new Promise((resolve) => requestAnimationFrame(resolve))
200+
const thinking_menuitem = Array.from(
201+
document.querySelectorAll('[role="menuitemradio"]')
202+
).find((el) => el.textContent?.includes('Thinking')) as HTMLElement
203+
if (thinking_menuitem) {
204+
thinking_menuitem.click()
205+
} else {
206+
report_initialization_error({
207+
function_name: 'set_options',
208+
log_message: 'Thinking menu item not found'
209+
})
210+
}
211+
} else {
212+
report_initialization_error({
213+
function_name: 'set_options',
214+
log_message: 'Think button icon not found'
215+
})
216+
}
194217
}
195218
}
196219
}

0 commit comments

Comments
 (0)