How can I launch Chrome with flags from command li

2019-03-09 21:27发布

I am developing a WebGL driven application and I want to launch chrome like this from the command line:

open -a Google\ Chrome --args --disable-web-security

I just don't want to have to type that in every single time. Is there a way to easily turn that into a one word command? I am using a mac if it matters.

4条回答
放荡不羁爱自由
2楼-- · 2019-03-09 21:56

The Easiest way to Launch Chrome with flags in MAC using terminal is :

'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' --disable-features=CrossSiteDocumentBlockingAlways,CrossSiteDocumentBlockingIfIsolating

Any filter can come after -- in the above code --disable-features=CrossSiteDocumentBlockingAlways,CrossSiteDocumentBlockingIfIsolating is just an example.

Note: Make sure to close all instances of Chrome before running it.

查看更多
虎瘦雄心在
3楼-- · 2019-03-09 22:02

This work for me:

  1. Modify the .bash_profile
  2. Write this alias:
alias cchrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/tmp/chrome_dev_session" --disable-web-security'
  1. Run
exec $SHELL
  1. With the cchrome command open a new windows of chrome with the disable web security to solve the "access-control-allow-origin" problem
查看更多
手持菜刀,她持情操
4楼-- · 2019-03-09 22:03

Just make an alias in your .bashrc or .bash_profile

alias ogc='open -a Google\ Chrome --args --disable-web-security'

And then reload your shell.

exec $SHELL

Now, every time you type ogc (or whatever you want to call it) in your terminal, it will run the full command open -a Google\ Chrome --args --disable-web-security

查看更多
老娘就宠你
5楼-- · 2019-03-09 22:16

Why not just run a webserver? Open a terminal and type

cd folder_with_html_and_assets
python -m SimpleHTTPServer

Now in your browser to go http://localhost:8000 When your done go to the terminal and press Ctrl-C

That seems much better than disabling your security and risking getting pwnd.

查看更多
登录 后发表回答