Loading TikTok Script Generator...
${bodyContent}
`;
// 3. Execute the Logic
const scriptEl = document.createElement('script');
scriptEl.text = scriptContent;
document.body.appendChild(scriptEl);
// 4. Override Generate Function for Auto-Scroll
// This ensures the user sees the generated script immediately
const originalGenerate = window.generate;
window.generate = function() {
if (typeof originalGenerate === 'function') {
originalGenerate();
setTimeout(() => {
const output = document.getElementById('output-area') || document.querySelector('main');
if (output) {
output.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}, 400);
}
};
// Initialize counter
setTimeout(() => {
if (typeof updateCount === 'function') updateCount();
}, 100);
})
.catch(err => {
document.getElementById('tiktok-script-root').innerHTML = "Error loading TikTok Script Generator.";
console.error(err);
});
})();