-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestbed.command
More file actions
executable file
·66 lines (59 loc) · 2.28 KB
/
Copy pathtestbed.command
File metadata and controls
executable file
·66 lines (59 loc) · 2.28 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
#!/bin/bash
# Launches an isolated Chrome with ModHeader loaded, so you can build test configs
# by hand and then export them.
#
# ./testbed.command open the testbed browser
# ./testbed.command --export export whatever is currently in it
#
# The browser profile persists at .work/testbed-profile, so configs you create
# survive between runs.
set -e
cd "$(dirname "$0")"
EXTENSION="$PWD/.work/ModHeader-Clean"
PROFILE="$PWD/.work/testbed-profile"
BROWSERS="$PWD/.work/browsers"
if [ "$1" = "--export" ]; then
# --browser restricts the scan to the testbed profile, which findModHeaderStores
# labels by its directory name, so real browser profiles are left out.
exec node src/cli.mjs \
--user-data-dir "$PROFILE" \
--browser "$(basename "$PROFILE")" \
--out-dir "$PWD/testbed-export"
fi
# Chrome 137+ ignores --load-extension, so this needs a Chrome for Testing build.
if [ ! -d "$BROWSERS/chrome" ]; then
echo "Downloading Chrome for Testing (one time, ~150MB)..."
npx -y @puppeteer/browsers install chrome@stable --path "$BROWSERS"
fi
CHROME=$(find "$BROWSERS/chrome" -type f \
\( -name "Google Chrome for Testing" -o -name "chrome" \) -perm -u+x | head -1)
if [ -z "$CHROME" ]; then
echo "Could not find a Chrome for Testing binary under $BROWSERS/chrome"
exit 1
fi
if [ ! -f "$EXTENSION/manifest.json" ]; then
echo "Fetching ModHeader (community build with the tracking SDK removed)..."
git clone --depth 1 https://github.com/T1sts/ModHeader-Clean.git "$EXTENSION"
fi
# The extension id is derived from the extension's absolute path.
EXT_ID=$(node -e "
const {createHash}=require('crypto');
const d=createHash('sha256').update(process.argv[1],'utf8').digest('hex').slice(0,32);
console.log([...d].map(c=>String.fromCharCode(parseInt(c,16)+97)).join(''));
" "$EXTENSION")
mkdir -p "$PROFILE"
echo "Profile: $PROFILE"
echo "ModHeader: chrome-extension://$EXT_ID/src/app_v1.html"
echo
echo "Build whatever profiles you want, then quit the browser and run:"
echo " ./testbed.command --export"
echo
"$CHROME" \
--user-data-dir="$PROFILE" \
--load-extension="$EXTENSION" \
--disable-extensions-except="$EXTENSION" \
--no-first-run \
--no-default-browser-check \
--disable-background-networking \
--disable-sync \
"chrome-extension://$EXT_ID/src/app_v1.html"