-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathlaunch_dev_browser.sh
More file actions
executable file
·105 lines (94 loc) · 4.55 KB
/
Copy pathlaunch_dev_browser.sh
File metadata and controls
executable file
·105 lines (94 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/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/
# 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\""}}}'
# 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,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() {
seed_devtools_preferences
open -na "Google Chrome" --args \
--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}" \
--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