-
Notifications
You must be signed in to change notification settings - Fork 0
/
preload.js
37 lines (32 loc) · 1.31 KB
/
preload.js
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
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('api', {
// No need for index.html to call this explicitly, we'll handle it here
});
window.addEventListener('DOMContentLoaded', () => {
document.addEventListener('click', (event) => {
const element = event.target;
// Check if the clicked element is a button or a link that should select a bot
if (element.tagName === 'BUTTON' || element.tagName === 'A') {
const botName = getBotNameFromElement(element);
if (botName) {
ipcRenderer.send('select-bot', botName); // Send bot selection to main process
}
}
});
// Map button or link text to bot names
function getBotNameFromElement(element) {
const text = element.textContent.trim().toLowerCase();
if (text.includes('chatgpt')) {
return 'ChatGPT';
} else if (text.includes('google gemini')) {
return 'Google Gemini';
} else if (text.includes('claude')) {
return 'Claude';
} else if (text.includes('you.com')) {
return 'You.com';
} else if (text.includes('blackbox.ai')) {
return 'Blackbox.ai';
}
return null;
}
});