You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
analytics/priv/tracker/js/plausible.compat.outbound-l...

1 line
1.8 KiB
JavaScript

!function(){"use strict";var t,e,i,n=window.location,r=window.document,a=window.localStorage,o=r.getElementById("plausible"),l=o.getAttribute("data-api")||(t=o.src.split("/"),e=t[0],i=t[2],e+"//"+i+"/api/event"),s=a&&a.plausible_ignore;function p(t){console.warn("Ignoring Event: "+t)}function c(t,e){if(/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(n.hostname)||"file:"===n.protocol)return p("localhost");if(!(window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)){if("true"==s)return p("localStorage flag");var i={};i.n=t,i.u=n.href,i.d=o.getAttribute("data-domain"),i.r=r.referrer||null,i.w=window.innerWidth,e&&e.meta&&(i.m=JSON.stringify(e.meta)),e&&e.props&&(i.p=JSON.stringify(e.props));var a=new XMLHttpRequest;a.open("POST",l,!0),a.setRequestHeader("Content-Type","text/plain"),a.send(JSON.stringify(i)),a.onreadystatechange=function(){4==a.readyState&&e&&e.callback&&e.callback()}}}function d(t){for(var e=t.target,i="auxclick"==t.type&&2==t.which,a="click"==t.type;e&&(void 0===e.tagName||"a"!=e.tagName.toLowerCase()||!e.href);)e=e.parentNode;e&&e.href&&e.host&&e.host!==n.host&&((i||a)&&plausible("Outbound Link: Click",{props:{url:e.href}}),e.target&&!e.target.match(/^_(self|parent|top)$/i)||t.ctrlKey||t.metaKey||t.shiftKey||!a||(setTimeout(function(){n.href=e.href},150),t.preventDefault()))}r.addEventListener("click",d),r.addEventListener("auxclick",d);var u=window.plausible&&window.plausible.q||[];window.plausible=c;for(var w,h=0;h<u.length;h++)c.apply(this,u[h]);function f(){w!==n.pathname&&(w=n.pathname,c("pageview"))}var g,v=window.history;v.pushState&&(g=v.pushState,v.pushState=function(){g.apply(this,arguments),f()},window.addEventListener("popstate",f)),"prerender"===r.visibilityState?r.addEventListener("visibilitychange",function(){w||"visible"!==r.visibilityState||f()}):f()}();