|
2 | 2 | (function() {
|
3 | 3 | if (typeof window === 'undefined') return;
|
4 | 4 |
|
| 5 | + // TEMPORARY DISABLE FLAG - Set to false to disable chatbot |
| 6 | + const CHATBOT_ENABLED = false; |
| 7 | + |
| 8 | + if (!CHATBOT_ENABLED) { |
| 9 | + console.log('Chatbot is temporarily disabled'); |
| 10 | + return; |
| 11 | + } |
| 12 | + |
5 | 13 | // Set configuration
|
6 | 14 | window.difyChatbotConfig = {
|
7 | 15 | token: 'bYIppJMzMieMPDHm'
|
|
18 | 26 | style.textContent = `
|
19 | 27 | #dify-chatbot-bubble-button {
|
20 | 28 | background-color: #4B39EF !important;
|
21 |
| - bottom: 0.25rem !important; |
22 |
| - right: 0.25rem !important; |
| 29 | + bottom: 0.80rem !important; |
| 30 | + right: 0.80rem !important; |
23 | 31 | border-radius: 50% !important;
|
24 |
| - width: 50px !important; |
25 |
| - height: 50px !important; |
| 32 | + width: 45px !important; |
| 33 | + height: 45px !important; |
26 | 34 | }
|
27 | 35 |
|
28 | 36 | /* Make the main chat window background more translucent to show rounded corners */
|
|
64 | 72 |
|
65 | 73 | // Function to force positioning
|
66 | 74 | function forceChatbotPosition() {
|
67 |
| - // Handle all possible widget states |
68 |
| - const allWidgets = document.querySelectorAll('.dify-chatbot-widget, [class*="dify"], [id*="dify"]'); |
69 |
| - const allWindows = document.querySelectorAll('#dify-chatbot-bubble-window, [class*="chat"], [class*="window"]'); |
| 75 | + // Only target specific chatbot elements with very specific selectors |
| 76 | + const chatbotWidgets = document.querySelectorAll('.dify-chatbot-widget, #dify-chatbot-widget'); |
| 77 | + const chatbotWindows = document.querySelectorAll('#dify-chatbot-bubble-window, .dify-chatbot-bubble-window'); |
| 78 | + const chatbotButtons = document.querySelectorAll('#dify-chatbot-bubble-button, .dify-chatbot-bubble-button'); |
70 | 79 |
|
71 |
| - // Position all widget containers |
72 |
| - allWidgets.forEach(widget => { |
| 80 | + // Position chatbot widget containers only |
| 81 | + chatbotWidgets.forEach(widget => { |
73 | 82 | widget.style.position = 'fixed';
|
74 | 83 | widget.style.bottom = '0';
|
75 | 84 | widget.style.right = '0';
|
|
80 | 89 | widget.style.transform = 'none';
|
81 | 90 | });
|
82 | 91 |
|
83 |
| - // Position all window elements |
84 |
| - allWindows.forEach(window => { |
| 92 | + // Position chatbot window elements only |
| 93 | + chatbotWindows.forEach(window => { |
85 | 94 | window.style.position = 'fixed';
|
86 | 95 | window.style.bottom = '0';
|
87 | 96 | window.style.right = '0';
|
|
91 | 100 | window.style.transform = 'none';
|
92 | 101 | });
|
93 | 102 |
|
94 |
| - // Also handle any iframe that might be created |
95 |
| - const iframes = document.querySelectorAll('iframe[src*="dify"], iframe[src*="udify"]'); |
96 |
| - iframes.forEach(iframe => { |
| 103 | + // Handle chatbot iframes specifically |
| 104 | + const chatbotIframes = document.querySelectorAll('iframe[src*="dify"], iframe[src*="udify"]'); |
| 105 | + chatbotIframes.forEach(iframe => { |
97 | 106 | iframe.style.position = 'fixed';
|
98 | 107 | iframe.style.bottom = '0';
|
99 | 108 | iframe.style.right = '0';
|
|
103 | 112 | iframe.style.transform = 'none';
|
104 | 113 | });
|
105 | 114 |
|
106 |
| - // Special handling for expanded state - target any element that might be the expanded window |
107 |
| - const expandedElements = document.querySelectorAll('[data-state="expanded"], [class*="expanded"], [style*="position: fixed"]'); |
108 |
| - expandedElements.forEach(element => { |
| 115 | + // Only target expanded chatbot elements |
| 116 | + const expandedChatbotElements = document.querySelectorAll('.dify-chatbot-widget[data-state="expanded"], .dify-chatbot-widget .expanded'); |
| 117 | + expandedChatbotElements.forEach(element => { |
109 | 118 | element.style.position = 'fixed';
|
110 | 119 | element.style.bottom = '0';
|
111 | 120 | element.style.right = '0';
|
|
116 | 125 | element.style.zIndex = '1000';
|
117 | 126 | });
|
118 | 127 |
|
119 |
| - // Also force any element with a high z-index to stay at bottom |
120 |
| - const highZIndexElements = document.querySelectorAll('[style*="z-index: 999"], [style*="z-index: 1000"], [style*="z-index: 1001"]'); |
121 |
| - highZIndexElements.forEach(element => { |
| 128 | + // Only force positioning on chatbot elements with high z-index |
| 129 | + const highZIndexChatbotElements = document.querySelectorAll('.dify-chatbot-widget[style*="z-index: 999"], .dify-chatbot-widget[style*="z-index: 1000"], .dify-chatbot-widget[style*="z-index: 1001"]'); |
| 130 | + highZIndexChatbotElements.forEach(element => { |
122 | 131 | if (element.style.position === 'fixed') {
|
123 | 132 | element.style.bottom = '0';
|
124 | 133 | element.style.right = '0';
|
|
127 | 136 | }
|
128 | 137 | });
|
129 | 138 |
|
130 |
| - // Make background elements more translucent to show rounded corners |
131 |
| - const allElements = document.querySelectorAll('.dify-chatbot-widget *'); |
132 |
| - allElements.forEach(element => { |
| 139 | + // Make chatbot background elements more translucent to show rounded corners |
| 140 | + const chatbotElements = document.querySelectorAll('.dify-chatbot-widget *'); |
| 141 | + chatbotElements.forEach(element => { |
133 | 142 | const computedStyle = window.getComputedStyle(element);
|
134 | 143 | // Look for dark backgrounds that are likely the main content area
|
135 | 144 | if (computedStyle.backgroundColor &&
|
|
147 | 156 | });
|
148 | 157 |
|
149 | 158 | // Ensure chat button is circular
|
150 |
| - const chatButtons = document.querySelectorAll('[id*="bubble-button"], [class*="bubble-button"]'); |
151 |
| - chatButtons.forEach(button => { |
| 159 | + chatbotButtons.forEach(button => { |
152 | 160 | button.style.borderRadius = '50%';
|
153 | 161 | button.style.width = '60px';
|
154 | 162 | button.style.height = '60px';
|
|
0 commit comments