This commit is contained in:
andreyflat 2025-08-19 03:58:16 +08:00
parent 6217ca412c
commit 6636f6698b

View file

@ -442,23 +442,35 @@ const videoObserver = new IntersectionObserver((entries, observer) => {
</script> </script>
<script> <script>
(function () { window.addEventListener("load", () => {
const secret = "flat_secret_123"; // тот же, что в Netlify → SECRET_KEY try {
const url = "/.netlify/functions/privateViewLogger?key=" + encodeURIComponent(secret) + "&t=" + Date.now(); if (sessionStorage.getItem("af_logged")) return; // не спамим: 1 раз за сессию
sessionStorage.setItem("af_logged", "1");
fetch(url, { const secret = "flat_secret_123"; // тот же, что в Netlify → SECRET_KEY
method: "POST", const url = "/.netlify/functions/privateViewLogger"
keepalive: true, + "?key=" + encodeURIComponent(secret)
headers: { "content-type": "application/json", "cache-control": "no-store" }, + "&path=" + encodeURIComponent(location.pathname)
body: JSON.stringify({ path: location.pathname }) + "&t=" + Date.now(); // ломаем кэш
})
.then(r => r.text().then(t => console.log("logger:", r.status, t))) if (navigator.sendBeacon) {
.catch(e => console.log("logger error:", e)); const body = JSON.stringify({ path: location.pathname });
})(); navigator.sendBeacon(url, body);
} else {
fetch(url, {
method: "POST",
keepalive: true,
headers: { "content-type": "application/json" },
body: JSON.stringify({ path: location.pathname })
}).catch(() => {});
}
} catch {}
});
</script> </script>
<button id="scrollToTopBtn" title="Rewind">&#8679;</button> <button id="scrollToTopBtn" title="Rewind">&#8679;</button>
<script> <script>