UNPKG

2.33 kBJavaScriptView Raw
1!function(){if(window){var t=function(){var t=window,e=t.navigator,n=t.external,r=t.doNotTrack||e.doNotTrack||e.msDoNotTrack||n&&"function"==typeof n.msTrackingProtectionEnabled&&n.msTrackingProtectionEnabled();return!0===r||1===r||"yes"===r||"1"===r}(),e=window,n=e.navigator.userAgent,r=e.location,i=r.hostname,o=r.pathname,a=r.search,d=r.origin,s=e.document,c=e.history,u=s.querySelector("script[data-site]");if(!u)return console.error("script.js not found");var w=new URL(s.currentScript.src).origin,p=function(t){return u&&(u.getAttribute(t)||u.getAttribute("data-"+t))},v=p("site"),f=p("dnt-off"),h=p("spa"),l=function(t){console.warn("Proxima:",t)},g=p("hostname")||i;if(p("canonical"),!v)return l("site not found");if(function(t){return/(bot|spider|crawl)/i.test(t)||window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress}(n))return l("bot detected");if(f&&t)return l("dnt-off and dnt=1");if("visibilityState"in s&&"prerender"===s.visibilityState)return l("Prerendering");var m=function(){var t=c.pushState;void 0!==c&&(c.pushState=function(){var e=t.apply(c,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("prxm")),e},window.addEventListener("popstate",function(){window.dispatchEvent(new Event("prxm"))}),window.addEventListener("prxm",b))},E=function(){window.addEventListener("hashchange",b)},b=function(){var t,e;t={p:d+o+a,v:"1.0.2",s:v,h:g,r:s.referrer,cid:Date.now().toString(32),l:navigator.userLanguage||navigator.language||""},(e=new XMLHttpRequest).open("POST",w+"/hit/torch",!0),e.setRequestHeader("Content-Type","text/plain"),e.addEventListener("error",function(){var e,n;e=t,(n=s.createElement("img")).setAttribute("aria-hidden","true"),n.setAttribute("alt",""),n.src=w+e.toString(),n.style.position="absolute",n.src=w+"/hit/torch/pixel?"+new URLSearchParams(e).toString(),n.addEventListener("load",function(){n.parentNode&&n.parentNode.removeChild(n)}),n.addEventListener("error",function(){n.parentNode&&n.parentNode.removeChild(n)}),s.body.appendChild(n)}),e.send(JSON.stringify(t))};window.proxima||(window.proxima={monitor:b,event:b},function(){if(l("init"),h)switch(h){case"history":m();break;case"hash":E();break;default:void 0!==c?m():E()}else window.addEventListener("load",b)}())}}();
2//# sourceMappingURL=script.debug.js.map