content = content.replace('', scriptToAdd + '\n'); return content; } function modifyJsContent(content) { // Intelligently add sendState(1) at the end of the interactive // This is a simple heuristic and may need adjustment based on the interactive's code var endStateRegex = /(function\s+endInteractive\s*\([\s\S]*?\{)/g; content = content.replace(endStateRegex, function(match) { return match + '\n sendState(1);'; }); return content; } function downloadModifiedZip() { if (modifiedZipBlob) { saveAs(modifiedZipBlob, 'modified_interactive.zip'); } }