lhi_chrome_profile_utils
v1.0.26
Published
Professional utility for Chrome profile selection and management on macOS, designed for Puppeteer, MCP servers, and browser automation workflows
Maintainers
Readme
LHI Chrome Profile Utils
A professional utility for Chrome profile selection and management on macOS, designed for use with Puppeteer, MCP servers, and browser automation workflows.
Features
- 🔍 Profile Detection: Automatically detects and lists all Chrome profiles on macOS
- 🎯 Profile Selection: Interactive UI dialog for selecting Chrome profiles
- 🚀 Direct Chrome Launch: Launch Chrome directly with selected profile (recommended)
- 💾 Profile Data Export: Save profile information to JSON for later use
- 🔧 CLI Interface: Command-line tools for profile management
Installation
npm install lhi_chrome_profile_utilsUsage
Recommended: Direct Chrome Launch
For the best user experience with full profile features (avatar, theme, bookmarks), use direct Chrome launching:
const { spawn } = require('child_process');
const chromeProfileUtils = require('lhi_chrome_profile_utils');
// Select a profile via UI dialog
const { chromeUserDataPath, selectedProfilePath, userDataDir } = chromeProfileUtils.getSelectedProfile();
// Launch Chrome directly
const chromeArgs = [
`--profile-directory=${selectedProfilePath}`,
`--user-data-dir=${userDataDir}`,
'--disable-blink-features=AutomationControlled',
'https://mail.google.com'
];
const chromeProcess = spawn('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', chromeArgs, {
detached: true,
stdio: 'ignore'
});
chromeProcess.unref();Alternative: Puppeteer Integration
For automation testing (note: may not show full profile features):
const puppeteer = require('puppeteer');
const chromeProfileUtils = require('lhi_chrome_profile_utils');
// Get Puppeteer launch options with the selected profile
const puppeteerOptions = chromeProfileUtils.getPuppeteerLaunchOptions();
const browser = await puppeteer.launch(puppeteerOptions);As a Node.js Module
const chromeProfileUtils = require('lhi_chrome_profile_utils');
// List all Chrome profiles
const { chromeUserDataPath, profiles } = chromeProfileUtils.listProfiles();
console.log(`Found ${profiles.length} profiles`);
// Select a profile via UI dialog
const selectedProfilePath = chromeProfileUtils.selectProfile(profiles);
// Save profile data to JSON
chromeProfileUtils.saveProfilesJSON({ chromeUserDataPath, profiles }, './profiles.json');Command Line Interface
The package can be used directly from the command line:
# List all available Chrome profiles
npx lhi_chrome_profile_utils list
# Select a Chrome profile via dialog
npx lhi_chrome_profile_utils select
# Get Puppeteer launch options for selected profile
npx lhi_chrome_profile_utils puppeteer-options
# Export profile data to JSON file
npx lhi_chrome_profile_utils json [output_path]Important Notes
First-Time Login
When using direct Chrome launching (recommended approach):
- If this is your first time using a profile with this script, Chrome may require a one-time login
- After this initial login, subsequent launches will automatically use your saved profile
- This is normal Chrome security behavior when launching from a new context
Puppeteer vs Direct Launch
- Direct Chrome Launch (recommended): Full profile features, normal Chrome behavior
- Puppeteer Launch: Automation mode, may show warnings, limited profile features
Troubleshooting
If Chrome opens in a semi-incognito mode or doesn't show your profile:
- Use the direct Chrome launch approach instead of Puppeteer
- Ensure you've logged in at least once using the direct launch method
- Check that Chrome is the ARM-native version on Apple Silicon Macs
API Reference
listProfiles()
Lists all Chrome user profiles with detailed information.
Returns: Object with:
chromeUserDataPath: Path to Chrome user data directoryprofiles: Array of profile objects with details (email, name, theme color, etc.)
selectProfile(profiles)
Displays a macOS dialog for profile selection.
Parameters:
profiles: Array of profile objects fromlistProfiles()
Returns: String - The path of the selected profile
getSelectedProfile()
Combines listing and selection in one step.
Returns: Object with:
chromeUserDataPath: Path to Chrome user data directoryselectedProfilePath: Path of the selected profileuserDataDir: Full path to the selected profile directory
getPuppeteerLaunchOptions(headless = false)
Gets Puppeteer launch options for the selected Chrome profile.
Parameters:
headless: Boolean indicating whether to run in headless mode (default: false)
Returns: Object - Puppeteer launch options with user data directory
saveProfilesJSON(profileData, outputPath)
Saves profile data to a JSON file.
Parameters:
profileData: Profile data object fromlistProfiles()outputPath: Path where to save the JSON file
Returns: Boolean - Success status
Requirements
- macOS operating system
- Google Chrome installed
- Node.js 14.0.0 or higher
License
MIT © Lifehack Innovations LLC
