Subj : Can SpiderMonkey do this? To : netscape.public.mozilla.jseng From : bryanashby@hotmail.com (Bryan Ashby) Date : Wed Nov 19 2003 03:36 pm All, I have multiple questions, so forgive me for the long post! I am currently working on a project in which my DLL ("Engine") sits in the space of web enabled executables (IE, Mozilla, Opera, ...). When traffic comes though, it passes though the Engine first, is analized/modified if necessary and then passed on to the application. One of the major goals here is to slightly modify JavaScript without breaking it - e.g.: remove popups, ads, dhtml popups, ... (Yes, I know many browsers are now doing this themselfs, I'm still stuck with the project). Currently I do not have a "true" JavaScript parser, only a pieced together one that examines via regular expressions, etc. certain aspects of the JavaScript code. This is what I'm hoping to replace, in part, with the SpiderMonkey engine. The major pains are things in JavaScript where people are deliberatly making it hard for apps like mine to parse the code. Things like breaking appart strings in document.write's, using functions to encrypt strings, etc. With a true JavaScript parser this would not be an issue as if the JavaScript could not be parsed then it would be broken in the browsers as well and of course this is not good for the authors of the code ;-) I have been messing around with SpiderMonkey and am able to compile + execute some portions of code, fetch properties, etc. but have run into many issues: - Common functionality, for example alert() will break the parser (JS_ExecuteScript() fails). I'm assuming I would have to "bridge" my own functionaly into the engine for these? So I'll have to write a complete up-to-browser-spec system for all of these common functions? - Some code (without "external" function calls) seems to fail in the engine whereas it works fine in Mozilla (SpiderMonkey 1.5 BTW): function SomeThing(c) { var aArray = new Array(); aArray["a"] = "A"; return aArray[c]; } // works fine in Mozilla but JS_ExecuteScript() fails? I guess more than just questions, I'm looking for suggestions here. Am I going about this all wrong? Can SpiderMonkey be used for what I am trying to do here? I'm open to any insight anyone can provide! Thanks, Bryan Ashby .