Skip to content

Commit 9c06bdb

Browse files
vveerrggclaude
andcommitted
feat: add Firefox screenshot capture script for AMO listing
Guided semi-automated script that walks through each extension state and captures the Firefox window at 1280x800 for AMO store screenshots. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 74c19a1 commit 9c06bdb

1 file changed

Lines changed: 204 additions & 0 deletions

File tree

dev/qa/capture-firefox.sh

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Firefox Screenshot Capture for AMO Listing
5+
# Guides you through each screenshot, captures the Firefox window.
6+
#
7+
# Usage:
8+
# ./capture-firefox.sh # Capture all screenshots
9+
# ./capture-firefox.sh --list # Show screenshot IDs
10+
# ./capture-firefox.sh home # Capture just one
11+
#
12+
# Prerequisites:
13+
# - Firefox running with NostrKey loaded (about:debugging)
14+
# - Extension popup visible (click toolbar icon)
15+
16+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
17+
SCREENSHOTS_DIR="$SCRIPT_DIR/screenshots/firefox"
18+
PREVIOUS_DIR="$SCREENSHOTS_DIR/.previous"
19+
20+
# AMO recommended: 1280x800 or similar. We capture the full Firefox window.
21+
WINDOW_WIDTH=1280
22+
WINDOW_HEIGHT=800
23+
24+
# Screenshots to capture — id, filename, instruction
25+
SCREENSHOTS=(
26+
"home|home.png|Home tab — show the profile list with a profile selected"
27+
"apps|apps.png|Apps tab — show the Bunker URL card and Permissions"
28+
"apps-bunker|apps-bunker-active.png|Apps tab — with an active Bunker URL (click Create Bunker URL first)"
29+
"vault|vault.png|Vault tab — show the vault view"
30+
"relays|relays.png|Relays tab — show relay list"
31+
"settings|settings.png|Settings tab — show settings"
32+
"locked|locked.png|Lock screen — lock the vault first (click the lock icon)"
33+
"signing|signing-prompt.png|Signing prompt — visit a Nostr site and trigger a sign request"
34+
)
35+
36+
die() { echo "ERROR: $*" >&2; exit 1; }
37+
38+
# --- Position Firefox window ---
39+
position_firefox() {
40+
osascript -e "
41+
tell application \"Firefox\"
42+
activate
43+
if (count of windows) > 0 then
44+
set bounds of window 1 to {0, 25, $WINDOW_WIDTH, $((WINDOW_HEIGHT + 25))}
45+
end if
46+
end tell
47+
" 2>/dev/null || echo "Warning: Could not position Firefox window. Position manually."
48+
}
49+
50+
# --- Capture Firefox window ---
51+
capture_window() {
52+
local output="$1"
53+
# Get Firefox window ID
54+
local wid
55+
wid=$(osascript -e '
56+
tell application "System Events"
57+
tell process "Firefox"
58+
set w to window 1
59+
return id of w
60+
end tell
61+
end tell
62+
' 2>/dev/null || echo "")
63+
64+
if [ -n "$wid" ]; then
65+
screencapture -l "$wid" -o "$output"
66+
else
67+
# Fallback: interactive window capture
68+
echo " Could not get window ID. Click the Firefox window to capture."
69+
screencapture -w -o "$output"
70+
fi
71+
}
72+
73+
# --- List screenshots ---
74+
list_screens() {
75+
echo "Available screenshot IDs:"
76+
echo ""
77+
for entry in "${SCREENSHOTS[@]}"; do
78+
IFS='|' read -r id filename instruction <<< "$entry"
79+
echo " $id$instruction"
80+
done
81+
}
82+
83+
# --- Rotate previous ---
84+
rotate() {
85+
if [ -d "$SCREENSHOTS_DIR" ] && [ "$(ls -A "$SCREENSHOTS_DIR" 2>/dev/null | grep -v '^\.')" ]; then
86+
echo "Rotating current screenshots to .previous/..."
87+
rm -rf "$PREVIOUS_DIR"
88+
mkdir -p "$PREVIOUS_DIR"
89+
mv "$SCREENSHOTS_DIR"/*.png "$PREVIOUS_DIR"/ 2>/dev/null || true
90+
fi
91+
mkdir -p "$SCREENSHOTS_DIR"
92+
}
93+
94+
# --- Capture one ---
95+
capture_one() {
96+
local id="$1"
97+
local found=false
98+
99+
for entry in "${SCREENSHOTS[@]}"; do
100+
IFS='|' read -r eid filename instruction <<< "$entry"
101+
if [ "$eid" = "$id" ]; then
102+
found=true
103+
echo ""
104+
echo "[$eid] $instruction"
105+
echo ""
106+
read -r -p " Set up the view, then press ENTER to capture (or 's' to skip): " choice
107+
if [ "$choice" = "s" ] || [ "$choice" = "S" ]; then
108+
echo " Skipped."
109+
return
110+
fi
111+
local output="$SCREENSHOTS_DIR/$filename"
112+
capture_window "$output"
113+
echo " Saved: $output"
114+
return
115+
fi
116+
done
117+
118+
if [ "$found" = false ]; then
119+
die "Unknown screenshot ID: $id (use --list to see available IDs)"
120+
fi
121+
}
122+
123+
# --- Main ---
124+
main() {
125+
local target_id=""
126+
local do_rotate=true
127+
128+
while [ $# -gt 0 ]; do
129+
case "$1" in
130+
--list)
131+
list_screens
132+
exit 0
133+
;;
134+
--no-rotate)
135+
do_rotate=false
136+
shift
137+
;;
138+
--help|-h)
139+
echo "Usage: capture-firefox.sh [OPTIONS] [SCREEN_ID]"
140+
echo ""
141+
echo "Captures Firefox screenshots for AMO listing."
142+
echo "Guides you through each state, then captures the Firefox window."
143+
echo ""
144+
echo "Options:"
145+
echo " --list Show available screenshot IDs"
146+
echo " --no-rotate Don't rotate previous screenshots"
147+
echo " --help Show this help"
148+
echo ""
149+
echo "Prerequisites:"
150+
echo " 1. Firefox running with NostrKey loaded via about:debugging"
151+
echo " 2. Click the NostrKey toolbar icon to open the popup"
152+
echo ""
153+
echo "Examples:"
154+
echo " capture-firefox.sh # Guided capture of all"
155+
echo " capture-firefox.sh home # Just one screenshot"
156+
echo " capture-firefox.sh --no-rotate # Don't move previous/"
157+
exit 0
158+
;;
159+
-*)
160+
die "Unknown option: $1"
161+
;;
162+
*)
163+
target_id="$1"
164+
shift
165+
;;
166+
esac
167+
done
168+
169+
echo "=== NostrKey Firefox Screenshot Capture ==="
170+
echo ""
171+
echo "Make sure:"
172+
echo " 1. Firefox is running with NostrKey loaded"
173+
echo " 2. The extension popup is open (click toolbar icon)"
174+
echo ""
175+
176+
# Position Firefox
177+
position_firefox
178+
echo "Firefox window positioned to ${WINDOW_WIDTH}x${WINDOW_HEIGHT}"
179+
echo ""
180+
181+
if [ -n "$target_id" ]; then
182+
mkdir -p "$SCREENSHOTS_DIR"
183+
capture_one "$target_id"
184+
else
185+
if [ "$do_rotate" = true ]; then
186+
rotate
187+
else
188+
mkdir -p "$SCREENSHOTS_DIR"
189+
fi
190+
191+
echo "Capturing ${#SCREENSHOTS[@]} screenshots..."
192+
for entry in "${SCREENSHOTS[@]}"; do
193+
IFS='|' read -r id _ _ <<< "$entry"
194+
capture_one "$id"
195+
done
196+
fi
197+
198+
echo ""
199+
echo "Done! Screenshots saved to: $SCREENSHOTS_DIR"
200+
echo ""
201+
echo "To review: open $SCREENSHOTS_DIR"
202+
}
203+
204+
main "$@"

0 commit comments

Comments
 (0)