-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·58 lines (48 loc) · 1.51 KB
/
install.sh
File metadata and controls
executable file
·58 lines (48 loc) · 1.51 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
#!/bin/bash
set -euo pipefail
# Registers the chrome-tap native messaging host with Chrome.
# Usage: ./install.sh <extension-id>
# or: ./install.sh (will prompt)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
HOST_DIR="$SCRIPT_DIR/host"
HOST_SCRIPT="$HOST_DIR/run.sh"
HOST_NAME="com.chrometap.host"
# macOS native messaging host location
MANIFEST_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
if [ $# -ge 1 ]; then
EXT_ID="$1"
else
read -rp "Extension ID (from chrome://extensions): " EXT_ID
fi
if [ -z "$EXT_ID" ]; then
echo "Error: extension ID required" >&2
exit 1
fi
# Ensure host script is executable
chmod +x "$HOST_SCRIPT"
# Install npm deps if needed
if [ ! -d "$HOST_DIR/node_modules" ]; then
echo "Installing host dependencies..."
(cd "$HOST_DIR" && npm install --production)
fi
# Create manifest directory
mkdir -p "$MANIFEST_DIR"
# Write native messaging host manifest
cat > "$MANIFEST_DIR/$HOST_NAME.json" << EOF
{
"name": "$HOST_NAME",
"description": "chrome-tap native messaging host",
"path": "$HOST_SCRIPT",
"type": "stdio",
"allowed_origins": ["chrome-extension://$EXT_ID/"]
}
EOF
echo "Installed native messaging host manifest:"
echo " $MANIFEST_DIR/$HOST_NAME.json"
echo " Extension ID: $EXT_ID"
echo " Host path: $HOST_SCRIPT"
echo ""
echo "Next steps:"
echo " 1. Load extension from $SCRIPT_DIR/extension in chrome://extensions"
echo " 2. Token will be at ~/.chrome-tap/token"
echo ' 3. Test: websocat "ws://127.0.0.1:9867?token=$(cat ~/.chrome-tap/token)"'