Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
2.7 kB
2
Indexable
Never
"use strict";
!(function (n) {
    var e,
        a = new (function () {
            (this.loadScript = function (t, e) {
                var o = document.createElement("script"),
                    t = ((o.src = t), (o.defer = !0), "function" == typeof e && (o.onload = e), (o.onerror = function (t) {}), document.getElementsByTagName("script")[0]);
                t.parentNode.insertBefore(o, t);
            }),
                (this.doGet = function (t, e) {
                    var o = new XMLHttpRequest();
                    o.open("GET", t, !0),
                        (o.onreadystatechange = function () {
                            if (4 === o.readyState || "complete" === o.readyState)
                                if (200 === o.status) {
                                    if ("function" == typeof e)
                                        try {
                                            var t = JSON.parse(o.responseText);
                                            e(t);
                                        } catch (t) {
                                            e({}, { status: o.status, message: "Wrong response" });
                                        }
                                } else "function" == typeof e && e({}, { status: o.status, message: "Chat not available" });
                        }),
                        o.send();
                });
        })(),
        i = 0,
        s = "/smartchat/open/chat-meta?app=sales";
    !(function t() {
        var o;
        document.body
            ? ((e = document.location.pathname),
              (o = function (t, e) {
                  if ("object" != typeof e) {
                      for (var o in ((n.openChat = n.openChat || {}), t)) "sys" !== o && (n.openChat[o] = t[o]);
                      (window.openChat.chatState && window.openChat.chatState.conversationId) || sessionStorage.removeItem("org.cometd.reload"),
                          window.Promise
                              ? a.loadScript(t.chatScript)
                              : a.loadScript("/smartchat/js/polyfill.js", function () {
                                    a.loadScript(t.chatScript);
                                });
                  }
              }),
              a.doGet("/smartchat/open/eligibility?intent=SALESCHAT&page=" + e, function (t, e) {
                  (window.openSalesChat = function () {
                      a.doGet(s, o);
                  }),
                      e || (t.eligible && a.doGet(s, o));
              }))
            : ++i < 10 && setTimeout(t, 200);
    })();
})(window);