Skip to content

Commit b2e54a6

Browse files
authored
Add chrome-prt function to launch Chrome with PRT features (#1156)
- Introduces a new `chrome-prt` function in the `install.sh` script to simplify launching Chrome (Stable/Dev/Canary) with Probabilistic Reveal Token (PRT) features enabled. Includes OS-specific binary detection, error handling, and temporary data directory management. - Channel selection: - You can explicitly choose the channel using one of: - `chrome-prt --stable` - `chrome-prt --dev` - `chrome-prt --canary` - If no channel is specified, the command auto-selects the first available in this order: Canary > Dev > Stable.
1 parent 7e956b5 commit b2e54a6

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

bin/install.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,111 @@ chrome-pat-ps() {
11281128
--enable-privacy-sandbox-ads-apis
11291129
}
11301130
1131+
# Launch desktop Chrome (Stable/Dev/Canary) with PRT features enabled
1132+
chrome-prt() {
1133+
local requested_channel=""
1134+
if [[ \$# -gt 0 ]]; then
1135+
case "\$1" in
1136+
--stable) requested_channel="stable"; shift;;
1137+
--dev) requested_channel="dev"; shift;;
1138+
--canary) requested_channel="canary"; shift;;
1139+
--*) echo "Error: Unknown option '\$1'. Use --stable, --dev, or --canary." >&2; return 1;;
1140+
esac
1141+
fi
1142+
1143+
local os_name
1144+
os_name=\$(uname -s)
1145+
1146+
# Determine available Chrome binaries per OS
1147+
local chrome_stable=""
1148+
local chrome_dev=""
1149+
local chrome_canary=""
1150+
1151+
if [[ "\$os_name" == "Darwin" ]]; then
1152+
chrome_stable="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
1153+
chrome_dev="/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev"
1154+
chrome_canary="/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
1155+
elif [[ "\$os_name" == "Linux" ]]; then
1156+
# Common Linux binary names
1157+
chrome_stable=\$(command -v google-chrome-stable || command -v google-chrome || true)
1158+
# Dev builds can be "google-chrome-unstable" or "google-chrome-dev"
1159+
chrome_dev=\$(command -v google-chrome-unstable || command -v google-chrome-dev || true)
1160+
chrome_canary=\$(command -v google-chrome-canary || true)
1161+
else
1162+
echo "Error: Unsupported OS '\$os_name'." >&2
1163+
return 1
1164+
fi
1165+
1166+
# Helper to test existence
1167+
_exists() {
1168+
if [[ -z "\$1" ]]; then return 1; fi
1169+
[[ -x "\$1" ]]
1170+
}
1171+
1172+
# Select channel
1173+
local chrome_binary=""
1174+
if [[ -n "\$requested_channel" ]]; then
1175+
case "\$requested_channel" in
1176+
stable)
1177+
if _exists "\$chrome_stable"; then chrome_binary="\$chrome_stable"; else echo "Error: Requested Chrome Stable either not installed or not found in the system." >&2; return 1; fi;;
1178+
dev)
1179+
if _exists "\$chrome_dev"; then chrome_binary="\$chrome_dev"; else echo "Error: Requested Chrome Dev either not installed or not found in the system." >&2; return 1; fi;;
1180+
canary)
1181+
if _exists "\$chrome_canary"; then chrome_binary="\$chrome_canary"; else echo "Error: Requested Chrome Canary either not installed or not found in the system." >&2; return 1; fi;;
1182+
esac
1183+
else
1184+
# Default precedence: Canary > Dev > Stable
1185+
if _exists "\$chrome_canary"; then
1186+
chrome_binary="\$chrome_canary"
1187+
elif _exists "\$chrome_dev"; then
1188+
chrome_binary="\$chrome_dev"
1189+
elif _exists "\$chrome_stable"; then
1190+
chrome_binary="\$chrome_stable"
1191+
else
1192+
echo "Error: No suitable Chrome installation found (Stable/Dev/Canary)." >&2
1193+
return 1
1194+
fi
1195+
fi
1196+
1197+
# Create a temporary directory for user data
1198+
local data_dir
1199+
data_dir=\$(mktemp -d "/tmp/chrome_testing_data_dir.XXXXXXXXXX") || { echo "Error: Failed to create temporary user data directory." >&2; return 1; }
1200+
1201+
echo "Launching Chrome..."
1202+
echo " Executable: \$chrome_binary"
1203+
echo " Data Directory: \$data_dir"
1204+
if [[ \$# -gt 0 ]]; then
1205+
echo " Arguments: \$@"
1206+
fi
1207+
1208+
local common_flags=(
1209+
--user-data-dir="\$data_dir"
1210+
--disable-sync
1211+
--no-default-browser-check
1212+
--no-first-run
1213+
--silent-debugger-extension-api
1214+
--disable-infobars
1215+
--enable-features="EnableIpPrivacyProxy,MaskedDomainList,EnableProbabilisticRevealTokens:ProbabilisticRevealTokensAddHeaderToProxiedRequests/true/EnableProbabilisticRevealTokensForNonProxiedRequests/true/BypassProbabilisticRevealTokenRegistry/true/ProbabilisticRevealTokenServerPath/%2Fv1%2Ftestissueprts%2F,EnableFingerprintingProtectionFilter,EnableFingerprintingProtectionFilterInIncognito,EnableIpPrivacyProxy:IpPrivacyBsaEnablePrivacyPass/true/IpPrivacyUseProxyChains/true/IpPrivacyEnableIppInDevTools/true"
1216+
--install-autogenerated-theme='15,157,88'
1217+
)
1218+
1219+
if [[ "\$os_name" == "Darwin" || "\$os_name" == "Linux" ]]; then
1220+
"\$chrome_binary" "\${common_flags[@]}" "\$@" "https://example.com/?psat_cdp=on" >/dev/null 2>&1 &
1221+
else
1222+
echo "Error: Unsupported OS '\$os_name' for chrome-prt." >&2
1223+
rm -rf "\$data_dir"
1224+
return 1
1225+
fi
1226+
1227+
local chrome_pid=\$!
1228+
(
1229+
while ps -p \$chrome_pid > /dev/null; do sleep 5; done
1230+
rm -rf "\$data_dir"
1231+
) &
1232+
1233+
echo "Chrome launched in background (PID: \$chrome_pid)."
1234+
}
1235+
11311236
EOF
11321237

11331238
# Make the generated script executable
@@ -1163,6 +1268,7 @@ display_outro() {
11631268
echo -e "${CYAN}chrome-3pcd-ps ${RESET}: Chrome with 3PCD and PSAT extension"
11641269
echo -e "${CYAN}chrome-pat ${RESET}: Chrome with Private Advertising Testing"
11651270
echo -e "${CYAN}chrome-pat-ps ${RESET}: Chrome with Private Advertising Testing and PSAT"
1271+
echo -e "${CYAN}chrome-prt ${RESET}: Desktop Chrome with PRT features (use --stable/--dev/--canary)"
11661272

11671273
print_header "=============================================="
11681274
}

0 commit comments

Comments
 (0)