added advertising

This commit is contained in:
SlimusMinus
2026-09-23 23:38:54 +03:00
parent 3661985a6a
commit 4e20315998
33 changed files with 3351 additions and 18 deletions

21
src/utils/adSession.js Normal file
View File

@@ -0,0 +1,21 @@
const AD_SESSION_KEY = "ad_session_id";
function generateAdSessionId() {
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
return crypto.randomUUID();
}
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
export function getAdSessionId() {
let sessionId = localStorage.getItem(AD_SESSION_KEY);
if (!sessionId) {
sessionId = generateAdSessionId();
localStorage.setItem(AD_SESSION_KEY, sessionId);
}
return sessionId;
}