Skip to content

Commit 267a18d

Browse files
committed
Fix initialization for ChatGPT and Perplexity to support specific chat or project URLs
1 parent c61cd75 commit 267a18d

3 files changed

Lines changed: 43 additions & 14 deletions

File tree

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

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,35 @@ import {
1111

1212
export const chatgpt: Chatbot = {
1313
wait_until_ready: async () => {
14-
await new Promise((resolve) => {
15-
const check_for_element = () => {
16-
if (
17-
document.querySelector(
18-
'span[data-testid="blocking-initial-modals-done"]'
19-
)
20-
) {
21-
resolve(null)
22-
} else {
23-
setTimeout(check_for_element, 100)
14+
const url = new URL(window.location.href)
15+
if (url.pathname == '/') {
16+
await new Promise((resolve) => {
17+
const check_for_element = () => {
18+
if (
19+
document.querySelector(
20+
'span[data-testid="blocking-initial-modals-done"]'
21+
)
22+
) {
23+
resolve(null)
24+
} else {
25+
setTimeout(check_for_element, 100)
26+
}
2427
}
25-
}
26-
check_for_element()
27-
})
28+
check_for_element()
29+
})
30+
} else {
31+
// User used custom path url for a "project"
32+
await new Promise((resolve) => {
33+
const check_for_element = () => {
34+
if (document.querySelector('textarea')) {
35+
resolve(null)
36+
} else {
37+
setTimeout(check_for_element, 100)
38+
}
39+
}
40+
check_for_element()
41+
})
42+
}
2843
},
2944
set_options: async (options?: string[]) => {
3045
if (!options) return

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ import {
1010

1111
export const perplexity: Chatbot = {
1212
wait_until_ready: async () => {
13+
const url = new URL(window.location.href)
14+
if (url.pathname != '/') {
15+
// User used custom path url for a "space"
16+
await new Promise((resolve) => {
17+
const check_for_element = () => {
18+
if (document.querySelector('div[contenteditable="true"]')) {
19+
resolve(null)
20+
} else {
21+
setTimeout(check_for_element, 100)
22+
}
23+
}
24+
check_for_element()
25+
})
26+
}
1327
await new Promise((resolve) => setTimeout(resolve, 500))
1428
if (window.innerWidth <= 768) {
1529
;(document.querySelector('[contenteditable="true"]') as any)?.click()

‎packages/browser/src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
{
2626
"matches": [
2727
"https://aistudio.google.com/prompts/new_chat",
28-
"https://chatgpt.com/",
28+
"https://chatgpt.com/*",
2929
"https://claude.ai/new",
3030
"https://copilot.microsoft.com/",
3131
"https://chat.deepseek.com/",

0 commit comments

Comments
 (0)