const fs = require('fs'); const path = require('path'); const glob = require('glob'); // Adjust these paths const htmlFolder = './html-pages'; // Your folder with 500 pages const oldLogoRegex = /]+src=["'][^"']*old-logo[^"']*["'][^>]*>/gi; // New logo HTML const newLogo = ``; glob(`${htmlFolder}/**/*.html`, (err, files) => { if (err) return console.error("Error reading files:", err); files.forEach(file => { let content = fs.readFileSync(file, 'utf8'); // Replace old logo content = content.replace(oldLogoRegex, newLogo); // Count existing "Trezor Suite" mentions (case-insensitive) const keywordCount = (content.match(/Trezor Suite/gi) || []).length; // Insert "Trezor Suite" if fewer than 9 if (keywordCount < 9) { const keywordToAdd = 9 - keywordCount; const filler = ` Trezor Suite`.repeat(keywordToAdd); // Add to end of first paragraph or if (content.includes('

')) { content = content.replace('

', `${filler}

`); } else if (content.includes('')) { content = content.replace('', `

${filler}

`); } } fs.writeFileSync(file, content, 'utf8'); console.log(`Updated: ${path.basename(file)} ✔`); }); });