PageSourceSearch

https://counterscale.viftrup.workers.dev/tracker.js

js counterscale.viftrup.workers.dev collected 2026-10-03 08:06:49 UTC 4,985 bytes, 175 lines download raw bytes

1(() => {
2var g = Object.defineProperty;
3var w = (t, e, n) => e in t ? g(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
4var u = (t, e, n) => w(t, typeof e != "symbol" ? e + "" : e, n);
5function y(t) {
6  const e = history.pushState;
7  history.pushState = function(r, a) {
8    e.apply(this, arguments), t();
9  };
10  const n = () => {
11    t();
12  };
13  return addEventListener("popstate", n), () => {
14    history.pushState = e, removeEventListener("popstate", n);
15  };
16}
17function P(t) {
18  return /^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*:)*?:?0*1$/.test(
19    t
20  );
21}
22function S(t, e = !1) {
23  if (e && typeof document < "u") {
24    const n = document.createElement("a");
25    n.href = t;
26    const r = n.protocol + "//" + n.hostname, a = n.pathname;
27    return { hostname: r, path: a };
28  } else {
29    const n = new URL(t), r = n.protocol + "//" + n.hostname, a = n.pathname;
30    return { hostname: r, path: a };
31  }
32}
33function U(t, e) {
34  return !e || e.indexOf(t) >= 0 ? "" : e.split("?")[0] || "";
35}
36function L(t) {
37  const e = {}, n = t.indexOf("?");
38  if (n === -1) return e;
39  const r = t.substring(n + 1), a = new URLSearchParams(r), o = a.get("utm_source"), c = a.get("utm_medium"), i = a.get("utm_campaign"), l = a.get("utm_term"), s = a.get("utm_content");
40  return o && (e.us = o), c && (e.um = c), i && (e.uc = i), l && (e.ut = l), s && (e.uco = s), e;
41}
42function T(t, e = !1) {
43  return "?" + Object.keys(t).filter((n) => !(t[n] === void 0 || e && t[n] === "")).map(function(n) {
44    return encodeURIComponent(n) + "=" + encodeURIComponent(t[n]);
45  }).join("&");
46}
47function O(t, e, n, r, a = {}, o) {
48  const c = {
49    p: n,
50    h: e,
51    r,
52    sid: t
53  };
54  return o && (c.ht = o), Object.assign(c, a), c;
55}
56function R(t, e, n = !1) {
57  return t + T(e, n);
58}
59const h = 1e3;
60function I(t, e) {
61  return new Promise((n) => {
62    const r = {
63      ht: 1
64      // Assume first hit (new visit)
65    }, a = `${t.replace(/\/collect$/, "/cache")}?sid=${encodeURIComponent(e)}`, o = new XMLHttpRequest();
66    o.open("GET", a, !0), o.timeout = h, o.setRequestHeader("Content-Type", "text/plain"), o.onload = function() {
67      if (o.status === 200)
68        try {
69          const c = JSON.parse(
70            o.responseText
71          );
72          n(c);
73        } catch {
74          n(r);
75        }
76      else
77        n(r);
78    }, o.onerror = () => n(r), o.ontimeout = () => n(r), o.send();
79  });
80}
81function q(t, e) {
82  const n = new XMLHttpRequest(), r = R(t, e);
83  n.open("GET", r, !0), n.setRequestHeader("Content-Type", "text/plain"), n.timeout = h, n.send();
84}
85function C(t) {
86  const e = y(() => {
87    f(t);
88  });
89  return f(t), e;
90}
91function E() {
92  const t = document.querySelector(
93    'link[rel="canonical"][href]'
94  );
95  if (!t)
96    return null;
97  const e = document.createElement("a");
98  return e.href = t.href, e;
99}
100function k(t, e) {
101  return !e && document.referrer && document.referrer.indexOf(t) < 0 && (e = document.referrer), U(t, e || "");
102}
103async function f(t, e = {}) {
104  const r = E() ?? window.location;
105  if (!t.reportOnLocalhost && P(window.location.hostname) || r.host === "" && navigator.userAgent.indexOf("Electron") < 0)
106    return;
107  const a = e.url || r.pathname + r.search || "/", { hostname: o, path: c } = S(a, !0), i = k(o, e.referrer || ""), l = L(a);
108  let s;
109  try {
110    s = (await I(
111      t.reporterUrl,
112      t.siteId
113    )).ht.toString();
114  } catch {
115  }
116  const p = O(
117    t.siteId,
118    o,
119    c,
120    i,
121    l,
122    s
123  );
124  q(t.reporterUrl, p);
125}
126class v {
127  constructor(e) {
128    u(this, "siteId");
129    u(this, "reporterUrl");
130    u(this, "reportOnLocalhost", !1);
131    u(this, "_cleanupAutoTrackPageviews");
132    this.siteId = e.siteId, this.reporterUrl = e.reporterUrl, e.reportOnLocalhost && (this.reportOnLocalhost = e.reportOnLocalhost), (e.autoTrackPageviews === void 0 || e.autoTrackPageviews) && setTimeout(() => {
133      this._cleanupAutoTrackPageviews = C(this);
134    }, 0);
135  }
136  cleanup() {
137    this._cleanupAutoTrackPageviews && this._cleanupAutoTrackPageviews();
138  }
139}
140const d = {
141  client: void 0
142};
143function A(t) {
144  d.client || (d.client = new v(t));
145}
146function _() {
147  return document.getElementById(
148    "counterscale-script"
149  );
150}
151function x() {
152  let t;
153  return (window.counterscale && window.counterscale.q || []).forEac
153h(function(n) {
154    n[0] === "set" && n[1] === "siteId" && (t = n[2]);
155  }), t;
156}
157function m() {
158  const t = _(), e = (t == null ? void 0 : t.getAttribute("data-site-id")) || x(), n = (t == null ? void 0 : t.hasAttribute("data-report-localhost")) && (t == null ? void 0 : t.getAttribute("data-report-localhost")) !== "false" || !1, r = t == null ? void 0 : t.src.replace("tracker.js", "collect");
159  !e || !r || A({
160    siteId: e,
161    reportOnLocalhost: n,
162    reporterUrl: r,
163    autoTrackPageviews: !0
164  });
165}
166(function() {
167  if (document.body === null) {
168    document.addEventListener("DOMContentLoaded", () => {
169      m();
170    });
171    return;
172  }
173  m();
174})();
175})()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.