forked from langgenius/chatbot-chrome-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
28 lines (22 loc) · 769 Bytes
/
options.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
document.getElementById('save-button').addEventListener('click', function (e) {
e.preventDefault();
const chatbotUrl = document.getElementById('chatbot-url').value;
const errorTip = document.getElementById('error-tip');
if (chatbotUrl.trim() === "") {
errorTip.textContent = "Dify ChatBot URL cannot be empty.";
} else {
errorTip.textContent = "";
chrome.storage.sync.set({
'chatbotUrl': chatbotUrl,
}, function () {
alert('Save Success!');
});
}
});
// Load parameters from chrome.storage when the page loads
chrome.storage.sync.get(['chatbotUrl'], function (result) {
const chatbotUrlInput = document.getElementById('chatbot-url');
if (result.chatbotUrl) {
chatbotUrlInput.value = result.chatbotUrl;
}
});