forked from legendjw/ai-chat-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-ai-chat.ts
40 lines (33 loc) · 1.26 KB
/
custom-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
35
36
37
38
39
40
import { type SendKey } from '@/ai/abstract-ai-chat';
import InputElementAiChat from '@/ai/input-element-ai-chat';
class CustomAiChat extends InputElementAiChat {
inputSelector: string;
sendButtonSelector: string;
sendKeys: SendKey[] | null;
constructor(id: string, name: string, icon: string, url: string, matches: string[], inputSelector: string, sendButtonSelector: string, sendKey: SendKey | null) {
super();
this.id = id;
this.name = name;
this.icon = icon;
this.url = url;
this.matches = matches;
this.inputSelector = inputSelector;
this.sendButtonSelector = sendButtonSelector;
this.sendKeys = sendKey ? [ sendKey ] : null;
}
queryInputElement(): HTMLInputElement | HTMLTextAreaElement | null {
let input = document.querySelector(this.inputSelector);
return input as HTMLInputElement | HTMLTextAreaElement;
}
querySendButtonElement(): HTMLElement | null {
let sendButton = document.querySelector(this.sendButtonSelector);
return sendButton as HTMLElement;
}
queryNewChatButtonElement(): HTMLElement | null {
return null;
}
sendKey(): SendKey[] | null {
return this.sendKeys;
}
}
export default CustomAiChat;