const fs = require('fs');
let app = fs.readFileSync('app_final.js', 'utf8');

const injectionStart = '// --- AUTO-CREATE ESSENTIAL ACCOUNTS ---';
const injectionEnd = '// -------------------------------------';

const firstStart = app.indexOf(injectionStart);
if (firstStart !== -1) {
    const secondStart = app.indexOf(injectionStart, firstStart + 1);
    if (secondStart !== -1) {
        const secondEnd = app.indexOf(injectionEnd, secondStart) + injectionEnd.length;
        app = app.substring(0, secondStart) + app.substring(secondEnd);
        fs.writeFileSync('app_final.js', app, 'utf8');
        console.log('Removed duplicate injection!');
    } else {
        console.log('No duplicate found.');
    }
}
