Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const visitorData = {
- file_id: 148201,
- viewport_size: `${window.innerWidth}x${window.innerHeight}`,
- referer: "http:\/\/vidara.so",
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
- gpu: null,
- cpu: null,
- browser: null,
- platform: navigator.platform,
- plugins_count: navigator.plugins ? navigator.plugins.length : 0,
- permissions_api: void 0 !== navigator.permissions,
- notification_api: "undefined" != typeof Notification,
- page_duration: 0,
- watch_time: 0,
- tab_visibility_changes: 0,
- focus_changes: 0,
- mouse_movements: [],
- click_positions: []
- };
- let startTime = Date.now(),
- hasSentData = !1;
- const ENCRYPTION_KEY = "7k9mP2nQ8vR4xT6yU3wZ1aS5dF0gH7jL";
- function compressAndEncrypt(t) {
- try {
- let e = JSON.stringify(t),
- i = pako.gzip(e),
- n = btoa(String.fromCharCode.apply(null, i)),
- o = CryptoJS.AES.encrypt(n, "7k9mP2nQ8vR4xT6yU3wZ1aS5dF0gH7jL").toString();
- return o
- } catch (a) {
- return console.error("Compression/Encryption error:", a), null
- }
- }
- let heartbeatInterval = null,
- sessionId = null;
- function generateSessionId() {
- return `${Date.now()}-${Math.random().toString(36).substr(2,9)}`
- }
- function sendHeartbeat() {
- let t = {
- file_id: visitorData.file_id,
- session_id: sessionId
- };
- fetch("/api/heartbeat", {
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify(t),
- keepalive: !0
- }).catch(() => {})
- }
- function startHeartbeat() {
- heartbeatInterval || (sessionId || (sessionId = generateSessionId()), sendHeartbeat(), heartbeatInterval = setInterval(() => {
- sendHeartbeat()
- }, 15e3))
- }
- function stopHeartbeat() {
- heartbeatInterval && (clearInterval(heartbeatInterval), heartbeatInterval = null)
- }
- function detectBrowser() {
- let t = navigator.userAgent,
- e = navigator.vendor;
- return navigator.brave && "function" == typeof navigator.brave.isBrave ? "Brave" : t.indexOf("Edg/") > -1 || t.indexOf("Edge/") > -1 ? "Edge" : window.opr || window.opera || t.indexOf("OPR/") > -1 ? "Opera" : t.indexOf("Vivaldi") > -1 ? "Vivaldi" : t.indexOf("YaBrowser") > -1 ? "Yandex" : t.indexOf("UCBrowser") > -1 ? "UC Browser" : t.indexOf("SamsungBrowser") > -1 ? "Samsung Internet" : t.indexOf("Firefox") > -1 || t.indexOf("FxiOS") > -1 ? "Firefox" : t.indexOf("Safari") > -1 && -1 === t.indexOf("Chrome") && e.indexOf("Apple") > -1 ? "Safari" : t.indexOf("Chrome") > -1 && e.indexOf("Google") > -1 ? "Chrome" : t.indexOf("MSIE") > -1 || t.indexOf("Trident/") > -1 ? "Internet Explorer" : "Unknown"
- }
- function getCPU() {
- return navigator.hardwareConcurrency ? `${navigator.hardwareConcurrency} cores` : "Unknown"
- }
- function getGPU() {
- try {
- let t = document.createElement("canvas"),
- e = t.getContext("webgl") || t.getContext("experimental-webgl");
- if (!e) return null;
- let i = e.getExtension("WEBGL_debug_renderer_info");
- if (i) return e.getParameter(i.UNMASKED_RENDERER_WEBGL);
- return "Unknown"
- } catch (n) {
- return null
- }
- }
- document.addEventListener("visibilitychange", () => {
- document.hidden && visitorData.tab_visibility_changes++
- }), window.addEventListener("focus", () => {
- visitorData.focus_changes++
- }), window.addEventListener("blur", () => {
- visitorData.focus_changes++
- }), window.addEventListener("load", () => {
- startHeartbeat()
- }), ("complete" === document.readyState || "interactive" === document.readyState) && startHeartbeat(), window.addEventListener("beforeunload", () => {
- stopHeartbeat()
- });
- let mouseMoveCount = 0;
- function calculateMouseEntropy() {
- if (visitorData.mouse_movements.length < 10) return 0;
- let t = [];
- for (let e = 1; e < visitorData.mouse_movements.length; e++) {
- let i = visitorData.mouse_movements[e - 1],
- n = visitorData.mouse_movements[e],
- o = n.x - i.x,
- a = n.y - i.y,
- r = Math.sqrt(o * o + a * a);
- t.push(r)
- }
- let s = t.reduce((t, e) => t + e, 0) / t.length,
- l = t.reduce((t, e) => t + Math.pow(e - s, 2), 0) / t.length;
- return Math.sqrt(l)
- }
- function detectStraightLineMovements() {
- if (visitorData.mouse_movements.length < 3) return 0;
- let t = 0;
- for (let e = 2; e < visitorData.mouse_movements.length; e++) {
- let i = visitorData.mouse_movements[e - 2],
- n = visitorData.mouse_movements[e - 1],
- o = visitorData.mouse_movements[e],
- a = Math.abs((n.x - i.x) * (o.y - i.y) - (o.x - i.x) * (n.y - i.y));
- a < 5 && t++
- }
- return t / visitorData.mouse_movements.length
- }
- function sendVisitorData() {
- if (hasSentData) return;
- hasSentData = !0, visitorData.page_duration = Math.round((Date.now() - startTime) / 1e3), visitorData.watch_time = void 0 !== totalWatchTime ? Math.round(totalWatchTime) : 0, visitorData.session_id = sessionId, visitorData.behavioral_analysis = {
- mouse_entropy: calculateMouseEntropy(),
- straight_line_ratio: detectStraightLineMovements(),
- has_mouse_movement: visitorData.mouse_movements.length > 0
- };
- let t = compressAndEncrypt(visitorData);
- if (!t) {
- console.error("Failed to encrypt data");
- return
- }
- fetch("/api/count", {
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify({
- data: t
- }),
- keepalive: !0
- }).then(t => t.json()).then(t => {}).catch(t => {}), stopHeartbeat()
- }
- document.addEventListener("mousemove", t => {
- ++mouseMoveCount % 10 == 0 && (visitorData.mouse_movements.push({
- x: t.pageX,
- y: t.pageY,
- t: Date.now() - startTime
- }), visitorData.mouse_movements.length > 50 && visitorData.mouse_movements.shift())
- }), document.addEventListener("click", t => {
- visitorData.click_positions.push({
- x: t.pageX,
- y: t.pageY,
- t: Date.now() - startTime,
- button: t.button
- }), visitorData.click_positions.length > 20 && visitorData.click_positions.shift()
- }), visitorData.browser = detectBrowser(), visitorData.gpu = getGPU(), visitorData.cpu = getCPU(), setInterval(() => {
- void 0 !== totalWatchTime && !hasSentData && Math.floor(totalWatchTime) >= 36 && sendVisitorData()
- }, 500);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment