// inject.js - runs in page context, auto-starts recording (function() { 'use strict'; let stopFn = null; // Auto-start recording stopFn = rrwebRecord.record({ emit: function(event) { window.postMessage({ __rrweb_action: 'event', __rrweb_data: event }, '*'); }, recordCrossOriginIframes: true }); // Listen for stop command window.addEventListener('message', function(event) { if (event.source !== window) return; if (event.data && event.data.__rrweb_action === 'stop') { if (stopFn) { stopFn(); stopFn = null; } } }); console.log('[rrweb] Recording started'); })();