views:

507

answers:

1

I'm doing some analysis of some Javascript and I want to keep javascript enabled, but disable all alert() boxes and self.location redirects.

Currently I'm using a regex proxy, but that seems like overkill.

I can override some native methods but not others in Firefox i.e.

window.alert = function('') { return null; }
alert('test!') // works as expected

However when I try to similarly overwrite window.location = (which is an alias for the method call window.assign() ) it does not work

window.location.assign = function('') { return null; }
window.location.assign('#') // redirects :(

I've tried setting Window.prototype.location.assign but i get a "Cannot modify properties of a WrappedNative" exception.

Any alternatives to NoScript for fine grained JS control, or is it possible to overwrite certain Native JS methods?

+2  A: 

This suggested solution for disabling alert might work.

wrumsby
I think http://www.adsafe.org/ is exactly what I was looking for, Thanks!
Joel P.