Where is Chrome's debugger console command history stored? - javascript

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?

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).

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 ?

Adding To marlars answer :
Actually i think its a little useful to not convert it into json. you can just keep it as a string so that you can use .indexof('yoursearchvalue')
And you don't have to always type that piece of code. you can just go to the Application tab -> Local Storage -> Devtools Entry and click on the consoleHistory

Related

How to trigger consistent events in single browser console in one time?

For example I would like to control multiple”online”webpages ,such as google.com ,with only a sequence of consistent codes on browser console(ctrl+shift+j in windows system)for consistent action "such as clicking button A in A web and jumping to web B automatically , then clicking button B in B web."
(as usual,I must type other codes in refreshed console once I jump to anther webpage to change html)
For example:
//on the console1
`document.getElementbyid(“id1”).click()
`
//id1 is inside the web1
`window.open(“link_of_new_webpage”,”_self”)`
//I understand that it will be just a new page with new console.
//but I mean I was looking forward to some kind of these things.
//and below is id2 inside web2 in console2
`document.getElementbyid(“id2”).click()`
in conclusion i want a console likely showed below
document.getElementbyid(“id1”).click()
window.open(“link_of_new_webpage”,”_self”)`
document.getElementbyid(“id2”).click()
//the code above is actually consistent!
//not like code below
document.getElementbyid(“id1”).click()//in console 1 in web1
////////////////////////////////////////////////////////////////////////////////////////////////////
document.getElementbyid(“id2”).click()//in console 2 in web2
Plz someone helps me or tell me that it cannot be fulfilled
(in fact ,I was freshman in JavaScript and Html)
I promise I will use these tools in correct way.thx beyond description !!
If you're trying to do this on a client facing site I'm afraid what I believe you're asking to do is impossible for a myriad of security reasons. If you're just looking to run these executions locally though you're in luck. Headless browsers are commonly used in testing as well as web scraping and allow you to program commands as if a user was interacting directly with the browser. If you're looking to stay within the confines of JS a popular option is Puppeteer.
Best of luck

How to extract information from web page

I'm looking for a way to automatically extract information from a web page, more specifically an online game (https://www.virtualregatta.com/fr/offshore-jeu/).
In the game, I want to extract/copy the position of the boat. With Mozilla and its debug tools, I used the network debugger and I saw an HTML POST request containing what I want.
It seems that we receive as a response a json containing a structure with latitude/longitude.
This is perfect to me, but I want a more user friendly way to get it and I would need advices. Problem is that I'm really a beginner in web development haha.
Is it possible to do this using a script ? (But I suppose it will be complicated to first log into the game)
Is it possible to create a basic Mozilla plugin which would be able to catch the request/response and copy the position to clipboard for me ?
anything else ?
EDIT:
I've tried using a Mozilla plugin, and I achieved to add a listener on POST request. I see the request to get the boat information but I can't find a way to get the json response in JS.
function logURL(responseDetails) {
console.log(responseDetails);
}
browser.webRequest.onResponseStarted.addListener(
logURL,
{urls: ["*://*.virtualregatta.com/getboatinfos"]}
);
In Chrome I use Broomo for this purposes. It helps you to add scripts in web pages, you can console.log the POST you found, and of course you can create functions and Use the webpage Backend.
In firefox I found this one js-injector. But I didn't use it before.
Update:
Now there are a new extension for both browsers:
Chrome: ABC JS-CSS Injector
Firefox: ABC JS-CSS Injector

Is it possible to save console logs to chrome_debug.log just from one extension

I am trying to save some data about browser usage but locally. I enable logging with chrome start and I can find chrome_debug.log with all console text. I just need to save only messages from extension with ID bkdejfodnieiifpcgcmbgfdlibjhgcja or lines with my inserted keyword for example keyword is BANANA and log is something like that:
[2928:6480:0628/163351:INFO:CONSOLE(20)] "BANANA;IMPORTANT;DATA;THAT;I;WANT", source: chrome-extension://bkdejfodnieiifpcgcmbgfdlibjhgcja/background.js (20)
How can I edit what to save in chrome_debug.log, I find some thread where explain how to show only warn / debug / info but it is still many lines for me.
Maybe here I can edit some script but I am not sure and don't want destroy it.
I will appreciate any advice.

Facebook like button in site that uses post message spams console

I have a site that uses a lot of postMessage communication between iframes. Putting a Facebook like button in my site causes my debug console to get spammed with messages like
Received message of type object from [domain], expected a string.
This makes development very difficult. Is there any way to prevent this extra logging from occurring? I am new to using facebooks apis so I'm hoping I'm just missing something simple. They can't possibly assume that no one besides them will ever use postmessage.
Thanks!
Actually, disabling console.log is a horrible answer. What if we want to use console.log, but just want to stop the spamming error message? What is causing it? How do we actually fix it?
Actually that's not an extra logging. It's from the Facebook SDK. Simply you can uglify the sdk for removing all console from the library.
1.Download the sdk. https://connect.facebook.net/en_US/sdk.js
2.Uglify it for removing console logging (production version.)
https://github.com/mishoo/UglifyJS
3.Use it in your site.
Another link which may help you:
http://elijahmanor.com/grunt-away-those-pesky-console-log-statements/
You could simply "unset" the console.log function, by doing something like:
console.log = function(){}
Save it in another variable first, for example:
var originalLog = console.log;
Now when the Facebook API tries to use the log function nothing will happen. If you need to use the log function, just enable it first by setting it back to your saved originalLog variable and unset it when you are done using it. Unhandled errors will still show up in your console, regardless of what you have done to the log function.
In my case this was caused by the FVD Video Downloader extension, so maybe you should disable all browser extensions and see if that solves the issue, then enable them back one by one to find the culprit.

How do I turn off the console logging in App Engine Channel API?

I've implemented the Channel API w/ persistence. When I make a channel and connect the socket (this is on the real app, not the local dev_appserver), Firebug goes nuts with log messages. I want to turn these off so I can see my OWN logs but cant find any documentation on how to disable the Channel API console logging.
one thing I'm probably doing differently than most is that I'm connecting cross-domain... which the Channel API supports (note the first message in the stream... if you can view that pic)
Does anyone know?
UPDATE
I finally realized that my code was creating two channels and trying to open/connect them both at the same time... and that was why I was getting a flood of messages. I didn't mean to do this (I know the rules: https://developers.google.com/appengine/docs/python/channel/overview#Caveats )... it was a bug... and once I fixed it, the messages went back to manageable level.
yay
There doesn't appear to be a way to shutoff the Firebug timeStamp log. One way to solve this problem is to edit the code and remove this functionality yourself:
Unpack the extension to a directory in your Mozilla Firefox Profile:
Change directory to your Firefox profile extensions directory. On Ubuntu, this would be something like this:
cd ~/.mozilla/firefox/{random-string}/extensions/
The Firebug extension is identified by firebug#software.joehewitt.com.xpi. Create a new directory of the same name, but without the .xpi, and move the XPI into that directory:
mkdir firebug#software.joehewitt.com
mv firebug#software.joehewitt.com.xpi firebug#software.joehewitt.com
Next, change directories to your newly created Firebug directory, and unpack the extension:
cd firebug#software.joehewitt.com
unzip firebug#software.joehewitt.com.xpi
All of the files should be unpacked so that the extension's directories are in the current directory. Your file structure will look something like this:
$: ~/.mozilla/firefox/{random-string}/extensions/firebug#software.joehewitt.com$ l
chrome.manifest defaults/ firebug#software.joehewitt.com.xpi install.rdf locale/ skin/
content/ docs/ icons/ license.txt modules/
$: ~/.mozilla/firefox/ghlfe0bb.ff5.0/extensions/firebug#software.joehewitt.com$
Open consoleExposed.js in your text editor:
Next, change to the content/firebug/console directory:
cd content/firebug/console
Edit the consoleExposed.js file using your favorite editor:
vim consoleExposed.js
Disable console.timeStamp:
On or near line 215, you'll see the following function:
console.timeStamp = function(label)
{
label = label || "";
if (FBTrace.DBG_CONSOLE)
FBTrace.sysout("consoleExposed.timeStamp; " + label);
var now = new Date();
Firebug.NetMonitor.addTimeStamp(context, now.getTime(), label);
var formattedTime = now.getHours() + ":" + now.getMinutes() + ":" +
now.getSeconds() + "." + now.getMilliseconds();
return logFormatted([formattedTime, label], "timeStamp");
};
Right after the first curly-brace, force the function to return nothing:
console.timeStamp = function(label)
{ return ; // disable timestamp by returning
label = label || "";
if (FBTrace.DBG_CONSOLE)
Restart Firefox and enjoy a world without timeStamp:
After the edits, restart Firebug. You should no longer see the log messages for timeStamp in your console.
On the Development server, when using the ChannelAPI, it essentially degrades into a polling implementation instead of using Comet/long-polling. Thus, in your debugger, you see an endless stream of HTTP requests made to the server to continuously and methodically check for updates.
In essence, these are just AJAX requests, or as Firebug would like to think of them, XMLHttpRequests.
Since your browser is responsible for making these requests, the only way to disable them is to click the small arrow on "Console" in Firebug and uncheck the option for logging XMLHttpRequests.
Of course, this also disables logging for all of your other XMLHttpRequests. But it's a small price to pay for the clarity and serenity of a quiet, well-behaved JavaScript console.
For more helpful information on how to make the most of Firebug, see Firebug Tips and Tricks.
NOTE: This works for both users of the Python SDK as well as the Java SDK. (or Go SDK, assuming it has an equivalent ChannelAPI). This is not limited to only Python Appengine.
UPDATE:
From getFirebug:
Creates a time stamp, which can be used together with HTTP traffic timing to measure when a certain piece of code was executed.
The console.timeStamp method was released in Firebug 1.8.0. The same technique described above can also override this Firebug logging method.
console.timeStamp("This is the type of console logging statement that Google is using!");
The above logging statement would produce the olive text. This method can be disabled using the same techniques which were described in the previous section.
However, Google loads the console object inside of a closure, which means that, once Google's code is initialized, the ChannelAPI object has it's own copy of the console object.
In order to disable console.timeStamp, one would need to disable it as the very first action before anything else loads or runs. in other words, we would need to ensure that Google only gets its hands on the disabled console.timeStamp method.
For best results, load this code above the /_ah/channel/jsapi script tag to ensure the console.timeStamp method is disabled before jsapi loads:
if(window.console) console.timeStamp = function(t) { };
NOTE: Because Google invokes Firebug logging in this manner, the only solution may very well in fact require a bug report or feature request that would allow for programmatically disabling this level of logging. Alternatively, the Firebug team could provide a new version of Firebug that includes the ability to explicitly disable timeStamp log statements, similar to how they've done so with Errors, Warnings, XMLHttpRequests, and other log levels.

Categories

Resources