forked from legendjw/ai-chat-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatsonic-ai-chat.ts
34 lines (28 loc) · 1.1 KB
/
chatsonic-ai-chat.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { type SendKey } from '@/ai/abstract-ai-chat';
import InputElementAiChat from '@/ai/input-element-ai-chat';
// @ts-ignore
import iconUrl from 'data-url:@/assets/chatsonic.png';
class ChatsonicAiChat extends InputElementAiChat {
id: string = "Chatsonic";
name: string = "Chatsonic";
icon: string = iconUrl;
url: string = "https://app.writesonic.com";
matches: string[] = ["*://app.writesonic.com/*"];
queryInputElement(): HTMLInputElement | HTMLTextAreaElement | null {
return document.querySelector('textarea[placeholder*="How can I help"],textarea');
}
querySendButtonElement(): HTMLElement | null {
return this.queryInputElement()?.parentElement?.nextElementSibling?.querySelector("button");
}
queryNewChatButtonElement(): HTMLElement | null {
const element = document.querySelector('h1.text-n-prose-xs');
if (element && element.textContent.trim() === 'Chatsonic') {
return element.closest("button");
}
return null;
}
sendKey(): SendKey[] {
return ["Enter"];
}
}
export default ChatsonicAiChat;