options.js 769 B

12345678910111213141516171819202122232425262728
  1. document.getElementById('save-button').addEventListener('click', function (e) {
  2. e.preventDefault();
  3. const chatbotUrl = document.getElementById('chatbot-url').value;
  4. const errorTip = document.getElementById('error-tip');
  5. if (chatbotUrl.trim() === "") {
  6. errorTip.textContent = "Dify ChatBot URL cannot be empty.";
  7. } else {
  8. errorTip.textContent = "";
  9. chrome.storage.sync.set({
  10. 'chatbotUrl': chatbotUrl,
  11. }, function () {
  12. alert('Save Success!');
  13. });
  14. }
  15. });
  16. // Load parameters from chrome.storage when the page loads
  17. chrome.storage.sync.get(['chatbotUrl'], function (result) {
  18. const chatbotUrlInput = document.getElementById('chatbot-url');
  19. if (result.chatbotUrl) {
  20. chatbotUrlInput.value = result.chatbotUrl;
  21. }
  22. });