#!/bin/bash CHROME_DIR="$HOME/Library/Application Support/Google/Chrome" TMP_DIR="/tmp/chrome-debug-profile" CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" # Gather profiles + emails declare -a profiles emails for dir in "$CHROME_DIR/Default" "$CHROME_DIR"/Profile*; do [ -d "$dir" ] || continue prof=$(basename "$dir") email=$(grep -Eo '"email":\s*"[^"]+"' "$dir/Preferences" 2>/dev/null \ | head -n1 | cut -d'"' -f4) [ -z "$email" ] && email="(no email found)" profiles+=("$prof") emails+=("$email") done # Interactive menu echo "Select a Chrome profile for remote debugging:" PS3="Enter number: " options=() for i in "${!profiles[@]}"; do options+=("${profiles[i]} – ${emails[i]}") done select choice in "${options[@]}"; do if [ -n "$choice" ]; then idx=$((REPLY-1)) SELECTED_PROFILE="${profiles[idx]}" break else echo "Invalid selection, try again." fi done # Prepare temp dir rm -rf "$TMP_DIR" mkdir -p "$TMP_DIR" # 1) Copy encryption key + prefs cp "$CHROME_DIR/Local State" "$TMP_DIR/" cp "$CHROME_DIR/Secure Preferences" "$TMP_DIR/" 2>/dev/null || true # 2) Copy additional auth-related files cp "$CHROME_DIR/First Run" "$TMP_DIR/" 2>/dev/null || true cp "$CHROME_DIR/Consent To Send Stats" "$TMP_DIR/" 2>/dev/null || true cp -r "$CHROME_DIR/component_crx_cache" "$TMP_DIR/" 2>/dev/null || true # 3) Copy the chosen profile cp -r "$CHROME_DIR/$SELECTED_PROFILE" "$TMP_DIR/" # 3) Launch exec "$CHROME_BIN" \ --remote-debugging-port=9222 \ --user-data-dir="$TMP_DIR" \ --profile-directory="$SELECTED_PROFILE" \ --no-first-run \ --no-default-browser-check \ --no-sandbox \ --disable-field-trial-config \ --disable-background-timer-throttling \ --disable-backgrounding-occluded-windows \ --disable-back-forward-cache \ --disable-breakpad \ --disable-client-side-phishing-detection \ --disable-component-extensions-with-background-pages \ --disable-default-apps \ --disable-dev-shm-usage \ --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding,PlzDedicatedWorker \ --allow-pre-commit-input \ --disable-hang-monitor \ --disable-ipc-flooding-protection \ --disable-popup-blocking \ --disable-prompt-on-repost \ --disable-renderer-backgrounding \ --force-color-profile=srgb \ --metrics-recording-only \ --enable-automation \ --no-service-autorun \ --export-tagged-pdf \ --disable-search-engine-choice-screen \ --unsafely-disable-devtools-self-xss-warnings \ --enable-logging \ --v=3 \ --log-file="$(pwd)/chrome_debug.log" \ --crash-dumps-dir="$(pwd)/Crash Reports"