Files
nuc/playwriter-browser/auto-activate.sh
Alejandro Gutiérrez 390eda1595 Initial commit - NUC server configuration and docs
- CLAUDE.md: Server instructions and service reference
- docs/: Persistent documentation (architecture, guides)
- .artifacts/: Session-generated notes
- playwriter-browser/: Remote browser container config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 20:49:20 +00:00

65 lines
2.0 KiB
Bash

#!/bin/bash
# Auto-activate Playwriter extension by clicking its icon
# This script attempts to find and click the Playwriter extension icon
export DISPLAY=:99
echo "Attempting to auto-activate Playwriter extension..."
# Wait for Chrome to fully load
sleep 5
# Get Chrome window ID
CHROME_WINDOW=$(xdotool search --name "Chrome" | head -1)
if [ -z "$CHROME_WINDOW" ]; then
echo "Chrome window not found. Trying again..."
sleep 5
CHROME_WINDOW=$(xdotool search --name "Chrome" | head -1)
fi
if [ -n "$CHROME_WINDOW" ]; then
echo "Found Chrome window: $CHROME_WINDOW"
# Focus the Chrome window
xdotool windowactivate --sync $CHROME_WINDOW
sleep 1
# Navigate to a page first (extension won't activate on chrome:// pages)
xdotool key ctrl+l
sleep 0.5
xdotool type "https://www.google.com"
xdotool key Return
sleep 3
# The extension icon is typically in the top-right corner
# Get window geometry
GEOMETRY=$(xdotool getwindowgeometry $CHROME_WINDOW)
WIDTH=$(echo "$GEOMETRY" | grep "Geometry" | sed 's/.*Geometry: \([0-9]*\)x.*/\1/')
# Extension icons are usually ~100-200px from the right edge, ~50px from top
# Try multiple positions since exact location varies
echo "Attempting to click extension icon area..."
# Click positions to try (relative to window, near extension area)
for OFFSET in 100 130 160 190 220; do
X_POS=$((WIDTH - OFFSET))
Y_POS=50
echo "Trying position: $X_POS, $Y_POS"
xdotool mousemove --window $CHROME_WINDOW $X_POS $Y_POS
sleep 0.3
xdotool click 1
sleep 1
done
echo "Auto-activation attempts complete."
echo "If extension didn't activate, please click it manually via noVNC at:"
echo "http://localhost:6080/vnc.html"
else
echo "Could not find Chrome window. Please activate extension manually."
fi
# Alternative: Use Chrome DevTools Protocol to check extension status
# This would require more sophisticated scripting with CDP