// Stamp the theme head script (themehead.js) into every static page under public/ that loads site.css, before the first // stylesheet, and put data-theme-base on the tag (dark: every InstantAdPay page is a site.css page). Re-runnable: an // existing copy between the markers is replaced. Run after changing AUTO_DEFAULT in themehead.js: // node tools/stamp-theme-head.cjs // Pages without site.css (door.html, plan-lab.html, the Google verification file) are skipped: they carry their own look. const fs = require('fs'), path = require('path'); const themehead = require(path.join(__dirname, '..', 'themehead.js')); const dir = path.join(__dirname, '..', 'public'); const OPEN = '', CLOSE = ''; let n = 0; for (const f of fs.readdirSync(dir).filter(f => f.endsWith('.html'))) { const p = path.join(dir, f); let html = fs.readFileSync(p, 'utf8'); if (!//, (m, a) => ''); const block = OPEN + themehead.tag() + CLOSE; if (html.includes(OPEN)) html = html.replace(new RegExp(OPEN + '[\\s\\S]*?' + CLOSE), block); else html = html.replace(/