Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is Chrome's debugger console command history stored?

I often use Chrome's debugger console for experimenting with javascript code fragments. When I got it right I usually want to copy the needed commands into my script, but here is where it gets messy. The is no filter options for commands and no way to call certain commands back (like with Ctrl-R in Bash) so you need to step through all the commands in the history and copy the commands you want one by one.

Instead, I think it should be possible to retrieve the command history from some file or Sqlite database. But I can't find it.

So my question is: Where is Chrome's debugger console command history stored?

like image 366
marlar Avatar asked Oct 23 '15 10:10

marlar


People also ask

Where does Console log show up?

Steps to Open the Console Log in Google Chrome By default, the Inspect will open the "Elements" tab in the Developer Tools. Click on the "Console" tab which is to the right of "Elements". Now you can see the Console and any output that has been written to the Console log.

How do I clear my Chrome Console history?

Use the short cut Ctrl + L to clear the console. Use the clear log button on the top left corner of the chrome dev tools console to clear the console.


2 Answers

I found an answer here: How to access firefox web console command history?

I had some trouble getting it working, but here is how I did.

Open the developer console (shift-ctrl-I). Then open that console in a new window if it isn't that already by using the menu in the upper right (the three dots).

When it is a separate window, press shift-ctrl-I again. Then paste something like this:

var hist = JSON.parse(localStorage.consoleHistory);
hist.forEach(function(command){
  console.log(command);
})

Now, with all the commands in the console you can either copy them all to the clipboard or use the filter field above the console to do some filtering on them (you can use regex).

like image 195
marlar Avatar answered Sep 24 '22 13:09

marlar


https://code.google.com/p/chromium/issues/detail?id=171386

Seems there was talk of such a feature which never came to fruition You can collect some people and pressure the devs to put it in, or get it done. Sounds really useful to me (:

For retrieving history : https://developer.chrome.com/extensions/experimental_devtools_console#method-getMessages

How about developing an extension around that ?

like image 28
DannyZB Avatar answered Sep 24 '22 13:09

DannyZB