Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Chrome open its Javascript debugger automatically when Chrome opens a new tab?

Or can Chrome open debugger automatically when it opens a page which contains 'debugger' keyword in its source code?

like image 798
CarmeloS Avatar asked Jun 10 '12 13:06

CarmeloS


People also ask

How do you launch the JavaScript debugger in Google Chrome?

The Sources panel is where you debug JavaScript. Open DevTools by pressing Command+Option+I (Mac) or Control+Shift+I (Windows, Linux).

How do I open Chrome debugger in a new window?

Just type ctrl+shift+I in google chrome & you will land in an isolated developer window. Save this answer. Show activity on this post. If you need to open the DevTools press ctrl-shift-i.


1 Answers

Previously there was a command line flag --always-enable-devtools, doesn't look like there is anymore. However, there's a nifty trick you can use although if you're not on OSX you'll have to fiddle around a bit to reproduce what I'm doing.

I made two shell scripts, 'developer-chrome' and 'debugger-chrome'.

developer-chrome is the instance I want to always be observing, debugger-chrome will just sit in my second monitor so I can see console messages and poke developer-chrome when I want.

developer-chrome

#!/bin/bash

export PROFILE=$HOME/develop-chromium-profile
export DISK_CACHEDIR=/tmp/develop-chromium-profile-cache
export DISK_CACHESIZE=0
export MEDIA_CACHESIZE=0
/Applications/Chromium.app/Contents/MacOS/Chromium \
    --remote-debugging-port=4096 \
    --user-data-dir=${PROFILE} \
    --enable-experimental-webgl=yes \
    --window-position=3000,400 \
    --window-size=1200,1000 \
    --no-pings \
    --disk-cache-dir=${DISK_CACHEDIR} \
    --disk-cache-size=${DISK_CACHESIZE} \
    --media-cache-size=${MEDIA_CACHESIZE} \
    --disable-geolocation \
    --ash-immersive \
    --disable-application-cache \
    --pinned-tab-count=1 http://some_url_im_developing_on/

debugger-chrome

#!/bin/bash

export PROFILE=$HOME/debugger-chromium-profile
export DISK_CACHEDIR=/tmp/debugger-chromium-profile-cache
export DISK_CACHESIZE=0
export MEDIA_CACHESIZE=0
/Applications/Chromium.app/Contents/MacOS/Chromium \
    --user-data-dir=${PROFILE} \
    --enable-experimental-webgl=yes \
    --window-position=2400,400 \
    --window-size=1200,1000 \
    --no-pings \
    --disk-cache-dir=${DISK_CACHEDIR} \
    --disk-cache-size=${DISK_CACHESIZE} \
    --media-cache-size=${MEDIA_CACHESIZE} \
    --disable-geolocation \
    --ash-immersive \
    --disable-application-cache \
    --pinned-tab-count=1 http://localhost:4096/

Run developer-chrome first, then debugger-chrome. Both instances of chrome will be autonomous so you can stop/restart them if you wish. You may have to manually reattach to the debugger from the debugger-chrome if you get disconnected.. but. I dunno.

It really irks me that there's no way to get devtools to just come up automatically. That coupled with Chrome's 'did it or didn't it?' caching behavior with dynamic content has almost gotten me to consider Firefox.

like image 176
synthesizerpatel Avatar answered Nov 13 '22 10:11

synthesizerpatel