Created
January 13, 2024 22:04
-
-
Save honzasterba/3f36758a8071ce7f636c4e6b5895a6fb to your computer and use it in GitHub Desktop.
ChatWoot with TurboDrive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style id="woot-0" data-turbo-permanent="true"></style> | |
<div id="woot-1" class="woot-widget-holder woot--hide woot-elements--right" data-turbo-permanent="true"></div> | |
<div id="woot-2" class="woot--bubble-holder" data-turbo-permanent="true"></div> | |
<script> | |
//# sourceURL=chatwoot_loader.js | |
window.addEventListener('chatwoot:ready', function() { | |
if (!window.wootLoaded) { | |
window.wootLoaded = true; | |
function markWootElement(el, i) { | |
el.setAttribute('data-turbo-permanent', "true") | |
if (el.id === '') { | |
el.id = 'woot-' + i | |
} | |
} | |
for (let el of document.querySelectorAll("style").values()) { | |
if (el.innerText.includes("woot")) { | |
markWootElement(el, 0) | |
} | |
} | |
markWootElement(document.querySelector('.woot-widget-holder'), 1); | |
markWootElement(document.querySelector('.woot--bubble-holder'), 2); | |
} | |
}); | |
if (!window.wootLoaded) { | |
document.getElementById("woot-0").remove(); | |
document.getElementById("woot-1").remove(); | |
document.getElementById("woot-2").remove(); | |
(function(d, t) { | |
var BASE_URL = 'https://chatwoot.example.com' | |
var g = d.createElement(t), s = d.getElementsByTagName(t)[0] | |
g.src = BASE_URL + '/packs/js/sdk.js' | |
g.defer = true | |
g.async = true | |
s.parentNode.insertBefore(g, s) | |
g.onload = function() { | |
window.chatwootSDK.run({ | |
websiteToken: 'XXX', | |
baseUrl: BASE_URL | |
}) | |
} | |
})(document, 'script') | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment