Skip to content

Commit 92b6d05

Browse files
committed
Add support for Meta AI chatbot including integration in content scripts and UI components
1 parent 4fbca7d commit 92b6d05

8 files changed

Lines changed: 105 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from './github-copilot'
99
export * from './hugging-chat'
1010
export * from './arena'
1111
export * from './mistral'
12+
export * from './meta'
1213
export * from './open-webui'
1314
export * from './openrouter'
1415
export * from './qwen'
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { Chatbot } from '../types/chatbot'
2+
import {
3+
add_apply_response_button,
4+
observe_for_responses
5+
} from '../utils/add-apply-response-button'
6+
import { report_initialization_error } from '../utils/report-initialization-error'
7+
8+
export const meta: Chatbot = {
9+
wait_until_ready: async () => {
10+
await new Promise((resolve) => {
11+
const check_for_element = () => {
12+
if (
13+
document.querySelector(
14+
'div[contenteditable="true"][data-testid="composer-input"]'
15+
)
16+
) {
17+
resolve(null)
18+
} else {
19+
setTimeout(check_for_element, 100)
20+
}
21+
}
22+
check_for_element()
23+
})
24+
},
25+
enter_message: async (params) => {
26+
const input_element = document.querySelector(
27+
'div[contenteditable="true"][data-testid="composer-input"]'
28+
) as HTMLElement
29+
30+
if (!input_element) {
31+
report_initialization_error({
32+
function_name: 'meta.enter_message',
33+
log_message: 'Message input element not found'
34+
})
35+
return
36+
}
37+
38+
input_element.dispatchEvent(
39+
new InputEvent('input', {
40+
bubbles: true,
41+
cancelable: true,
42+
inputType: 'insertText',
43+
data: params.message
44+
})
45+
)
46+
},
47+
setup_observer: (params) => {
48+
const add_buttons = (footer: Element) => {
49+
add_apply_response_button({
50+
client_id: params.client_id,
51+
raw_instructions: params.raw_instructions,
52+
edit_format: params.edit_format,
53+
footer,
54+
get_chat_turn: (f) =>
55+
f.closest('div[data-testid="assistant-message"]') as HTMLElement,
56+
perform_copy: (f) => {
57+
const copy_button = f.querySelector(
58+
'div:nth-child(3) > button'
59+
) as HTMLElement
60+
if (!copy_button) {
61+
report_initialization_error({
62+
function_name: 'meta.perform_copy',
63+
log_message: 'Copy button not found'
64+
})
65+
return
66+
}
67+
copy_button.click()
68+
},
69+
insert_button: (f, b) =>
70+
f.insertBefore(b, f.children[f.children.length])
71+
})
72+
}
73+
74+
observe_for_responses({
75+
chatbot_name: 'Meta',
76+
is_generating: () =>
77+
!!document.querySelector('button[data-testid="composer-stop-button"]'),
78+
footer_selector:
79+
'div[data-testid="assistant-message"] > div + div > div > div:last-child > div > div',
80+
add_buttons: params.inject_button ? add_buttons : undefined
81+
})
82+
}
83+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
qwen,
1717
yuanbao,
1818
doubao,
19+
meta,
1920
kimi,
2021
arena,
2122
together,
@@ -77,6 +78,9 @@ const is_doubao = current_url.startsWith(doubao_url)
7778
const kimi_url = 'https://www.kimi.com/'
7879
const is_kimi = current_url.startsWith(kimi_url)
7980

81+
const meta_url = 'https://www.meta.ai/'
82+
const is_meta = current_url.startsWith(meta_url)
83+
8084
const together_url = 'https://chat.together.ai/'
8185
const is_together = current_url.startsWith(together_url)
8286

@@ -119,6 +123,8 @@ if (is_ai_studio) {
119123
chatbot = yuanbao
120124
} else if (is_doubao) {
121125
chatbot = doubao
126+
} else if (is_meta) {
127+
chatbot = meta
122128
} else if (is_kimi) {
123129
chatbot = kimi
124130
} else if (is_together) {

‎apps/browser/src/manifest.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"https://huggingface.co/chat/",
3737
"https://arena.ai/*",
3838
"https://www.kimi.com/",
39+
"https://www.meta.ai/",
3940
"https://chat.mistral.ai/*",
4041
"http://openwebui/",
4142
"https://openrouter.ai/chat*",

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ export const CHATBOTS = {
148148
Kimi: {
149149
url: 'https://www.kimi.com/'
150150
} as Chatbot,
151+
'Meta AI': {
152+
url: 'https://www.meta.ai/'
153+
} as Chatbot,
151154
Mistral: {
152155
url: 'https://chat.mistral.ai/chat',
153156
supports_url_override: true,
Lines changed: 5 additions & 0 deletions
Loading

‎packages/ui/src/components/editor/common/Icon/Icon.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import Reddit from '../../../../assets/icons/reddit.svg'
2727
import X from '../../../../assets/icons/x.svg'
2828
import Yuanbao from '../../../../assets/icons/yuanbao.svg'
2929
import ZAI from '../../../../assets/icons/z-ai.svg'
30+
import Meta from '../../../../assets/icons/meta.svg'
3031

3132
export namespace Icon {
3233
export type Variant =
@@ -57,6 +58,7 @@ export namespace Icon {
5758
| 'TOGETHER'
5859
| 'REDDIT'
5960
| 'X'
61+
| 'META'
6062
| 'YUANBAO'
6163
| 'Z_AI'
6264

@@ -150,6 +152,9 @@ export const Icon: React.FC<Icon.Props> = ({ variant }) => {
150152
case 'X':
151153
icon = <X />
152154
break
155+
case 'META':
156+
icon = <Meta />
157+
break
153158
case 'YUANBAO':
154159
icon = <Yuanbao />
155160
break

‎packages/ui/src/components/editor/panel/Presets/Presets.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const chatbot_to_icon: Record<keyof typeof CHATBOTS, Icon.Variant> = {
2121
HuggingChat: 'HUGGING_CHAT',
2222
Kimi: 'KIMI',
2323
Mistral: 'MISTRAL',
24+
"Meta AI": 'META',
2425
Arena: 'ARENA',
2526
'Open WebUI': 'OPEN_WEBUI',
2627
OpenRouter: 'OPENROUTER',

0 commit comments

Comments
 (0)