Created
November 18, 2016 18:35
-
-
Save jscheel/152431a9b8d2753800fae6d2f536d50b to your computer and use it in GitHub Desktop.
Temporary hack to refresh the node inspector devtools without having to worry about the constantly-changing uuid. Only works in OSX. Use an iTerm2 trigger to run script automatically.
This file contains 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
#!/bin/bash | |
###################################################################################### | |
# regex for iterm2: | |
# chrome-devtools\:\/\/devtools\/remote\/serve\_file\/\@[a-f0-9]*\/inspector\.html\?experiments\=true\&v8only\=true\&ws\=localhost\:9229\/[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12} | |
# | |
# command for iterm2: | |
# /path/to/script/chrome-devtools-refresh.sh "\0" [-h "example.com"] | |
###################################################################################### | |
usage() { echo "Usage: $0 <devtools_url> [-h <replacement_hostname>]" 1>&2; exit 1; } | |
url=$1 | |
shift 1 | |
while getopts ":h:" opt; do | |
case $opt in | |
h) | |
replacement=$OPTARG | |
url="${url/localhost/$replacement}" | |
;; | |
\?) | |
echo "Invalid option -$OPTARG" | |
;; | |
esac | |
done | |
osascript <<EOD | |
tell application "Google Chrome" | |
set window_list to every window | |
set found to false | |
repeat with current_window in window_list | |
repeat with current_tab in tabs of current_window | |
set current_url to get URL of current_tab | |
if current_url starts with "chrome-devtools://devtools/remote/serve_file" then | |
set URL of current_tab to "$url" | |
set found to true | |
end if | |
end repeat | |
end repeat | |
if not found then | |
set devWindow to make new window | |
set URL of last tab in devWindow to "$url" | |
end if | |
display notification "devtool refreshed" | |
end tell | |
EOD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment