Spaces:
Running
Running
| (function () { | |
| const baseUrl = 'https://testingweb647-test2.hf.space'; | |
| 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); | |
| }); | |
| // console.log("Martechsol Assistant Loaded Successfully"); | |
| }) | |
| .catch(err => console.error("Failed to load Martechsol Assistant:", err)); | |
| })(); | |