Skip to content

Instantly share code, notes, and snippets.

@syui
Created November 17, 2015 08:47
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 syui/eecf0c035ddee3848c47 to your computer and use it in GitHub Desktop.
Save syui/eecf0c035ddee3848c47 to your computer and use it in GitHub Desktop.
comic-walker.com-screenshot.
#!/usr/local/bin/zsh
case $1 in
"") pg=16 ;;
*) pg=$1 ;;
esac
tl=`osascript -e 'tell application "Google Chrome" to get NAME of active tab of first window' | cut -d ' ' -f -1`
ul=`osascript -e 'tell application "Google Chrome" to get URL of active tab of first window'`
ul=`echo ${ul:t} | cut -d = -f 4-`
echo $ul
fn=${tl}_${ul}
hd=~/Downloads/comicwalker
td=$hd/$ul
mkdir -p $td
cd $hd
## chrome window size
ssize=`osascript -e 'tell application "System Events" to get properties of first window of application process "Google Chrome"' | tr ":" "\n" | grep -A 1 -e position -e size | awk "NR==2"`
swidth=`echo $ssize | cut -d , -f 1`
shigh=$(expr `echo $ssize | cut -d , -f 2` + 100)
wsize=`osascript -e 'tell application "System Events" to get properties of first window of application process "Google Chrome"' | tr ":" "\n" | grep -A 1 -e position -e size | awk "NR==5"`
wwidth=`echo $wsize | cut -d , -f 1`
whigh=`echo $wsize | cut -d , -f 2`
#w-high=$(expr `echo $w-size | cut -d , -f 2` - 100)
for ((i=1;i<=${pg};i++ ))
do
#osascript -e 'tell application "Google Chrome" to activate'
if [ $i -le 9 ];then
echo "screencapture -R${swidth},${shigh},${wwidth},${whigh} $td/0${i}.png"
screencapture -R${swidth},${shigh},${wwidth},${whigh} $td/0${i}.png
#screencapture -R2602,-189,670,980 $td/0${i}.png
else
echo "screencapture -R${swidth},${shigh},${wwidth},${whigh} $td/${i}.png"
screencapture -R${swidth},${shigh},${wwidth},${whigh} $td/${i}.png
fi
osascript << EOF > /dev/null 2>&1
tell application "Google Chrome"
activate
tell application "System Events"
delay 0.3
key code 123
tell application "iTerm"
activate
end tell
end tell
end tell
EOF
sleep 1
done
apack ${fn}.zip $ul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment