-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai.js
More file actions
59 lines (59 loc) · 1.92 KB
/
Copy pathai.js
File metadata and controls
59 lines (59 loc) · 1.92 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// AI chat logic
export function setupAIChat() {
const aiForm = document.getElementById('ai-form');
aiForm.addEventListener('submit', function(e) {
e.preventDefault();
const query = document.getElementById('ai-input').value.trim();
const platform = document.querySelector('.custom-dropdown[data-name="ai-platform"] input[type="hidden"]').value;
if (!query) return;
navigator.clipboard.writeText(query).then(() => {
let url = '';
switch (platform) {
case 'chatgpt':
url = 'https://chat.openai.com/';
break;
case 'gemini':
url = 'https://gemini.google.com/app';
break;
case 'claude':
url = 'https://claude.ai/';
break;
default:
url = 'https://chat.openai.com/';
}
window.open(url, '_blank');
const notification = document.createElement('div');
notification.textContent = 'Query copied to clipboard!';
notification.style.position = 'fixed';
notification.style.top = '20px';
notification.style.right = '20px';
notification.style.background = '#4CAF50';
notification.style.color = 'white';
notification.style.padding = '10px 20px';
notification.style.borderRadius = '5px';
notification.style.zIndex = '10000';
notification.style.fontSize = '14px';
document.body.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 2000);
}).catch(() => {
let url = '';
switch (platform) {
case 'chatgpt':
url = 'https://chat.openai.com/';
break;
case 'gemini':
url = 'https://gemini.google.com/app';
break;
case 'claude':
url = 'https://claude.ai/';
break;
default:
url = 'https://chat.openai.com/';
}
window.open(url, '_blank');
});
document.getElementById('ai-input').value = '';
});
}