UNPKG

2.37 kBJavaScriptView Raw
1!function(){function t(){return t=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},t.apply(this,arguments)}!function(){if(window){var n=window,e=n.navigator,r=e.language,i=e.userAgent,o=n.location,a=o.hostname,u=o.pathname,s=o.search,d=o.origin,c=n.document,w=n.history,v=c.querySelector("script[data-site]");if(!v)return console.error("script.js not found");var p=function(t){var n=v&&(v.hasAttribute(t)||v.hasAttribute("data-"+t));return!!n&&(v.getAttribute(t)||v.getAttribute("data-"+t)||n)},f=v.src||"https://buzz.proxima.so",l=p("site"),h=p("manual"),g=p("url")||new URL(f).origin,b=p("spa"),m=p("hostname")||a;if(!l)return;if(function(t){return/(bot|spider|crawl)/i.test(t)||window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress}(i))return;if(p("dnt")&&function(){var t=window,n=t.doNotTrack||t.navigator.doNotTrack;return"yes"===n||"1"===n}())return;if("visibilityState"in c&&"prerender"===c.visibilityState)return;var y=function(){window.addEventListener("hashchange",x)},E=function(t,n){var e=new XMLHttpRequest;e.open("POST",g+t,!0),e.setRequestHeader("Content-Type","text/plain"),e.addEventListener("error",function(){}),e.send(JSON.stringify(n))},S=function(n){var e,i,o;void 0===n&&(n={});var a=c.querySelector("[rel='canonical']");return t({p:a?null!=(e=n)&&e.page?null==(i=n)?void 0:i.page:a.getAttribute("href"):d+u+s,v:"1.0.7",s:l,h:m||"",r:null!=(o=n)&&o.referrer?n.referrer:(null==c?void 0:c.referrer)||"",l:r||"",cid:Date.now().toString(32)},n)},x=function(n){void 0===n&&(n={}),E("/torch",t({t:"pageview"},S(n)))};window.proxima||(window.proxima={track:x,event:function(n,e,r){void 0===e&&(e={}),void 0===r&&(r={}),n&&E("/torch",t({t:"event",e:n,mt:e},S(r)))}},function(){var t,n,e;if("true"===(null==(t=window)||null==(n=t.localStorage)?void 0:n.proxima_ignore))return console.warn("ignored");if(b&&!h)switch(b){case"off":break;case"hash":y();break;default:void 0!==w?(e=w.pushState,void 0!==w&&(w.pushState=function(){var t=e.apply(w,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("prxm")),t},window.addEventListener("popstate",function(){window.dispatchEvent(new Event("prxm"))}),window.addEventListener("prxm",x))):y()}h||x()}())}}()}();