Skip to content

Commit f943990

Browse files
committed
Enable and implement the 'Search' option for the Perplexity chatbot
1 parent c690043 commit f943990

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,43 @@ import {
1111
export const perplexity: Chatbot = {
1212
wait_until_ready: async () => {
1313
await new Promise((resolve) => setTimeout(resolve, 500))
14+
;(document.querySelector('[contenteditable="true"]') as any)?.click()
15+
},
16+
set_options: async (options?: string[]) => {
17+
if (!options) return
18+
19+
if (options.includes('search')) {
20+
// Enabled by default
21+
return
22+
}
23+
24+
const switcher_button = document.querySelector(
25+
'button[data-testid="sources-switcher-button"]'
26+
) as HTMLButtonElement
27+
if (!switcher_button) {
28+
report_initialization_error({
29+
function_name: 'perplexity.set_options',
30+
log_message: 'Sources switcher button not found',
31+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
32+
})
33+
return
34+
}
35+
36+
switcher_button.click()
37+
await new Promise((r) => requestAnimationFrame(r))
38+
39+
const web_toggle = document.querySelector(
40+
'div[data-testid="source-toggle-web"]'
41+
) as HTMLElement
42+
if (web_toggle) {
43+
web_toggle.click()
44+
} else {
45+
report_initialization_error({
46+
function_name: 'perplexity.set_options',
47+
log_message: 'Web toggle button not found',
48+
alert_message: InitializationError.UNABLE_TO_SET_OPTIONS
49+
})
50+
}
1451
},
1552
enter_message_and_send: async (params) => {
1653
const input_element = document.querySelector(

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ export const CHATBOTS = {
310310
supports_reasoning_effort: false,
311311
supports_thinking_budget: false,
312312
default_system_instructions: '',
313-
supported_options: {},
313+
supported_options: {
314+
search: 'Search'
315+
},
314316
default_top_p: 0,
315317
models: {}
316318
},

0 commit comments

Comments
 (0)