plausible.kproxy.com Open in urlscan Pro
62.77.140.46  Public Scan

URL: https://plausible.kproxy.com/js/plausible.js
Submission: On May 10 via manual from IN — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

(function () {
  "use strict";

  var currentLocation = window.location;
  var document = window.document;
  var localStorage = window.localStorage;
  var currentScript = document.currentScript;
  var apiEndpoint =
    currentScript.getAttribute("data-api") ||
    new URL(currentScript.src).origin + "/api/event";
  var ignoreLocalStorageFlag = localStorage && localStorage.plausible_ignore;

  function logIgnoreEvent(event) {
    console.warn("Ignoring Event: " + event);
  }

  function trackEvent(event, eventData) {
    if (
      /^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(
        currentLocation.hostname
      ) ||
      currentLocation.protocol === "file:"
    ) {
      return logIgnoreEvent("localhost");
    }

    if (
      !(
        window._phantom ||
        window.__nightmare ||
        window.navigator.webdriver ||
        window.Cypress
      )
    ) {
      if (ignoreLocalStorageFlag === "true") {
        return logIgnoreEvent("localStorage flag");
      }

      var eventDataToSend = {
        n: event,
        u: currentLocation.href,
        d: currentScript.getAttribute("data-domain"),
        r: document.referrer || null,
        w: window.innerWidth,
      };

      if (eventData && eventData.meta) {
        eventDataToSend.m = JSON.stringify(eventData.meta);
      }

      if (eventData && eventData.props) {
        eventDataToSend.p = JSON.stringify(eventData.props);
      }

      var xhr = new XMLHttpRequest();
      xhr.open("POST", apiEndpoint, true);
      xhr.setRequestHeader("Content-Type", "text/plain");
      xhr.send(JSON.stringify(eventDataToSend));

      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && eventData && eventData.callback) {
          eventData.callback();
        }
      };
    }
  }

  var plausibleQueue = (window.plausible && window.plausible.q) || [];
  window.plausible = trackEvent;

  for (var i = 0; i < plausibleQueue.length; i++) {
    trackEvent.apply(this, plausibleQueue[i]);
  }

  var previousPathname = null;

  function trackPageView() {
    if (previousPathname !== currentLocation.pathname) {
      previousPathname = currentLocation.pathname;
      trackEvent("pageview");
    }
  }

  var history = window.history;
  var pushState = history.pushState;

  if (pushState) {
    history.pushState = function () {
      pushState.apply(this, arguments);
      trackPageView();
    };

    window.addEventListener("popstate", trackPageView);
  }

  if (document.visibilityState === "prerender") {
    document.addEventListener("visibilitychange", function () {
      if (!previousPathname || document.visibilityState !== "visible") {
        return;
      }

      trackPageView();
    });
  } else {
    trackPageView();
  }
})();