mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-20 17:02:53 -04:00
chrome launch script (#1371)
This commit is contained in:
@@ -10,22 +10,60 @@ declare -r chrome_dir="/tmp/chrome/${entropy}"
|
||||
# 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
|
||||
# Seed the profile with DevTools preferences before Chrome starts.
|
||||
# This sets: dock position = bottom, default panel = network.
|
||||
# Chrome stores these in <user-data-dir>/Default/Preferences.
|
||||
seed_devtools_preferences() {
|
||||
local prefs='{"devtools":{"preferences":{"currentDockState":"\"bottom\"","panel-selected-tab":"\"network\""}}}'
|
||||
|
||||
#--auto-open-devtools-for-tabs="true" \
|
||||
#--devtools-flags="" \
|
||||
# Seed both Default and Guest Profile — Chrome uses Guest Profile when
|
||||
# launched with --guest, and Default otherwise.
|
||||
for profile_name in "Default" "Guest Profile"; do
|
||||
local prefs_dir="${chrome_dir}/${profile_name}"
|
||||
mkdir -p "${prefs_dir}"
|
||||
echo "${prefs}" > "${prefs_dir}/Preferences"
|
||||
done
|
||||
}
|
||||
|
||||
# TODO(bt): Math to determine better window placement.
|
||||
|
||||
# Flags reference:
|
||||
# --auto-open-devtools-for-tabs Open DevTools automatically for every tab on launch.
|
||||
# Dock position and default panel are set via seeded
|
||||
# preferences (see seed_devtools_preferences above).
|
||||
# --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() {
|
||||
seed_devtools_preferences
|
||||
chromium \
|
||||
--auto-open-devtools-for-tabs \
|
||||
--allow-running-insecure-content \
|
||||
--disable-features=ChromeLabs \
|
||||
--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}" \
|
||||
@@ -35,16 +73,15 @@ launch_linux() {
|
||||
}
|
||||
|
||||
launch_mac() {
|
||||
# See https://stackoverflow.com/a/58658101
|
||||
# NB: '7001' port is being chosen because something on the system is hogging port 7000.
|
||||
# chrome://flags/#unsafely-treat-insecure-origin-as-secure - allow microphone recording
|
||||
# otherwise getUserMedia() / navigator.mediaDevices will not function
|
||||
# --guest: no Google login screen
|
||||
seed_devtools_preferences
|
||||
open -na "Google Chrome" --args \
|
||||
--disable-features=ChromeLabs \
|
||||
--auto-open-devtools-for-tabs \
|
||||
--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}" \
|
||||
|
||||
Reference in New Issue
Block a user