Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
JavaScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#!/usr/bin/env node// prep-chrome — make the browser look like a clean, default browser before we film it.//// node bin/prep-chrome.mjs [--dir ~/.chrome-cdp]//// `reel` films the WINDOW, so Chrome's own furniture is in every frame: the tab// strip, the URL bar, the bookmarks bar, and whatever theme the profile happens// to wear. A tutorial should be shot in a browser that looks like the viewer's,// not like ours — someone else's bookmarks and a purple theme read as "this was// recorded on a person's laptop", which is exactly the impression to avoid.//// These are PROFILE preferences, not command-line flags — Chrome has no switch// for either — so they are patched in the Preferences JSON. That is only safe// while Chrome is CLOSED: it holds prefs in memory and rewrites the file on exit,// so editing a running profile is silently undone the moment it quits.
import { execFileSync } from "node:child_process";import { existsSync, readFileSync, writeFileSync } from "node:fs";import { homedir } from "node:os";import { join } from "node:path";
const i = process.argv.indexOf("--dir");const DIR = i === -1 ? join(homedir(), ".chrome-cdp") : process.argv[i + 1];const PREFS = join(DIR, "Default", "Preferences");
try { execFileSync("pkill", ["-f", `user-data-dir=${DIR}`]); } catch {}await new Promise((r) => setTimeout(r, 1500)); // let it flush and exit
if (!existsSync(PREFS)) { console.error(`no profile at ${PREFS}`); process.exit(1);}
const p = JSON.parse(readFileSync(PREFS, "utf8"));
// Bookmarks bar off — someone's bookmarks have no place in a product tutorial.p.bookmark_bar = { ...(p.bookmark_bar || {}), show_on_all_tabs: false };
// Default theme. A custom theme is an installed extension plus a pinned set of// colours; clearing both is what actually returns Chrome to stock, and either one// alone leaves the window tinted.if (p.extensions?.theme) p.extensions.theme = { id: "", use_system: false };delete p.browser?.theme;p.browser = { ...(p.browser || {}), theme: { user_color_scheme: 0 } };delete p.autogenerated?.theme;
writeFileSync(PREFS, JSON.stringify(p));console.log(`✓ ${DIR}: bookmarks bar off, default theme`);