javascript – Custom CSS AND JS Plugin not working with js code

I have a JS script which loads chatbot User interface. the scripts works everywhere on the internet except in WordPress. I have tried several other plugins but the issue is same…

<script>
    var str = window.location.href;

    var params={};

    window.location.search

    .replace(/(?&)+((^=&)+)=((^&)*)/gi, function(str,key,value) {

      params(key) = value;

    });

    window.CCHAT_CONFIG = {

      EMBED_TOKEN: typeof(params.token) !== "undefined" && params.token !== null ? params.token : "f0a3dc1f865a4b349a11b78282c2ab0f",

      HOST_URL: "http://18.116.204.111/"

    };

    (function() {

      window.business_name = 'Welcome to DentalChat!';

      window.business_ID = '153';

      window.widgetTimeout = 1;
      window.NAME = "DentalChat"


      var scriptTag = document.createElement('script');

      scriptTag.type = 'text/javascript';

      scriptTag.async = true;

      scriptTag.src = window.CCHAT_CONFIG.HOST_URL + 'loader.js?t='+Math.random();

      var s = document.getElementsByTagName('script')(0);

      s.parentNode.insertBefore(scriptTag, s);

    })();
  </script>