3e3b8d529c
- Change nav open and open-wait to avoid activating newly created tabs unless --focus is explicitly requested. - Send background=true for default opens so older or remote extensions also avoid stealing focus even if they ignore the new focus flag. - Remove the redundant --bg flag from navigation and search CLI commands now that no-focus/background behavior is the default. - Thread focus support through the sync SDK, async SDK, tab helpers, and workflow decorators. - Update README and demo usage to document the new default and --focus opt-in. - Bump package and extension metadata to 0.12.3. - Add regression coverage for CLI help, wire payloads, and extension behavior.
89 lines
2.0 KiB
Bash
Executable File
89 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# browser-cli Bash demo
|
|
# ----------------------
|
|
# Shows how to drive your running browser from a shell script.
|
|
#
|
|
# Run with:
|
|
# bash examples/demo.sh
|
|
#
|
|
# Press ENTER to advance each step, or set AUTO=1 to run without pausing:
|
|
# AUTO=1 bash examples/demo.sh
|
|
|
|
CLI="uv run browser-cli"
|
|
DELAY=2 # seconds between steps in auto mode
|
|
|
|
pause() {
|
|
echo ""
|
|
if [ "${AUTO:-0}" = "1" ]; then
|
|
sleep "$DELAY"
|
|
else
|
|
read -rp " [press ENTER to continue] "
|
|
fi
|
|
echo ""
|
|
}
|
|
|
|
header() {
|
|
echo ""
|
|
echo "────────────────────────────────────"
|
|
echo " $1"
|
|
echo "────────────────────────────────────"
|
|
}
|
|
|
|
|
|
header "1/8 · Open tabs"
|
|
$CLI tabs list
|
|
pause
|
|
|
|
header "2/8 · Tab count & windows"
|
|
$CLI tabs count
|
|
echo ""
|
|
$CLI windows list
|
|
pause
|
|
|
|
header "3/8 · Create 'research' group and open URLs into it"
|
|
$CLI groups create research
|
|
echo ""
|
|
$CLI nav open https://example.com --group research
|
|
$CLI nav open https://wikipedia.org --group research
|
|
echo ""
|
|
echo " Tabs are now open inside the 'research' group in your browser."
|
|
pause
|
|
|
|
header "4/8 · Tab hygiene — close duplicates, sort by domain"
|
|
$CLI tabs close --duplicates
|
|
echo ""
|
|
$CLI tabs sort --by domain
|
|
pause
|
|
|
|
header "5/8 · Find tabs by URL pattern or title"
|
|
$CLI tabs filter wikipedia
|
|
echo ""
|
|
$CLI tabs query "example"
|
|
pause
|
|
|
|
header "6/8 · DOM and content extraction (active tab)"
|
|
echo " Switching to the example.com tab first..."
|
|
$CLI nav focus example.com
|
|
echo ""
|
|
echo " Page headings:"
|
|
$CLI dom text h1
|
|
echo ""
|
|
echo " Links on the page:"
|
|
$CLI extract links
|
|
pause
|
|
|
|
header "7/8 · Session management"
|
|
$CLI session save before-meeting
|
|
echo ""
|
|
echo " Restore later with:"
|
|
echo " $CLI session load before-meeting"
|
|
echo ""
|
|
echo " Compare two sessions with:"
|
|
echo " $CLI session diff before-meeting after-meeting"
|
|
pause
|
|
|
|
header "8/8 · Merge all windows into one"
|
|
$CLI tabs merge-windows
|
|
echo ""
|
|
echo "Done!"
|