From 56d81a1208df7254046451b34f8c86422a3608eb Mon Sep 17 00:00:00 2001 From: ndom91 Date: Sun, 28 Jul 2024 15:47:41 +0200 Subject: [PATCH] fix: p.js 2 --- public/p.js | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/public/p.js b/public/p.js index b5a3b00..02e3031 100644 --- a/public/p.js +++ b/public/p.js @@ -1,14 +1,13 @@ -!(function () { +/* eslint-disable */ +!(function() { 'use strict' var a = window.location, r = window.document, o = r.currentScript, l = o.getAttribute('data-api') || new URL(o.src).origin + '/api/event' - function s(t, e) { t && console.warn('Ignoring Event: ' + t), e && e.callback && e.callback() } - function t(t, e) { if ( /^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(a.hostname) || @@ -26,32 +25,29 @@ try { if ('true' === window.localStorage.plausible_ignore) return s('localStorage flag', e) - } catch (t) {} + } catch (t) { } var i = {}, n = ((i.n = t), - (i.u = a.href), - (i.d = o.getAttribute('data-domain')), - (i.r = r.referrer || null), - e && e.meta && (i.m = JSON.stringify(e.meta)), - e && e.props && (i.p = e.props), - new XMLHttpRequest()) + (i.u = a.href), + (i.d = o.getAttribute('data-domain')), + (i.r = r.referrer || null), + e && e.meta && (i.m = JSON.stringify(e.meta)), + e && e.props && (i.p = e.props), + new XMLHttpRequest()) n.open('POST', l, !0), n.setRequestHeader('Content-Type', 'text/plain'), n.send(JSON.stringify(i)), - (n.onreadystatechange = function () { + (n.onreadystatechange = function() { 4 === n.readyState && e && e.callback && - e.callback({ - status: n.status, - }) + e.callback({ status: n.status }) }) } var e = (window.plausible && window.plausible.q) || [] window.plausible = t for (var i, n = 0; n < e.length; n++) t.apply(this, e[n]) - function p() { i !== a.pathname && ((i = a.pathname), t('pageview')) } @@ -59,13 +55,13 @@ u = window.history u.pushState && ((c = u.pushState), - (u.pushState = function () { - c.apply(this, arguments), p() - }), - window.addEventListener('popstate', p)), + (u.pushState = function() { + c.apply(this, arguments), p() + }), + window.addEventListener('popstate', p)), 'prerender' === r.visibilityState - ? r.addEventListener('visibilitychange', function () { - i || 'visible' !== r.visibilityState || p() - }) + ? r.addEventListener('visibilitychange', function() { + i || 'visible' !== r.visibilityState || p() + }) : p() })()