forked from jorrit-stack/Raycast-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbolt-admin.sh
More file actions
executable file
·55 lines (46 loc) · 1.55 KB
/
bolt-admin.sh
File metadata and controls
executable file
·55 lines (46 loc) · 1.55 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
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title bolt-admin
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🤖
# @raycast.argument1 { "type": "text", "placeholder": "UserID or Email" }
# Documentation:
# @raycast.description bolt-admin-email-lookup
# @raycast.author jorrit_harmamny
# @raycast.authorURL https://raycast.com/jorrit_harmamny
input="$1"
if [[ "$input" =~ ^[0-9]+$ ]]; then
# If input is only digits, treat as ID
url="https://stackblitz.com/admin/users?q%5Bid_eq%5D=${input}&commit=Filter&order=id_desc"
else
# Otherwise, treat as email
encoded=$(python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$input")
url="https://stackblitz.com/admin/users?q%5Bby_email_address%5D=${encoded}&commit=Filter&order=id_desc"
fi
open "$url"
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
COPY_USER_ID_SCRIPT="$SCRIPT_DIR/copy-user-id-from-browser.sh"
# Give the browser time to load, then retry extraction a few times if needed.
attempts=0
max_attempts=4
sleep_between=1.5
if [[ -x "$COPY_USER_ID_SCRIPT" ]]; then
sleep "$sleep_between"
while (( attempts < max_attempts )); do
"$COPY_USER_ID_SCRIPT"
status=$?
if (( status == 0 )); then
exit 0
fi
(( attempts++ ))
if (( status != 2 || attempts == max_attempts )); then
echo "copy-user-id-from-browser.sh failed with status $status" >&2
exit $status
fi
sleep "$sleep_between"
done
else
echo "Warning: copy-user-id-from-browser.sh not found or not executable at $COPY_USER_ID_SCRIPT" >&2
fi