Chrome headless mode

Chrome

Requirement

Chrome version 59+

command alias (or edit .bash_profile)

1
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu"
1
chrome --print-to-pdf https://httpbin.org
1
2
chrome --screenshot https://httpbin.org
chrome --screenshot --window-size=1280,1696 https://httpbin.org

REPL mode (read-eval-print loop) - samething like javascript console

1
2
3
4
chrome --repl https://httpbin.org

>> window.innerHeight
{"result":{"description":"600","type":"number","value":600}}

Reference

https://developers.google.com/web/updates/2017/04/headless-chrome
https://en.wikipedia.org/wiki/Headless_browser