// ============================================================================ // File: content_fb.js // ============================================================================ (async function() { 'use strict'; if (window.__FritreeFacebookShieldInitialized) { console.warn("[Fritree Shield] Stealth protection and behavior simulation node is already active in this tab."); return; } window.__FritreeFacebookShieldInitialized = true; let panelShadowRootRef = null; let virtualCursorElement = null; let driftTimer = null; const SHIELD_INTEGRITY_SALT = "FritreeFacebookStealthShieldSymmetricSignatureSalt_SHA256_2026_EnterpriseSecureForce"; // Enhanced Stealth Guard configuration matrix (Facebook Node) const ShieldConfig = { sessionProfile: "casual", typingProfile: "average", typingSpeedMultiplier: 1.0, humanScrollActive: true, simulateMouseActive: true, antiHoneypotActive: true, humanTypingActive: true, randomMicroActive: true, autoPauseFailActive: true, scrollStepPixels: 250, scrollTotalCycles: 4, mouseMovementCycles: 5, mouseJitterSpeed: 8, coordinateJitterRadius: 10, showVirtualCursor: true, canvasNoiseActive: true, audioContextNoiseActive: true, webRtcLeakProtectionActive: true, hardwareConcurrencyMockActive: true, deviceMemoryMockActive: true, batteryApiMockActive: true, languagesSpoofActive: true, screenOrientationSpoofActive: true, pluginsMockActive: true, idleWanderActive: true, safeHoursSchedulerActive: true, dailyCapActive: false, dailyCapLimit: 100, typoRatio: 0.04, activeFreezeState: false, viewportJitterActive: true, idleCursorDriftActive: true, audioFingerprintNoiseActive: true, // Facebook-Specific Advanced Controls fbAntiHoneypotStrict: true, fbFocusShufflingActive: true, fbFocusShuffleMinSec: 15, fbFocusShuffleMaxSec: 45, fbHesitationBeforeType: true, fbHesitationMinMs: 800, fbHesitationMaxMs: 2500, fbSmoothScrollAcceleration: true, fbNetworkInfoSpoof: true }; /** * Compute secure symmetric SHA-256 signature to protect shield parameters */ async function calculateShieldSignature(config) { const serialized = JSON.stringify(config); const concatString = `${serialized}:${SHIELD_INTEGRITY_SALT}`; if (typeof FritreeCrypto !== 'undefined' && typeof FritreeCrypto.signReceipt === 'function') { return await FritreeCrypto.signReceipt( "FB_STEALTH_SHIELD_V3", concatString.length, "config_signature_256", concatString, SHIELD_INTEGRITY_SALT ); } let hash = 0; for (let i = 0; i < concatString.length; i++) { const char = concatString.charCodeAt(i); hash = ((hash << 5) - hash) + char; hash |= 0; } return "fallback_shield_sig_256_" + Math.abs(hash).toString(16); } /** * Save shield parameters securely with SHA-256 cryptographic signatures */ async function saveConfigSecurely() { const configToSave = {}; Object.keys(ShieldConfig).forEach(key => { if (typeof ShieldConfig[key] !== 'function' && typeof ShieldConfig[key] !== 'object') { configToSave[key] = ShieldConfig[key]; } }); const signature = await calculateShieldSignature(configToSave); if (typeof FritreeCrypto !== 'undefined' && typeof FritreeCrypto.setStorage === 'function') { await FritreeCrypto.setStorage('local_shield_config_matrix', configToSave); await FritreeCrypto.setStorage('local_shield_config_matrix_sig_256', signature); TelemetryLogger.log("🔐 Encryption Guard", "Shield parameters encrypted and signed with SHA-256.", "success"); } } /** * Load shield parameters securely and verify signature integrity */ async function loadConfigSecurely() { if (typeof FritreeCrypto !== 'undefined' && typeof FritreeCrypto.getStorage === 'function') { const loaded = await FritreeCrypto.getStorage('local_shield_config_matrix', null); const savedSig = await FritreeCrypto.getStorage('local_shield_config_matrix_sig_256', null); if (loaded) { if (savedSig) { const computedSig = await calculateShieldSignature(loaded); if (savedSig !== computedSig) { console.log("[Fritree Shield] Re-aligned configuration signature."); await saveConfigSecurely(); return; } } Object.keys(loaded).forEach(key => { if (ShieldConfig[key] !== undefined) { ShieldConfig[key] = loaded[key]; } }); } } } // Storage updates synchronized across contexts if (typeof chrome !== 'undefined' && chrome.storage && chrome.storage.onChanged) { chrome.storage.onChanged.addListener(async (changes, namespace) => { if (namespace === 'local') { const targetHash = await FritreeCrypto.sha256("local_shield_config_matrix" + "FritreeKeySalt_2026_StrictSHA256_Hashed_Production_WebCrypto_Salt"); if (changes[targetHash]) { await loadConfigSecurely(); TelemetryLogger.log("Live Mappings Sync", "New shield configurations decrypted and applied.", "success"); if (panelShadowRootRef) { FacebookWebLayoutOverride.setInitialSwitchesState(panelShadowRootRef); } } } }); } // Telemetry logger component class TelemetryLogger { static log(layer, action, status) { const timestamp = new Date().toLocaleTimeString('en-US'); console.log(`[${timestamp}] [Fritree FB Shield] [${layer}] [${action}] (${status})`); if (panelShadowRootRef) { const logsList = panelShadowRootRef.getElementById('fb-panel-logs-list'); if (logsList) { if (logsList.textContent.includes('Waiting for campaign trigger')) { logsList.innerHTML = ''; } const line = document.createElement('div'); line.style.cssText = 'border-bottom: 1px dashed #cbd5e1; padding: 6px 0; line-height: 1.4; color: #1e293b; font-size:11px; text-align: left; direction: ltr;'; let levelColor = '#1e293b'; if (status === 'error') levelColor = '#ef4444'; else if (status === 'warn') levelColor = '#f59e0b'; else if (status === 'success') levelColor = '#10b981'; const timeSpan = document.createElement('span'); timeSpan.style.color = '#64748b'; timeSpan.textContent = `[${timestamp}] `; const layerSpan = document.createElement('span'); layerSpan.style.color = levelColor; layerSpan.style.fontWeight = 'bold'; layerSpan.textContent = `[${layer}] `; const actionText = document.createTextNode(action); line.appendChild(timeSpan); line.appendChild(layerSpan); line.appendChild(actionText); logsList.appendChild(line); logsList.scrollTop = logsList.scrollHeight; } } } } // Dynamic Hardware, Network, and Profile Spoofing class DigitalFingerprintMask { static apply() { if (ShieldConfig.hardwareConcurrencyMockActive) { try { Object.defineProperty(navigator, 'hardwareConcurrency', { get: () => 8, configurable: true }); Object.defineProperty(navigator, 'deviceMemory', { get: () => 8, configurable: true }); } catch(e) {} } if (ShieldConfig.canvasNoiseActive) { this.injectCanvasFingerprintSpoofer(); } if (ShieldConfig.audioFingerprintNoiseActive) { this.injectAudioFingerprintSpoofer(); } if (ShieldConfig.languagesSpoofActive) { try { Object.defineProperty(navigator, 'languages', { get: () => ['en-US', 'ar'], configurable: true }); } catch(e) {} } if (ShieldConfig.fbNetworkInfoSpoof) { this.spoofNetworkInfo(); } if (ShieldConfig.batteryApiMockActive) { this.spoofBatteryInfo(); } } static injectCanvasFingerprintSpoofer() { try { const script = document.createElement('script'); script.textContent = ` const originalToDataURL = HTMLCanvasElement.prototype.toDataURL; const originalGetImageData = CanvasRenderingContext2D.prototype.getImageData; HTMLCanvasElement.prototype.toDataURL = function(...args) { const ctx = this.getContext('2d'); if (ctx) { try { const imgData = originalGetImageData.call(ctx, 0, 0, 1, 1); if (imgData) { imgData.data[0] = (imgData.data[0] + 1) % 256; ctx.putImageData(imgData, 0, 0); } } catch(e) {} } return originalToDataURL.apply(this, args); }; `; (document.head || document.documentElement).appendChild(script); script.remove(); } catch (e) { console.error("[Fritree Shield] Canvas spoofer error:", e); } } static injectAudioFingerprintSpoofer() { try { const script = document.createElement('script'); script.textContent = ` (() => { const originalGetChannelData = AudioBuffer.prototype.getChannelData; AudioBuffer.prototype.getChannelData = function(...args) { const data = originalGetChannelData.apply(this, args); if (data && data.length > 0) { data[0] += (Math.random() - 0.5) * 1e-7; } return data; }; })(); `; (document.head || document.documentElement).appendChild(script); script.remove(); } catch (e) { console.error("[Fritree Shield] Audio spoofer error:", e); } } static spoofNetworkInfo() { try { const mockConnection = { downlink: 10, effectiveType: "4g", rtt: 50, saveData: false, addEventListener: () => {}, removeEventListener: () => {} }; Object.defineProperty(navigator, 'connection', { get: () => mockConnection, configurable: true }); TelemetryLogger.log("Fingerprint Mask", "Network Information API spoofed (4G Latency).", "info"); } catch (e) {} } static spoofBatteryInfo() { try { const mockBattery = { charging: true, chargingTime: 0, dischargingTime: Infinity, level: 0.95, addEventListener: () => {}, removeEventListener: () => {} }; navigator.getBattery = () => Promise.resolve(mockBattery); TelemetryLogger.log("Fingerprint Mask", "Battery Status API obfuscated.", "info"); } catch (e) {} } } // Human Interaction and Movement Simulation class BehavioralSimulationEngine { static drawVirtualCursor() { if (virtualCursorElement || !ShieldConfig.showVirtualCursor) return; virtualCursorElement = document.createElement('div'); virtualCursorElement.id = 'fritree-virtual-cursor'; virtualCursorElement.style.cssText = ` position: fixed; width: 18px; height: 18px; background: url('data:image/svg+xml;utf8,') no-repeat; pointer-events: none; z-index: 1000000; transition: none; transform: translate(100px, 100px); `; document.body.appendChild(virtualCursorElement); } static removeVirtualCursor() { if (virtualCursorElement) { virtualCursorElement.remove(); virtualCursorElement = null; } } static async runAdvancedScrollSimulation() { if (!ShieldConfig.humanScrollActive) return; TelemetryLogger.log("📜 Reading Simulation", "Initiating human scrolling sweeps.", "info"); const step = ShieldConfig.scrollStepPixels || 250; const cycles = ShieldConfig.scrollTotalCycles || 4; for (let i = 0; i < cycles; i++) { let jitterStep = step + (Math.random() * 50 - 25); const targetY = window.scrollY + jitterStep; if (ShieldConfig.fbSmoothScrollAcceleration) { await this.runPhysicsBasedScroll(targetY, 1500); } else { window.scrollBy({ top: jitterStep, behavior: 'smooth' }); await new Promise(r => setTimeout(r, 1200)); } const correctionTargetY = window.scrollY - (jitterStep * 0.25); if (ShieldConfig.fbSmoothScrollAcceleration) { await this.runPhysicsBasedScroll(correctionTargetY, 900); } else { window.scrollBy({ top: -jitterStep * 0.25, behavior: 'smooth' }); await new Promise(r => setTimeout(r, 900)); } } TelemetryLogger.log("📜 Reading Simulation", "Human reading simulation completed.", "success"); } static runPhysicsBasedScroll(targetY, durationMs) { const startTime = performance.now(); const startY = window.scrollY; const difference = targetY - startY; return new Promise(resolve => { const step = (currentTime) => { const elapsed = currentTime - startTime; const progress = Math.min(elapsed / durationMs, 1); // Ease out cubic emulating human deceleration const ease = 1 - Math.pow(1 - progress, 3); window.scrollTo(0, startY + (difference * ease)); if (progress < 1) { requestAnimationFrame(step); } else { resolve(); } }; requestAnimationFrame(step); }); } static async runBezierMouseMovements() { if (!ShieldConfig.simulateMouseActive) return; this.drawVirtualCursor(); const cycles = ShieldConfig.mouseMovementCycles; TelemetryLogger.log("🖱️ Mouse Simulation", `Simulating mouse sweeps across Bezier curve paths. Cycles: [${cycles}].`, "info"); for (let i = 0; i < cycles; i++) { const startPoint = { x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight }; const endPoint = { x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight }; const ctrl1 = { x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight }; const ctrl2 = { x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight }; await this.animateBezierCurve(startPoint, ctrl1, ctrl2, endPoint); await new Promise(r => setTimeout(r, 700)); } if (ShieldConfig.idleCursorDriftActive) { this.startIdleCursorDrift(); } else if (!ShieldConfig.showVirtualCursor) { this.removeVirtualCursor(); } TelemetryLogger.log("🖱️ Mouse Simulation", "Bezier curve mouse sweeps completed.", "success"); } static animateBezierCurve(p0, p1, p2, p3) { return new Promise((resolve) => { const steps = 30; let currentStep = 0; const intervalDelay = ShieldConfig.mouseJitterSpeed || 8; const interval = setInterval(() => { if (currentStep > steps) { clearInterval(interval); resolve(); return; } const t = currentStep / steps; const temp = 1 - t; const x = temp * temp * temp * p0.x + 3 * temp * temp * t * p1.x + 3 * temp * t * t * p2.x + t * t * t * p3.x; const y = temp * temp * temp * p0.y + 3 * temp * temp * t * p1.y + 3 * temp * t * t * p2.y + t * t * t * p3.y; if (virtualCursorElement) { virtualCursorElement.style.transform = `translate(${x}px, ${y}px)`; } const mouseEvent = new MouseEvent('mousemove', { clientX: x, clientY: y, bubbles: true }); document.dispatchEvent(mouseEvent); currentStep++; }, intervalDelay); }); } static startIdleCursorDrift() { if (driftTimer) clearInterval(driftTimer); if (!ShieldConfig.idleCursorDriftActive || !virtualCursorElement) return; let angle = Math.random() * Math.PI * 2; let currentX = parseFloat(virtualCursorElement.style.transform.match(/translate\((.*)px,.*\)/)?.[1] || 300); let currentY = parseFloat(virtualCursorElement.style.transform.match(/translate\(.*px,\s*(.*)px\)/)?.[1] || 300); driftTimer = setInterval(() => { if (!ShieldConfig.idleCursorDriftActive) { clearInterval(driftTimer); return; } angle += (Math.random() - 0.5) * 0.5; const distance = 0.5 + Math.random() * 1.5; currentX += Math.cos(angle) * distance; currentY += Math.sin(angle) * distance; currentX = Math.max(10, Math.min(window.innerWidth - 10, currentX)); currentY = Math.max(10, Math.min(window.innerHeight - 10, currentY)); virtualCursorElement.style.transform = `translate(${currentX}px, ${currentY}px)`; }, 120); } static stopIdleCursorDrift() { if (driftTimer) { clearInterval(driftTimer); driftTimer = null; } } static applyViewportJitter() { if (!ShieldConfig.viewportJitterActive) return; const originalWidth = document.body.style.width; const offset = Math.floor(Math.random() * 3) + 1; document.body.style.width = `calc(100% - ${offset}px)`; setTimeout(() => { document.body.style.width = originalWidth || '100%'; }, 150); } static startFocusShuffling() { if (!ShieldConfig.fbFocusShufflingActive) return; const scheduleNext = () => { const delay = (Math.random() * (ShieldConfig.fbFocusShuffleMaxSec - ShieldConfig.fbFocusShuffleMinSec) + ShieldConfig.fbFocusShuffleMinSec) * 1000; setTimeout(() => { if (!ShieldConfig.fbFocusShufflingActive) return; TelemetryLogger.log("Stealth Focus", "Simulating tab focus background transition.", "info"); window.dispatchEvent(new Event('blur')); document.dispatchEvent(new Event('visibilitychange')); setTimeout(() => { window.dispatchEvent(new Event('focus')); document.dispatchEvent(new Event('visibilitychange')); scheduleNext(); }, Math.random() * 3000 + 1000); }, delay); }; scheduleNext(); } static async hesitateBeforeInteracting(element) { if (!ShieldConfig.fbHesitationBeforeType) return; const delay = Math.random() * (ShieldConfig.fbHesitationMaxMs - ShieldConfig.fbHesitationMinMs) + ShieldConfig.fbHesitationMinMs; TelemetryLogger.log("Stealth Focus", `hesitation phase active. Holding interaction for ${Math.round(delay)}ms...`, "info"); if (element) { element.dispatchEvent(new MouseEvent('mouseenter', { bubbles: true })); element.dispatchEvent(new MouseEvent('mouseover', { bubbles: true })); } await new Promise(r => setTimeout(r, delay)); } static isHoneypot(element) { if (!ShieldConfig.fbAntiHoneypotStrict) return false; if (!element) return false; const style = window.getComputedStyle(element); if (style.display === 'none' || style.visibility === 'hidden' || parseFloat(style.opacity) === 0) { return true; } if (element.getAttribute('aria-hidden') === 'true' || element.hasAttribute('hidden')) { return true; } const rect = element.getBoundingClientRect(); if (rect.width === 0 || rect.height === 0) { return true; } const left = parseFloat(style.left) || 0; const top = parseFloat(style.top) || 0; if (left < -5000 || top < -5000) { return true; } return false; } } // Real-Time Campaign Dispatch User-Interface Overlay class CampaignOverlayManager { static init() { this.overlayHost = null; this.shadowRoot = null; this.bindMessageListener(); } static bindMessageListener() { if (typeof chrome !== 'undefined' && chrome.runtime && chrome.runtime.onMessage) { chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { if (request.action === 'show_campaign_overlay') { this.show(request.text, request.photos, request.groupId); sendResponse({ success: true }); } else if (request.action === 'update_campaign_overlay_status') { this.updateStatus(request.status, request.step); sendResponse({ success: true }); } else if (request.action === 'close_campaign_overlay') { this.close(); sendResponse({ success: true }); } }); } } static show(text, photos, groupId) { this.close(); this.overlayHost = document.createElement('div'); this.overlayHost.id = 'fritree-campaign-overlay-host'; this.overlayHost.style.cssText = 'position: fixed; top: 70px; right: 20px; width: 380px; z-index: 10000000; pointer-events: none;'; document.body.appendChild(this.overlayHost); this.shadowRoot = this.overlayHost.attachShadow({ mode: 'open' }); const container = document.createElement('div'); container.id = 'campaign-overlay-container'; container.style.cssText = ` width: 100%; background: #ffffff; border: 1px solid #cbd5e1; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); display: flex; flex-direction: column; font-family: system-ui, -apple-system, sans-serif; overflow: hidden; pointer-events: auto; direction: ltr; text-align: left; `; const header = document.createElement('div'); header.style.cssText = 'background: #1877f2; color: #ffffff; padding: 12px 16px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; font-size: 13px;'; header.innerHTML = `