|
64 | 64 |
|
65 | 65 | // Function to force positioning
|
66 | 66 | 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"]'); |
| 67 | + // Only target specific chatbot elements with very specific selectors |
| 68 | + const chatbotWidgets = document.querySelectorAll('.dify-chatbot-widget, #dify-chatbot-widget'); |
| 69 | + const chatbotWindows = document.querySelectorAll('#dify-chatbot-bubble-window, .dify-chatbot-bubble-window'); |
| 70 | + const chatbotButtons = document.querySelectorAll('#dify-chatbot-bubble-button, .dify-chatbot-bubble-button'); |
70 | 71 |
|
71 |
| - // Position all widget containers |
72 |
| - allWidgets.forEach(widget => { |
| 72 | + // Position chatbot widget containers only |
| 73 | + chatbotWidgets.forEach(widget => { |
73 | 74 | widget.style.position = 'fixed';
|
74 | 75 | widget.style.bottom = '0';
|
75 | 76 | widget.style.right = '0';
|
|
80 | 81 | widget.style.transform = 'none';
|
81 | 82 | });
|
82 | 83 |
|
83 |
| - // Position all window elements |
84 |
| - allWindows.forEach(window => { |
| 84 | + // Position chatbot window elements only |
| 85 | + chatbotWindows.forEach(window => { |
85 | 86 | window.style.position = 'fixed';
|
86 | 87 | window.style.bottom = '0';
|
87 | 88 | window.style.right = '0';
|
|
91 | 92 | window.style.transform = 'none';
|
92 | 93 | });
|
93 | 94 |
|
94 |
| - // Also handle any iframe that might be created |
95 |
| - const iframes = document.querySelectorAll('iframe[src*="dify"], iframe[src*="udify"]'); |
96 |
| - iframes.forEach(iframe => { |
| 95 | + // Handle chatbot iframes specifically |
| 96 | + const chatbotIframes = document.querySelectorAll('iframe[src*="dify"], iframe[src*="udify"]'); |
| 97 | + chatbotIframes.forEach(iframe => { |
97 | 98 | iframe.style.position = 'fixed';
|
98 | 99 | iframe.style.bottom = '0';
|
99 | 100 | iframe.style.right = '0';
|
|
103 | 104 | iframe.style.transform = 'none';
|
104 | 105 | });
|
105 | 106 |
|
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 => { |
| 107 | + // Only target expanded chatbot elements |
| 108 | + const expandedChatbotElements = document.querySelectorAll('.dify-chatbot-widget[data-state="expanded"], .dify-chatbot-widget .expanded'); |
| 109 | + expandedChatbotElements.forEach(element => { |
109 | 110 | element.style.position = 'fixed';
|
110 | 111 | element.style.bottom = '0';
|
111 | 112 | element.style.right = '0';
|
|
116 | 117 | element.style.zIndex = '1000';
|
117 | 118 | });
|
118 | 119 |
|
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 => { |
| 120 | + // Only force positioning on chatbot elements with high z-index |
| 121 | + 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"]'); |
| 122 | + highZIndexChatbotElements.forEach(element => { |
122 | 123 | if (element.style.position === 'fixed') {
|
123 | 124 | element.style.bottom = '0';
|
124 | 125 | element.style.right = '0';
|
|
127 | 128 | }
|
128 | 129 | });
|
129 | 130 |
|
130 |
| - // Make background elements more translucent to show rounded corners |
131 |
| - const allElements = document.querySelectorAll('.dify-chatbot-widget *'); |
132 |
| - allElements.forEach(element => { |
| 131 | + // Make chatbot background elements more translucent to show rounded corners |
| 132 | + const chatbotElements = document.querySelectorAll('.dify-chatbot-widget *'); |
| 133 | + chatbotElements.forEach(element => { |
133 | 134 | const computedStyle = window.getComputedStyle(element);
|
134 | 135 | // Look for dark backgrounds that are likely the main content area
|
135 | 136 | if (computedStyle.backgroundColor &&
|
|
147 | 148 | });
|
148 | 149 |
|
149 | 150 | // Ensure chat button is circular
|
150 |
| - const chatButtons = document.querySelectorAll('[id*="bubble-button"], [class*="bubble-button"]'); |
151 |
| - chatButtons.forEach(button => { |
| 151 | + chatbotButtons.forEach(button => { |
152 | 152 | button.style.borderRadius = '50%';
|
153 | 153 | button.style.width = '60px';
|
154 | 154 | button.style.height = '60px';
|
|
0 commit comments