I used to put !open -a Firefox.app % to open current file with Firefox, But I failed to make it with Chrome.
I got my answer:
!open -a Google\ Chrome %
You could also use:
!open -a "Google Chrome" %
Related
I am attempting to launch a new window of Chrome with an exact viewport size. I'm using this command on Windows command line:
chrome --window-size="500,500" http://whatismyviewport.com
This is the result, which is not 500x500 dimensions:
Here is more about this version of Chrome (from chrome://version):
How can I consistently, reliably get the viewport height & width supplied?
The window-size argument has never worked, at least as far back as 2018 when I wrote a script to open Chrome in app mode for taking screenshots. I had a hacky workaround in place but that also broke recently.
Maybe somebody can fix my hack?
If run without the url="data:text/html part commented out Chrome just exits now.
https://gist.github.com/duffyjp/13a8f7a40cb4e43a240811c64235b25b
#!/bin/bash
url=${1:-http://localhost:3000}
# FYI: If your URL has an & you need to pass the argument in quotes.
# Chrome app mode doesn't work without the http/https part.
if [[ $url = *"http"* ]]; then
echo $url
else
url="http://${url}"
echo $url
fi
# Hack to resize the window to 1024x768.
# url="data:text/html,<script>window.moveTo(0,0);window.resizeTo(1024,768);window.location='${url}';</script>"
# Launch Chrome from one of it's usual locations.
if [ -e "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app=$url 2>/dev/null
elif [ -e "~/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
~/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app=$url 2>/dev/null
else
/usr/bin/google-chrome --app=$url 2>/dev/null
fi
I'm trying to get the devtools to open automatically when starting chrome from a shortcut with a command line switch --auto-open-devtools-for-tabs.
i.e. the path of that shortcut is: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -incognito -auto-open-devtools-for-tabs (or --auto-open-devtools-for-tabs).
But both don't seem to open the dev tools, neither does entering in the cmd chrome.exe -auto-open-devtools-for-tabs (or --auto-open-devtools-for-tabs), of course when in Chrome's folder.
Maybe I'm doing something wrong?
The command is from:
http://peter.sh/experiments/chromium-command-line-switches/#auto-open-devtools-for-tabs
https://stackoverflow.com/a/41452619/4279201
This flag only applies when you open the first chrome instance.
Close all chrome windows
Run "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -incognito -auto-open-devtools-for-tabs
If you want your daily browser, with all tabs but without devtools, at the same time as you're debugging a website with devtools automatically opening, you have to run them separately.
Alternative: Stable + Beta
One example is to use example Chrome stable and Chrome beta.
"C:\Program Files\Google\Chrome\Application\chrome.exe"
"C:\Program Files\Google\Chrome Beta\Application\chrome.exe" --auto-open-devtools-for-tabs
Alternative: data-dir
"C:\Program Files\Google\Chrome\Application\chrome.exe" -incognito --auto-open-devtools-for-tabs --user-data-dir="%APPDATA%\ChromeDevOrAnyName"
I would know if it's possible to make a chrome app who could be launched in the terminal without chrome UI. Example:
chrome.app.runtime.onLaunched.addListener(function() {
console.log("Hello world!);
});
imac:bin$ chrome --app-id=<my-app-id>
Hello world!
imac:bin$
I think not, but could you confirm. Thanks
I use this line to start chrome apps from the command line, on OSX:
open -n -a Google\ Chrome\ Canary --args --user-data-dir=/tmp/temp_chrome_data_dir --load-and-launch-app=...
The key flags are --user-data-dir to create an isolated profile, and --load-and-launch-app to start a chrome app automatically. I use the open command to resolve the path to chrome application on OSX, but you can just an explicit path instead:
/path/to/Google\ Chrome\ Canary --user-data-dir=/tmp/temp_chrome_data_dir --load-and-launch-app=...
That said, this will pop open a chrome browser window as well. I'm not yet sure how to get around that, but I will investigate. (My workaround for local development is to just minimize the window once, and it won't pop up any more).
I am trying to access some local files via jqueryMobile, it works fine in Firefox and IE but Chrome gives a security exception. I can open Chrome in disabled security mode to access local files by using
C:\Program Files\Chrome\Chrome.exe --disable-web-security
or run it via this
chrome.exe --disable-web-security
but is there any way I can create a shortcut on desktop that will always open Chrome in disabled security mode?
Just clone the shortcut for chrome you have on your desktop, and then in the shortcut properties add the parameter --disable-web-security (and --user-data-dir) at the end of chrome executable path
e.g
"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="C:\tmpChromeSession"
Edit #1 : I changed google chrome path, the old one was not correct.
I just tried it on XP with fresh Chrome installed, but i got a error message that this flag is not supported.
Edit #2 : http://peter.sh/experiments/chromium-command-line-switches/
First search Run, then try this:
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
just a quick update, now you need not only --disable-web-security but --user-data-dir
to sum it up:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir
You must use the following flags
--disable-web-security
--user-data-dir
but also pass the path to your chrome user profile
See this:
https://productforums.google.com/forum/#!topic/chrome/9nHBcjNW384
https://bugs.chromium.org/p/chromium/issues/detail?id=575690
So now i have top pass my user profile path:
C:\Users\user\projects\project>"C:\Program Files (x86)\Google\Chrome\App
lication\chrome.exe" --disable-web-security --user-data-dir="C:\Users\user\A
ppData\Local\Google\Chrome\User Data\Default"
For MAC (ios)
Run following command in terminal.
open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security
It's working You have to add that parameter --disable-web-security in Target location after one space
Goto window search type Run
then on the run popup
just paste "chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security "
and ok || worked for me :)
Now it's
--disable-web-security --user-data-dir="c:/someFolderName"
chrome security command
for windows open run->than paste this command and make sure you have to close all windows before run this command
"chrome --disable-web-security --user-data-dir"
For Windows10:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="C:\temp"
For Ubuntu,
google-chrome --args --disable-web-security --user-data-dir="Path_To_Project_Directory"
Creating Google Chrome
Ubuntu
Windows10
chrome.exe --disable-web-security --user-data-dir=c:\my-chrome-data\data
Why don't you try with Safari browser? It is simple to disable web security over there.
Simply click on
Develop > Disable Cross-Origin Restrictions
in the menu bar.
In order to get Develop menu, do the following:
Preferences > Advanced > Show Develop menu in menu bar.
I'm trying to do a simple test without changing any server-side code involving a cross-domain AJAX call, and I was wondering if it's possible to use --disable-web-security anymore. It seems to not work on Chrome 28.
I haven't used it since Chrome version 21; has this feature been dropped?
Check your windows task manager and make sure you kill all chrome processes before running the command.
The new tag for recent Chrome and Chromium browsers is :
--disable-web-security --user-data-dir=c:\my\data
Try this :
Windows:
Run below commands in CMD to start a new instance of chrome browser with disabled security
Go to Chrome folder:
cd C:\Program Files (x86)\Google\Chrome\Application
Run below command:
chrome.exe --disable-web-security --user-data-dir=c:\my-chrome-data\data
MAC OS:
Run this command in terminal:
open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_sess_1" --disable-web-security
Hope this will help both Windows & Mac users!
This flag worked for me at v30.0.1599.101 m
The warning "You are using an unsupported command-line flag" can be ignored. The flag still works (as of Chrome v86).
This should work. You may save the following in a batch file:
TASKKILL /F /IM chrome.exe
start chrome.exe --args --disable-web-security
pause
Open target location of chrome and navigate through cmd
type
chrome.exe --disable-web-security --user-data-dir=c:\my\dat
Just create this batch file and run it on windows. It basically would kill all chrome instances and then would start chrome with disabling security. Save the following script in batch file say ***.bat and double click on it.
TASKKILL /F /IM chrome.exe
start chrome.exe --args --disable-web-security –-allow-file-access-from-files
Check if you have Chrome App Launcher. You can usually see it in your toolbar. It runs as a second instance of chrome, but unlike the browser, it auto-runs so is going to be running whenever you start your PC. Even though it isn't a browser view, it is a chrome instance which is enough to prevent your arguments from taking effect. Go to your task manager and you will probably have to kill 2 chrome processes.
As you can't run --disable-web-security and a normal chrome in parallel it's probably a good solution to use Opera for --disable-web-security
Here is how to create a launcher for opera on windows. By the way, Opera has the same debugging tools as chrome!
http://www.opera.com/
:: opera-browse-dangerously.bat
cd c:\Program Files\Opera\
launcher.exe --disable-web-security --user-data-dir="c:\opera-dev"
PS: Opera doesn't display any notification when started without web-security
If you want to automate this:
Kill chrome from task Manager First. In Windows - Right Click (or Shift+right click, in-case of taskbar) on Chrome Icon. Select Properties. In "Target" text-box, add --disable-web-security flag.
So text in text-box should look like
C:\Users\njadhav\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --disable-web-security
Click Ok and launch chrome.
just run this command from command prompt and it will launch chrome instance with CORS disabled:
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --disable-gpu --user-data-dir=~/chromeTemp
Automated solution for Windows 10
Right-click on Chrome icon > right-click Google Chrome > Properties
Shortcut > Target > "C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="C:\ChromeDevSession"
Notes:
Your file path for chrome.exe may vary.
Also, the --user-data-dir flag is required, and its file path may vary. Besides C:\ChromeDevSession, another possible location is ~/chromeTemp
Now Chrome always has its web security disabled :-)