Files
artcraft/script/launch_dev_browser.sh
T

91 lines
3.7 KiB
Bash
Executable File

#!/bin/bash
declare -r entropy=$(xxd -l16 -ps /dev/urandom)
#declare -r CHROME_DIR="${HOME}/.chromeDevTemp"
declare -r chrome_dir="/tmp/chrome/${entropy}"
# See flags available and documentation:
# https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/common/chrome_switches.cc
# https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
# https://peter.sh/experiments/chromium-command-line-switches/
# NB: Creating the directory first seems to block process start.
# Perhaps this is the wrong chmod ownership flags.
#mkdir -p $CHROME_DIR
#--auto-open-devtools-for-tabs="true" \
#--devtools-flags="" \
# TODO(bt): Math to determine better window placement.
# Flags reference:
# --allow-running-insecure-content Allow HTTPS pages to load HTTP resources (mixed content).
# --disable-features=ChromeLabs, Disable Chrome Labs experiments UI and the
# DefaultBrowserPrompt feature-flag-based default browser prompt.
# --disable-site-isolation-trials Disable site isolation (allows cross-origin iframes
# to share process, useful for local dev).
# --disable-web-security Disable same-origin policy. Required for local dev
# where the frontend talks to a different-origin API.
# --ignore-certificate-errors Accept self-signed / invalid TLS certs.
# --no-default-browser-check Skip the "set as default browser" check on startup.
# --no-first-run Suppress the "Welcome to Google Chrome" first-run
# dialog (default browser checkbox, crash reporting, etc.).
# --install-autogenerated-theme Set a custom window color so the dev browser is
# visually distinct from your normal Chrome.
# --unsafely-treat-insecure-origin-as-secure
# Treat the given HTTP origin as secure. Required for
# APIs like getUserMedia() / navigator.mediaDevices
# which need a "secure context".
# --user-data-dir Use a throwaway profile directory so dev sessions
# don't pollute your real Chrome profile.
# --guest (Mac only) Launch in guest mode — no Google login screen.
# --window-position / --window-size Place the dev window predictably on screen.
launch_linux() {
chromium \
--allow-running-insecure-content \
--disable-features=ChromeLabs,DefaultBrowserPrompt \
--disable-site-isolation-trials \
--disable-web-security \
--ignore-certificate-errors \
--no-default-browser-check \
--no-first-run \
--install-autogenerated-theme="100,150,255" \
--unsafely-treat-insecure-origin-as-secure="http://localhost:5173" \
--user-data-dir="${chrome_dir}" \
--window-position=1200,300 \
--window-size=1500,1700 \
http://localhost:5173
}
launch_mac() {
open -na "Google Chrome" --args \
--disable-features=ChromeLabs,DefaultBrowserPrompt \
--disable-site-isolation-trials \
--disable-web-security \
--ignore-certificate-errors \
--no-default-browser-check \
--no-first-run \
--install-autogenerated-theme="100,150,255" \
--unsafely-treat-insecure-origin-as-secure="http://localhost:5173" \
--user-data-dir="${chrome_dir}" \
--window-position=1200,300 \
--window-size=1500,1700 \
--guest \
http://localhost:5173
}
case $OSTYPE in
linux*)
launch_linux
;;
darwin*)
launch_mac
;;
*)
echo "Unknown OS"
;;
esac