mirror of https://github.com/garrytan/gstack.git
fix: prefer account email over generic profile name in picker
Chrome profiles signed into a Google account often have generic display names like "Person 2". Check account_info[0].email first for a more readable label, falling back to profile.name as before. Addresses review feedback from @ngurney. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8a27c35729
commit
4d00241549
|
|
@ -152,15 +152,22 @@ export function listProfiles(browserName: string): ProfileEntry[] {
|
||||||
const cookiePath = path.join(browserDir, entry.name, 'Cookies');
|
const cookiePath = path.join(browserDir, entry.name, 'Cookies');
|
||||||
if (!fs.existsSync(cookiePath)) continue;
|
if (!fs.existsSync(cookiePath)) continue;
|
||||||
|
|
||||||
// Try to read display name from Preferences
|
// Try to read display name from Preferences.
|
||||||
|
// Prefer account email — signed-in Chrome profiles often have generic
|
||||||
|
// names like "Person 2" while the email is far more readable.
|
||||||
let displayName = entry.name;
|
let displayName = entry.name;
|
||||||
try {
|
try {
|
||||||
const prefsPath = path.join(browserDir, entry.name, 'Preferences');
|
const prefsPath = path.join(browserDir, entry.name, 'Preferences');
|
||||||
if (fs.existsSync(prefsPath)) {
|
if (fs.existsSync(prefsPath)) {
|
||||||
const prefs = JSON.parse(fs.readFileSync(prefsPath, 'utf-8'));
|
const prefs = JSON.parse(fs.readFileSync(prefsPath, 'utf-8'));
|
||||||
const profileName = prefs?.profile?.name;
|
const email = prefs?.account_info?.[0]?.email;
|
||||||
if (profileName && typeof profileName === 'string') {
|
if (email && typeof email === 'string') {
|
||||||
displayName = profileName;
|
displayName = email;
|
||||||
|
} else {
|
||||||
|
const profileName = prefs?.profile?.name;
|
||||||
|
if (profileName && typeof profileName === 'string') {
|
||||||
|
displayName = profileName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue