2

I'd like to be able to send info to the Chrome developer console from my application.

For example, my app has some json. I'd like this json to show up in either an existing, or newly created instance of the chrome dev tools console.

Is this possible? If so, any pointers to examples? Note that the platform should be any language, not just javascript. And definitely not a site already running in Chrome. I'm interested in implementing this in another process.

Kara
  • 6,115
  • 16
  • 50
  • 57
Brad Parks
  • 66,836
  • 64
  • 257
  • 336

3 Answers3

0

Do you thought of running your app in an environment which is pretty much like a browser?

Node.js

or (this is a whole webkit browser)

phantom.js

Otherwise you could call Chrome directly via commandline and try to simulate the dev tools key stroke like explained here:
Is there a command line argument in Chrome to start the developer tools on startup?

The command of displaying something in the Chrome console is e.g. console.log and it is at the end Javascript. All Console commands are described here: https://developers.google.com/chrome-developer-tools/docs/console-api

Community
  • 1
  • 1
therealmarv
  • 3,692
  • 4
  • 24
  • 42
0

The closest I've seen so far is this library:

https://github.com/ccampbell/chromelogger

which seems to allow logging to the Chrome Console from lots of other server side apis, but no desktop APIs.

Brad Parks
  • 66,836
  • 64
  • 257
  • 336
0

This can be done on Mac using osascript. Save the following as a script and run it:

#!/usr/bin/osascript -l JavaScript

var chrome = Application('Google Chrome');
//chrome.activate();
chrome.includeStandardAdditions = true;
var currentTab = chrome.windows[0].activeTab()
currentTab.execute({javascript: 'console.log("Hello")'})
Brad Parks
  • 66,836
  • 64
  • 257
  • 336