|
|
| (function () { |
| const baseUrl = 'https://joedown11-chatbot21.hf.space'; |
|
|
| function init() { |
| |
| if (document.getElementById('martech-chat-widget-container')) return; |
|
|
| const container = document.createElement('div'); |
| container.id = 'martech-chat-widget-container'; |
| document.body.appendChild(container); |
|
|
| fetch(`${baseUrl}/widget?v=${Date.now()}`) |
| .then(response => response.text()) |
| .then(html => { |
| const parser = new DOMParser(); |
| const doc = parser.parseFromString(html, 'text/html'); |
|
|
| doc.querySelectorAll('style').forEach(st => { |
| document.head.appendChild(st.cloneNode(true)); |
| }); |
|
|
| const wrapper = doc.querySelector('#martech-chat-wrapper'); |
| if (wrapper) { |
| container.innerHTML = wrapper.outerHTML; |
| } else { |
| container.innerHTML = doc.body.innerHTML; |
| } |
|
|
| doc.querySelectorAll('script').forEach(oldScript => { |
| const newScript = document.createElement('script'); |
| Array.from(oldScript.attributes).forEach(attr => { |
| newScript.setAttribute(attr.name, attr.value); |
| }); |
| newScript.innerHTML = oldScript.innerHTML; |
| document.body.appendChild(newScript); |
| }); |
| }) |
| .catch(err => console.error("Failed to load Martechsol Assistant:", err)); |
| } |
|
|
| if (document.readyState === 'loading') { |
| document.addEventListener('DOMContentLoaded', init); |
| } else { |
| init(); |
| } |
| })(); |
|
|