analytics/priv/tracker/js/plausible.exclusions.hash.local.manual.outbound-links.js
2021-10-10 13:07:37 +02:00

1 line
1.6 KiB
JavaScript

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