Streaming live at 10am (PST)

Custom Code Script Not Executing Correctly

So, I am trying to add a new script to the custom code in project settings. When I add the script I should see a small widget that floats on the bottom right of the screen. When clicked it brings up a live chat box (kayako).

The current iteration works… but their beta version does not. I have tried to add it after stripping away all the current custom code on the site… still does not work.

I have added it, via wordpress, to the blog that is integrated with the site here, and it loads correctly.

Here is the code snippet;

<script type="text/javascript">!function(a,b){function c(){var b=a.createElement("iframe");return"kayako-messenger-frame","none","100%","100%",b}function d(){var c=a.createElement("script");return c.async=!0,c.type="text/javascript",c.src=b._settings.messengerUrl,c}function e(){var b=a.createElement("div");return"kayako-messenger","fixed",,,,,b}window.kayako=b,b.readyQueue=[],b.ready=function(a){b.readyQueue.push(a)},b._settings={messengerUrl:"",apiUrl:"",socketInstance:"",teamName:"FXPIG",homeTitle:"Hi... Need some Help",homeSubtitle:"Welcome to FXPIG. Let's chat - start a new conversation below.",widgets:{presence:{enabled:true},twitter:{enabled:true,twitterHandle:"134279494"},articles:{enabled:false,sectionId:undefined}},styles:{primaryColor:"#9557c1",homeBackground:"#9557c1",homePattern:"",homeTextColor:"#FFFFFF"}};var f=a.body.getElementsByTagName("script")[0],g=c(),h=e();f.parentNode.insertBefore(h,f),g.onload=function(a){||(!0,g.contentWindow.document.body.appendChild(d()))},h.appendChild(g,f),,g.contentWindow.document.write("<!DOCTYPE html>"),g.contentWindow.document.write("<html>"),g.contentWindow.document.write("<head></head>"),g.contentWindow.document.write("<body></body>"),g.contentWindow.document.write("</html>"),g.contentWindow.document.close()}(document,window.kayako||{});</script>

I am trying to add this to Currently, the site displays the non-beta widget, using this code;

<script type="text/javascript">!function(a,e){window.kayako=e,e.readyQueue=[],e._config={apiUrl:"",cdnUrl:"",defaultName:"FXPIG",themeColor:"#9557c1",themeAvatar:"",welcomeMessage: "How can we help? We’d love to know what brought you to FXPIG"},e.ready=function(a){e.readyQueue.push(a)};var t=a.createElement("div");"Kykw__app",t["class"]="k-widget",a.body.appendChild(t);var o=a.createElement("script");o.type="text/javascript",o.async=!0;var i="";o.src=i;var s=a.getElementsByTagName("script");s=s[s.length-1],s.parentNode.insertBefore(o,s)}(document,window.kayako||[]);</script>

And you can see what the new code does here:

(To load the site you need to inspect and then remove the display:block)

There has to be some conflict within webflow that is stopping this script from running, but I have no idea what it might be.

Any ideas? REALLY appreciate the help

New code site doesn’t load for me

You need to right click, inspect and uncheck the display:hidden element

Not sure why this is, but for some reason the webflow published version never seems to do this on its own

The script is blocked in Google Chrome due to terrible coding practices. Please contact the author of the script.

Will do… But that has nothing to do with the problem at hand…

The specified code causes errors in webflow only, on our actual website at there are no such errors and the underlying element, the ticker at the top of the page, loads and works as expected.

Wait… that code is ONLY on the index page, and when checking other pages via the webflow sub domain the kayako widget does show up as intended… so I guess you are correct samliew :slight_smile:

Thank you.

Any idea on how this specific snippet could be cleaned up?

Yeah, I copied the new code onto a test page and it worked

Possibly a script conflict now due to the document.write, which I mentioned is terrible practice.

Yeah actually seems this is garbage code anyway, it is not in use. I believe we may have used it as a hack to test the ticker initially… and someone forgot to erase it…

Anyway, problem solved.

Thanks again.

Hmm… so I removed the garbage code and via the webflow sub domain everything worked… but after downloading the code and uploading to our server the display:block will not automatically disengage anymore and the widget does not appear…

Could there be some conflict with this

        display: block;

Down to one issue, Syntax Error…

“Uncaught Syntax Error: missing ) after argument list”

Can someone help to spot the issue in the below code snippet:

<script type="text/javascript">!function(a,b){function c(){var b=a.createElement("iframe");return"kayako-messenger-frame","none","100%","100%",b}function d(){var c=a.createElement("script");return c.async=!0,c.type="text/javascript",c.src=b._settings.messengerUrl,c.crossOrigin="anonymous",c}function e(){var b=a.createElement("div");return"kayako-messenger","fixed",,,,,b}window.kayako=b,b.readyQueue=[],b.ready=function(a){b.readyQueue.push(a)},b._settings={apiUrl:"",teamName:"FXPIG",homeTitle:"Hi... Need some Help?",homeSubtitle:"Welcome to FXPIG. Let's chat - start a new conversation below.",messengerUrl:"",realtimeUrl:"wss://",widgets:{presence:{enabled:true},twitter:{enabled:false,twitterHandle:"134279494"},articles:{enabled:false,sectionId:undefined}},styles:{primaryColor:"#9557c1",homeBackground:"-192deg, #9557c1 37%, #532574 100%",homePattern:"",homeTextColor:"#FFFFFF"}};var f=a.body.getElementsByTagName("script")[0],g=c(),h=e();f.parentNode.insertBefore(h,f),h.appendChild(g,f),,g.contentWindow.document.write("<!DOCTYPE html>"),g.contentWindow.document.write("<html>"),g.contentWindow.document.write("<head></head>"),g.contentWindow.document.write("<body></body>"),g.contentWindow.document.write("</html>"),g.contentWindow.document.body.appendChild(d()),g.contentWindow.document.close()}(document,window.kayako||{});</script>

Still digging here… and i have to believe this syntax error is not the issue… as I have checked the code a million times. I can get this to work in DW, in WP, etc… so maybe its something in the CSS? Its the only thing I can think of…

Currently, the old kayako code is live, with no errors… substituting the code from previous posts causes the loader to remain in place and the kayako chat widget never appears