WebOrbiton
v1.0.1

PriviMetrics 2

53 lines · 1.4 KB
  1. ; (() => {
  2. var s = document.currentScript
  3. if (!s) return
  4. ​
  5. var code = s.getAttribute("data-code")
  6. if (!code) return
  7. ​
  8. var customTitle = s.getAttribute("data-title")
  9. ​
  10. var noTrackIp = s.getAttribute("data-no-track-ip") === "true"
  11. ​
  12. var endpoint = s.src.replace(/\/[^/]+$/, "/privimetrics.php")
  13. ​
  14. function send() {
  15. try {
  16. var displayTitle = customTitle || document.title || ""
  17. ​
  18. var tz = ""
  19. try {
  20. tz = Intl.DateTimeFormat().resolvedOptions().timeZone || ""
  21. } catch (_) { }
  22. ​
  23. var lang = navigator.language || navigator.userLanguage || ""
  24. ​
  25. var params = [
  26. "t=" + encodeURIComponent(code),
  27. "p=" + encodeURIComponent(window.location.href),
  28. "title=" + encodeURIComponent(displayTitle),
  29. "r=" + encodeURIComponent(document.referrer || "d"),
  30. "js=1",
  31. "tz=" + encodeURIComponent(tz),
  32. "lang=" + encodeURIComponent(lang),
  33. "z=" + Math.random()
  34. ]
  35. ​
  36. if (noTrackIp) {
  37. params.push("track-ip=false")
  38. }
  39. ​
  40. var img = new Image(1, 1)
  41. img.style.display = "none"
  42. img.src = endpoint + "?" + params.join("&")
  43. document.documentElement.appendChild(img)
  44. } catch (_) { }
  45. }
  46. ​
  47. if (document.readyState === "complete" || document.readyState === "interactive") {
  48. send()
  49. } else {
  50. document.addEventListener("DOMContentLoaded", send)
  51. }
  52. })()
  53. ​