chore: add reliable local business run scripts

This commit is contained in:
kris
2026-03-21 02:59:52 +08:00
parent c09a976628
commit 39216d18b4
7 changed files with 156 additions and 54 deletions

39
scripts/cleanup_debug_ui.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/sh
set -eu
PORT="${1:-3618}"
SCRIPT_PATH="/Users/kris/code/StoryForge-gitea/scripts/douyin-browser-capture/control_panel.mjs"
lsof -tiTCP:"$PORT" -sTCP:LISTEN | xargs -r kill || true
osascript -e 'tell application "Terminal"' \
-e 'if it is running then' \
-e 'repeat with w in windows' \
-e 'set shouldClose to false' \
-e 'repeat with t in tabs of w' \
-e 'try' \
-e 'set tabText to contents of t' \
-e 'if tabText contains "'"$SCRIPT_PATH"'" then set shouldClose to true' \
-e 'end try' \
-e 'end repeat' \
-e 'if shouldClose then close w saving no' \
-e 'end repeat' \
-e 'end if' \
-e 'end tell' >/dev/null 2>&1 || true
for app in "Google Chrome" "Brave Browser" "Arc" "Safari"; do
osascript -e 'try' \
-e 'tell application "'"$app"'"' \
-e 'repeat with w in windows' \
-e 'repeat with i from (count of tabs of w) to 1 by -1' \
-e 'try' \
-e 'set tabUrl to URL of tab i of w' \
-e 'if tabUrl contains "127.0.0.1:'"$PORT"'" then close tab i of w' \
-e 'end try' \
-e 'end repeat' \
-e 'end repeat' \
-e 'end tell' \
-e 'end try' >/dev/null 2>&1 || true
done
echo "debug ui cleaned: port $PORT"