Skip navigation.
Home

A safer way to monitor Javascript in a web page

Recently Val asked me to look over a html file that contained encoded data that was decoded by javascript.

It sent me on a mission to find a way to redirect javascript output to a console rather than to a browser window.

As always, firefox is your friend. I found this snippet on borngeek.com, tested it , and it works like a charm. Once you make the required changes to firefox, just edit the hostile javascript replacing " document.write() " with " dump() " and the output is sent to a console window.

Logging to the Standard Console An alternative method of logging debug information is available through the standard console mechanism. Before this method can be used, several modifications to the browser must be made. First, we need to add a new browser preference. In the URL bar in Firefox, type about:config and press enter. Right click in the list control and select the New » Boolean menu item to create a new boolean preference. Give the preference a name of browser.dom.window.dump.enabled and set the value to true.

The next step is to add the "-console" command line parameter to your Firefox startup shortcut. Using this parameter will cause the standard output console window to appear each time you run Firefox. Once this has been done, and Firefox has been started, any output produced by the dump() function will appear in this console window. The dump() function works just like the standard JavaScript alert() function, so the syntax is similar.

Ha!

Thats pretty awesome. I didnt know about that!

super cool

V.

thanx for sharing this

thanx for sharing this trick! ;)

Why did I ever bother to

Why did I ever bother to code Malzilla...

The trick here will deal with a rather small number of current scripts.
Not a lot of scripts are using document.write() anymore.

slaps face

ah man I totally forgot about malzilla, that could be very useful for something we are working on.

Thanks for reminding me!

V.

right on

I didn't know that, what a really useful trick.

And that was a rocking party at the riv this year!