Last active
June 12, 2025 01:02
-
-
Save HanSooloo/ce94c3974a39fe494524ea650489b234 to your computer and use it in GitHub Desktop.
Websocat test with CDP commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Inspired by https://gist.github.com/darrensapalo/6b8d71dffab0883818cd1facedaafbe0 | |
| TARGET_URL=ws://192.168.1.193:9222/devtools/page/1F7F5248167482D0C67811CDEA342940 | |
| COMMANDS=( 'DOM.getDocument {}' 'DOM.performSearch {"query": "\/\/yt-formatted-string[contains(@class, \"yt-mealbar-promo-renderer\")]"}' ) | |
| LOCALHOST=127.0.0.1 | |
| LOCALPORT=6543 | |
| WEBSOCAT=bin/websocat.aarch64-apple-darwin | |
| MESSAGE_COUNT=2 | |
| echo " β³οΈ Connecting to WebSocat..." | |
| ${WEBSOCAT} -v -t -E --jsonrpc-omit-jsonrpc jsonrpc:tcp-l:${LOCALHOST}:${LOCALPORT} reuse-raw:${TARGET_URL} --max-messages ${MESSAGE_COUNT} --max-messages-rev ${MESSAGE_COUNT}& | |
| WS_PID=$! | |
| echo " π Websocat connection created (${WS_PID})!" | |
| echo " ποΈ Getting current page DOM" | |
| echo "${COMMANDS[0]}" | nc ${LOCALHOST} ${LOCALPORT} | |
| echo " ποΈ Perform search on current page" | |
| echo "${COMMANDS[1]}" | nc ${LOCALHOST} ${LOCALPORT} | |
| echo " β Done!" | |
| echo " ποΈ Websocat connection disposed." | |
| kill ${WS_PID} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment