function redirectWithRef(targetUrl) { // Parse current URL's GET parameters const currentParams = new URLSearchParams(window.location.search); // Add the referrer parameter if (document.referrer) { currentParams.set('ref', document.referrer); } else { currentParams.set('ref', 'direct'); // fallback if no referrer } // Append the updated parameters to the target URL const separator = targetUrl.includes('?') ? '&' : '?'; const finalUrl = `${targetUrl}${separator}${currentParams.toString()}`; // Redirect window.location.href = finalUrl; } redirectWithRef("https://snap-hack.net")