Created
January 14, 2021 03:35
-
-
Save danielvlopes/8ec4b30bd5fbaa9322ef3ac8c1b03768 to your computer and use it in GitHub Desktop.
Adding support for Turbo to Intercom
This file contains hidden or 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
| !(function (e) { | |
| var t = {}; | |
| function n(o) { | |
| if (t[o]) return t[o].exports; | |
| var r = (t[o] = { i: o, l: !1, exports: {} }); | |
| return e[o].call(r.exports, r, r.exports, n), (r.l = !0), r.exports; | |
| } | |
| (n.m = e), | |
| (n.c = t), | |
| (n.d = function (e, t, o) { | |
| n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: o }); | |
| }), | |
| (n.r = function (e) { | |
| "undefined" != typeof Symbol && | |
| Symbol.toStringTag && | |
| Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), | |
| Object.defineProperty(e, "__esModule", { value: !0 }); | |
| }), | |
| (n.t = function (e, t) { | |
| if ((1 & t && (e = n(e)), 8 & t)) return e; | |
| if (4 & t && "object" == typeof e && e && e.__esModule) return e; | |
| var o = Object.create(null); | |
| if ( | |
| (n.r(o), | |
| Object.defineProperty(o, "default", { enumerable: !0, value: e }), | |
| 2 & t && "string" != typeof e) | |
| ) | |
| for (var r in e) | |
| n.d( | |
| o, | |
| r, | |
| function (t) { | |
| return e[t]; | |
| }.bind(null, r) | |
| ); | |
| return o; | |
| }), | |
| (n.n = function (e) { | |
| var t = | |
| e && e.__esModule | |
| ? function () { | |
| return e.default; | |
| } | |
| : function () { | |
| return e; | |
| }; | |
| return n.d(t, "a", t), t; | |
| }), | |
| (n.o = function (e, t) { | |
| return Object.prototype.hasOwnProperty.call(e, t); | |
| }), | |
| (n.p = "https://js.intercomcdn.com/"), | |
| n((n.s = 935)); | |
| })({ | |
| 13: function (e, t, n) { | |
| "use strict"; | |
| n.d(t, "d", function () { | |
| return c; | |
| }), | |
| n.d(t, "c", function () { | |
| return u; | |
| }), | |
| n.d(t, "g", function () { | |
| return s; | |
| }), | |
| n.d(t, "h", function () { | |
| return d; | |
| }), | |
| n.d(t, "e", function () { | |
| return l; | |
| }), | |
| n.d(t, "b", function () { | |
| return m; | |
| }), | |
| n.d(t, "f", function () { | |
| return p; | |
| }), | |
| n.d(t, "j", function () { | |
| return f; | |
| }), | |
| n.d(t, "i", function () { | |
| return w; | |
| }); | |
| var o = n(8), | |
| r = /iphone|ipad|ipod|android|blackberry|opera mini|iemobile/i, | |
| i = [ | |
| ".intercom-lightweight-app-launcher", | |
| ".intercom-launcher-frame", | |
| "#intercom-container", | |
| ".intercom-messenger", | |
| ".intercom-notifications", | |
| ]; | |
| function a(e) { | |
| try { | |
| if (!(e in window)) return !1; | |
| var t = window[e]; | |
| return ( | |
| null !== t && | |
| (t.setItem("intercom-test", "0"), t.removeItem("intercom-test"), !0) | |
| ); | |
| } catch (e) { | |
| return !1; | |
| } | |
| } | |
| function c() { | |
| return a("localStorage"); | |
| } | |
| function u() { | |
| return !!( | |
| window.FileReader && | |
| window.File && | |
| window.FileList && | |
| window.FormData | |
| ); | |
| } | |
| function s() { | |
| var e = m().userAgent; | |
| return !!e && null !== e.match(r) && void 0 !== window.parent; | |
| } | |
| function d() { | |
| var e = m().vendor || "", | |
| t = m().userAgent || ""; | |
| return 0 === e.indexOf("Apple") && /\sSafari\//.test(t); | |
| } | |
| function l(e) { | |
| void 0 === e && (e = window); | |
| var t = m(), | |
| n = "Google Inc." === t.vendor && !e.chrome; | |
| return "" === t.languages && (t.webdriver || n); | |
| } | |
| function m() { | |
| return navigator || {}; | |
| } | |
| function p(e) { | |
| return ( | |
| void 0 === e && (e = m().userAgent), | |
| /iPad|iPhone|iPod/.test(e) && !window.MSStream | |
| ); | |
| } | |
| function f() { | |
| return ( | |
| !Object(o.a)() && | |
| i.some(function (e) { | |
| var t = window.parent.document.querySelector(e); | |
| if (t) { | |
| var n = window.getComputedStyle(t); | |
| return null === n || "none" === n.display; | |
| } | |
| }) | |
| ); | |
| } | |
| var w = function () { | |
| return "ontouchstart" in window || navigator.maxTouchPoints > 0; | |
| }; | |
| t.a = { | |
| hasXhr2Support: function () { | |
| return ( | |
| "XMLHttpRequest" in window && | |
| "withCredentials" in new XMLHttpRequest() | |
| ); | |
| }, | |
| hasLocalStorageSupport: c, | |
| hasSessionStorageSupport: function () { | |
| return a("sessionStorage"); | |
| }, | |
| hasFileSupport: u, | |
| hasAudioSupport: function () { | |
| var e = document.createElement("audio"); | |
| return ( | |
| !!e.canPlayType && !!e.canPlayType("audio/mpeg;").replace(/^no$/, "") | |
| ); | |
| }, | |
| hasVisibilitySupport: function () { | |
| return ( | |
| void 0 !== document.hidden || | |
| void 0 !== document.mozHidden || | |
| void 0 !== document.msHidden || | |
| void 0 !== document.webkitHidden | |
| ); | |
| }, | |
| messengerIsVisible: function () { | |
| return ( | |
| !!Object(o.a)() || | |
| i.some(function (e) { | |
| var t = window.parent.document.querySelector(e); | |
| if (t) { | |
| var n = t.getBoundingClientRect(); | |
| return n && n.width > 0 && n.height > 0; | |
| } | |
| }) | |
| ); | |
| }, | |
| messengerHasDisplayNoneSet: f, | |
| isMobileBrowser: s, | |
| isIOSFirefox: function () { | |
| return !!m().userAgent.match("FxiOS"); | |
| }, | |
| isFirefox: function () { | |
| return !!m().userAgent.match("Firefox"); | |
| }, | |
| isSafari: d, | |
| isElectron: function () { | |
| var e = m().userAgent || "", | |
| t = window.parent || {}, | |
| n = t.process && t.versions && t.versions.electron; | |
| return /\sElectron\//.test(e) || n; | |
| }, | |
| isIE: function () { | |
| var e = m().userAgent || ""; | |
| return e.indexOf("MSIE") > 0 || e.indexOf("Trident") > 0; | |
| }, | |
| isEdge: function () { | |
| return (m().userAgent || "").indexOf("Edge") > 0; | |
| }, | |
| isNativeMobile: function () { | |
| return m().isNativeMobile; | |
| }, | |
| isChrome: function () { | |
| var e = window.chrome, | |
| t = m().vendor, | |
| n = m().userAgent.indexOf("OPR") > -1, | |
| o = m().userAgent.indexOf("Edge") > -1; | |
| return ( | |
| !!m().userAgent.match("CriOS") || | |
| (null != e && "Google Inc." === t && !1 === n && !1 === o) | |
| ); | |
| }, | |
| isIOS: p, | |
| isAndroid: function (e) { | |
| return ( | |
| void 0 === e && (e = m().userAgent), | |
| e && e.toLowerCase().indexOf("android") > -1 | |
| ); | |
| }, | |
| }; | |
| }, | |
| 247: function (e, t, n) { | |
| "use strict"; | |
| n.d(t, "b", function () { | |
| return r; | |
| }), | |
| n.d(t, "a", function () { | |
| return i; | |
| }); | |
| var o = n(13), | |
| r = function (e, t, n) { | |
| void 0 === n && (n = "en"), | |
| o.a.isFirefox() && | |
| (e.contentDocument.open(), e.contentDocument.close()), | |
| (function (e, t, n) { | |
| void 0 === n && (n = "en"), | |
| (e.documentElement.innerHTML = t), | |
| e.documentElement.setAttribute("lang", n); | |
| })(e.contentDocument, t, n); | |
| }, | |
| i = function (e) { | |
| var t = document.createElement("script"); | |
| return ( | |
| (t.type = "text/javascript"), (t.charset = "utf-8"), (t.src = e), t | |
| ); | |
| }; | |
| }, | |
| 253: function (e, t) { | |
| e.exports = { | |
| source_map: "hidden-source-map", | |
| api_base: "https://api-iam.intercom.io", | |
| public_path: "https://js.intercomcdn.com/", | |
| sheets_proxy_path: "https://intercom-sheets.com/sheets_proxy", | |
| sentry_proxy_path: "https://www.intercom-reporting.com/sentry/index.html", | |
| install_mode_base: "https://app.intercom.com", | |
| sentry_dsn: | |
| "https://[email protected]/24287", | |
| intersection_js: "https://js.intercomcdn.com/intersection/assets/app.js", | |
| intersection_styles: | |
| "https://js.intercomcdn.com/intersection/assets/styles.js", | |
| article_search_messenger_app_id: 27, | |
| mode: "production", | |
| }; | |
| }, | |
| 8: function (e, t, n) { | |
| "use strict"; | |
| n.d(t, "a", function () { | |
| return o; | |
| }); | |
| var o = function () { | |
| return window.INTERCOM_PRIVILEGE_SEPARATION; | |
| }; | |
| }, | |
| 935: function (e, t, n) { | |
| e.exports = n(957); | |
| }, | |
| 957: function (e, t, n) { | |
| "use strict"; | |
| n.r(t); | |
| var o = [ | |
| "position: absolute !important;", | |
| "opacity: 0 !important;", | |
| "width: 1px !important;", | |
| "height: 1px !important;", | |
| "top: 0 !important;", | |
| "left: 0 !important;", | |
| "border: none !important;", | |
| "display: block !important;", | |
| "pointer-events: none !important;", | |
| ].join(" "), | |
| r = function (e) { | |
| var t = e.document.createElement("iframe"); | |
| return t.setAttribute("style", o), t; | |
| }; | |
| var i = function (e) { | |
| var t = {}; | |
| return ( | |
| Object.keys(e).forEach(function (n) { | |
| n.indexOf("intercom") > -1 && (t[n] = e[n]); | |
| }), | |
| t | |
| ); | |
| }, | |
| a = function (e, t, n) { | |
| !(function (e) { | |
| if (null == e) throw new TypeError("Cannot destructure undefined"); | |
| })(t), | |
| e.postMessage( | |
| { | |
| type: "intercom:callback", | |
| payload: { | |
| localStorage: i(window.localStorage), | |
| sessionStorage: i(window.sessionStorage), | |
| }, | |
| callbackId: n, | |
| }, | |
| "*" | |
| ); | |
| }; | |
| function c(e, t) { | |
| var n = Object.keys(e); | |
| if (Object.getOwnPropertySymbols) { | |
| var o = Object.getOwnPropertySymbols(e); | |
| t && | |
| (o = o.filter(function (t) { | |
| return Object.getOwnPropertyDescriptor(e, t).enumerable; | |
| })), | |
| n.push.apply(n, o); | |
| } | |
| return n; | |
| } | |
| function u(e, t, n) { | |
| return ( | |
| t in e | |
| ? Object.defineProperty(e, t, { | |
| value: n, | |
| enumerable: !0, | |
| configurable: !0, | |
| writable: !0, | |
| }) | |
| : (e[t] = n), | |
| e | |
| ); | |
| } | |
| var s = function (e) { | |
| return (function (e) { | |
| for (var t = 1; t < arguments.length; t++) { | |
| var n = null != arguments[t] ? arguments[t] : {}; | |
| t % 2 | |
| ? c(n, !0).forEach(function (t) { | |
| u(e, t, n[t]); | |
| }) | |
| : Object.getOwnPropertyDescriptors | |
| ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) | |
| : c(n).forEach(function (t) { | |
| Object.defineProperty( | |
| e, | |
| t, | |
| Object.getOwnPropertyDescriptor(n, t) | |
| ); | |
| }); | |
| } | |
| return e; | |
| })({}, d(e), {}, l(e)); | |
| }, | |
| d = function (e) { | |
| var t, n; | |
| return { | |
| location: null == e ? void 0 : e.location, | |
| referrer: | |
| null == e | |
| ? void 0 | |
| : null === (t = e.document) || void 0 === t | |
| ? void 0 | |
| : t.referrer, | |
| title: | |
| null == e | |
| ? void 0 | |
| : null === (n = e.document) || void 0 === n | |
| ? void 0 | |
| : n.title, | |
| }; | |
| }, | |
| l = function (e) { | |
| return { innerHeight: e.innerHeight, innerWidth: e.innerWidth }; | |
| }; | |
| var m = function (e, t, n) { | |
| !(function (e) { | |
| if (null == e) throw new TypeError("Cannot destructure undefined"); | |
| })(t), | |
| window.requestAnimationFrame(function (t) { | |
| e.postMessage( | |
| { type: "intercom:callback", payload: t, callbackId: n }, | |
| "*" | |
| ); | |
| }); | |
| }, | |
| p = [], | |
| f = 0, | |
| w = function (e) { | |
| for (; 2 > p.length; ) p.push(v(e)); | |
| }, | |
| v = function (e) { | |
| return (function (e, t) { | |
| var o = r(e); | |
| (o.src = n.p + "component.html"), | |
| (o.name = "intercom-component-" + t), | |
| (o.loaded = !1); | |
| return ( | |
| o.addEventListener("load", function e() { | |
| (o.loaded = !0), o.removeEventListener("load", e); | |
| }), | |
| e.document.body.appendChild(o), | |
| o | |
| ); | |
| })(e, f++); | |
| }, | |
| g = function (e, t, n, o) { | |
| !(function (e, t) { | |
| var n = p.shift(); | |
| n || (n = v(e)); | |
| var o = function e() { | |
| n.removeEventListener("load", e), t(n); | |
| }; | |
| n.loaded ? setTimeout(o, 0) : n.addEventListener("load", o), w(e); | |
| })(e, function (e) { | |
| (e.dataset.name = t), (e.style.cssText = n), o(e); | |
| }); | |
| }, | |
| h = function (e, t, n, o) { | |
| var r = e.document.querySelector('iframe[data-name="' + t + '"]'); | |
| r | |
| ? (function (e, t, n) { | |
| (e.style.cssText = t), | |
| setTimeout(function () { | |
| return n(e); | |
| }, 0); | |
| })(r, n, o) | |
| : g(e, t, n, o); | |
| }, | |
| y = function (e, t, n) { | |
| var o = t.name, | |
| r = t.styles; | |
| h(window, o, r, function (t) { | |
| e.postMessage( | |
| { | |
| type: "intercom:callback", | |
| payload: { frameName: t.name }, | |
| callbackId: n, | |
| }, | |
| "*" | |
| ); | |
| }); | |
| }, | |
| b = function (e) { | |
| var t, | |
| n = !1, | |
| o = | |
| (function (e) { | |
| return e.Intercom && e.Intercom.q; | |
| })(e) || [], | |
| r = function (e) { | |
| if ( | |
| ((n = e[0]), | |
| -1 !== ["boot", "update", "shutdown", "show", "hide"].indexOf(n)) | |
| ) { | |
| var n, | |
| o = { | |
| type: "intercom:api-call", | |
| payload: { args: Array.from(e) }, | |
| }; | |
| t.postMessage(o, "*"); | |
| } else | |
| console.warn( | |
| "Intercom – API call not supported with Privilege Separation:", | |
| e | |
| ); | |
| }, | |
| i = function (e) { | |
| "intercom:ready" === e.data.type && | |
| ((n = !0), | |
| (t = e.source), | |
| (function () { | |
| for (; o.length; ) r(o.pop()); | |
| })()); | |
| }; | |
| return ( | |
| e.addEventListener("message", i), | |
| (e.Intercom = function () { | |
| for (var e = arguments.length, t = new Array(e), i = 0; i < e; i++) | |
| t[i] = arguments[i]; | |
| n ? r(t) : o.push(t); | |
| }), | |
| function () { | |
| e.removeEventListener("message", i), delete e.Intercom, (n = !1); | |
| } | |
| ); | |
| }, | |
| S = function (e) { | |
| var t, | |
| n, | |
| o, | |
| r = e.source, | |
| i = e.data, | |
| c = e.origin; | |
| if ( | |
| "http://intercom-js.test" === c || | |
| "https://js.intercomcdn.com" === c | |
| ) | |
| switch (i.type) { | |
| case "intercom:ready": | |
| !(function (e) { | |
| var t = window.intercomSettings; | |
| if (t) { | |
| var n = window.location.href, | |
| o = document.cookie; | |
| e.postMessage( | |
| { | |
| type: "intercom:boot", | |
| payload: { settings: t, url: n, cookie: o }, | |
| }, | |
| "*" | |
| ); | |
| } | |
| })(r, i.payload), | |
| window.addEventListener( | |
| "resize", | |
| (function (e) { | |
| return function () { | |
| e.postMessage( | |
| { | |
| type: "intercom:window-resize", | |
| payload: { updates: l(window) }, | |
| }, | |
| "*" | |
| ); | |
| }; | |
| })(r) | |
| ); | |
| break; | |
| case "intercom:create-or-update-frame": | |
| y(r, i.payload, i.callbackId); | |
| break; | |
| case "intercom:destroy-frame": | |
| (t = i.payload), | |
| (n = t.name), | |
| (o = document.querySelector('iframe[data-name="' + n + '"]')) && | |
| o.remove(); | |
| break; | |
| case "intercom:write-cookie": | |
| !(function (e, t) { | |
| var n = t.cookie; | |
| window.document.cookie = n; | |
| })(0, i.payload, i.callbackId); | |
| break; | |
| case "intercom:set-item-for-storage": | |
| !(function (e, t) { | |
| var n = t.type, | |
| o = t.key, | |
| r = t.value, | |
| i = | |
| "localStorage" === n | |
| ? window.localStorage | |
| : window.sessionStorage; | |
| try { | |
| i.setItem(o, r); | |
| } catch (e) {} | |
| })(0, i.payload); | |
| break; | |
| case "intercom:remove-item-from-storage": | |
| !(function (e, t) { | |
| var n = t.type, | |
| o = t.key, | |
| r = | |
| "localStorage" === n | |
| ? window.localStorage | |
| : window.sessionStorage; | |
| try { | |
| r.removeItem(o); | |
| } catch (e) {} | |
| })(0, i.payload); | |
| break; | |
| case "intercom:create-storage-state": | |
| a(r, i.payload, i.callbackId); | |
| break; | |
| case "intercom:window-request-animation-frame": | |
| m(r, i.payload, i.callbackId); | |
| break; | |
| case "intercom:open-url": | |
| !(function (e, t) { | |
| var n = t.url; | |
| if (t.openNatively) window.open(n); | |
| else { | |
| var o = window.open(); | |
| if (!o) return; | |
| (o.opener = null), (o.location = n); | |
| } | |
| })(0, i.payload); | |
| } | |
| }, | |
| O = function () { | |
| var e = s(window); | |
| return ( | |
| "window=" + encodeURIComponent(JSON.stringify(e)) + "&localStorage=" | |
| ); | |
| }, | |
| I = function (e) { | |
| if ( | |
| !(function (e) { | |
| return e.document.querySelector( | |
| 'iframe[name="intercom-messenger"]' | |
| ); | |
| })(e) | |
| ) { | |
| b(e); | |
| var t = r(e); | |
| (t.name = "intercom-messenger"), | |
| (t.src = n.p + "frame.html?" + O()), | |
| e.document.body.appendChild(t), | |
| e.addEventListener("message", S), | |
| w(e); | |
| } | |
| }, | |
| E = [ | |
| /intercom-privilege-separation-enabled/, | |
| /^https:\/\/www\.intercom\.com\/legal\/terms-and-policies/, | |
| ], | |
| j = function (e) { | |
| return ( | |
| !0 === e.INTERCOM_PRIVILEGE_SEPARATION || | |
| E.some(function (t) { | |
| return t.test(e.location.href); | |
| }) | |
| ); | |
| }, | |
| A = ["turbo:visit", "turbolinks:visit", "page:before-change"], | |
| x = ["turbo:before-cache", "turbolinks:before-cache"], | |
| k = ["turbo:load", "turbolinks:load", "page:change"]; | |
| var _ = n(247), | |
| P = n(253).public_path; | |
| var M = P + "frame.f9b022ce.js", | |
| L = P + "vendor.cdd252af.js", | |
| C = P + "frame-modern.c4016961.js", | |
| T = P + "vendor-modern.9a7cb227.js", | |
| q = /bot|googlebot|crawler|spider|robot|crawling|facebookexternalhit/i, | |
| N = function () { | |
| return window.Intercom && window.Intercom.booted; | |
| }, | |
| R = function () { | |
| var e, | |
| t = | |
| !!(e = navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9\.]+)/)) && | |
| e[1]; | |
| return ( | |
| !!t && | |
| t.split(".").map(function (e) { | |
| return parseInt(e); | |
| }) | |
| ); | |
| }, | |
| D = function () { | |
| var e = document.querySelector('meta[name="referrer"]'), | |
| t = e ? '<meta name="referrer" content="' + e.content + '">' : "", | |
| n = document.createElement("iframe"); | |
| (n.id = "intercom-frame"), | |
| n.setAttribute( | |
| "style", | |
| "position: absolute !important; opacity: 0 !important; width: 1px !important; height: 1px !important; top: 0 !important; left: 0 !important; border: none !important; display: block !important; z-index: -1 !important; pointer-events: none;" | |
| ), | |
| n.setAttribute("aria-hidden", "true"), | |
| n.setAttribute("tabIndex", "-1"), | |
| n.setAttribute("title", "Intercom"), | |
| document.body.appendChild(n), | |
| Object(_.b)( | |
| n, | |
| '<!doctype html>\n <html lang="en">\n <head>\n ' + | |
| t + | |
| "\n </head>\n <body>\n </body>\n </html>" | |
| ); | |
| var o, | |
| r = !!(o = R()) && o[0] >= 81, | |
| i = Object(_.a)(r ? C : M), | |
| a = Object(_.a)(r ? T : L); | |
| return ( | |
| n.contentDocument.head.appendChild(i), | |
| n.contentDocument.head.appendChild(a), | |
| (window.__intercomAssignLocation = function (e) { | |
| window.location.assign(e); | |
| }), | |
| n | |
| ); | |
| }, | |
| F = function () { | |
| var e = document.getElementById("intercom-frame"); | |
| e && e.parentNode && e.parentNode.removeChild(e), | |
| delete window.__intercomAssignLocation; | |
| }, | |
| H = function () { | |
| if (!window.Intercom) { | |
| var e = function e() { | |
| for (var t = arguments.length, n = new Array(t), o = 0; o < t; o++) | |
| n[o] = arguments[o]; | |
| e.q.push(n); | |
| }; | |
| (e.q = []), (window.Intercom = e); | |
| } | |
| }, | |
| z = function () { | |
| N() || (H(), D(), (window.Intercom.booted = !0)); | |
| }; | |
| j(window) | |
| ? I(window) | |
| : ("attachEvent" in window && !window.addEventListener) || | |
| (navigator && | |
| navigator.userAgent && | |
| /MSIE 9\.0/.test(navigator.userAgent) && | |
| window.addEventListener && | |
| !window.atob) || | |
| ("onpropertychange" in document && | |
| window.matchMedia && | |
| /MSIE 10\.0/.test(navigator.userAgent)) || | |
| (navigator && navigator.userAgent && q.test(navigator.userAgent)) || | |
| window.isIntercomMessengerSheet || | |
| N() || | |
| (z(), | |
| (function (e, t, n) { | |
| k.forEach(function (t) { | |
| document.addEventListener(t, e); | |
| }), | |
| x.forEach(function (e) { | |
| document.addEventListener(e, t); | |
| }), | |
| A.forEach(function (e) { | |
| document.addEventListener(e, n); | |
| }); | |
| })(z, F, function () { | |
| window.Intercom("shutdown", !1), delete window.Intercom, F(), H(); | |
| })); | |
| }, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment