Overriding a hard-coded Javascript variable??

View: New views
1 Messages — Rating Filter:   Alert me  

Overriding a hard-coded Javascript variable??

by JonathanHeard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,
   I'm hoping someone can help shed some light on a little problem I'm trying to solve...

I have to use an Oracle Forms application which is lauched by some utterly horrible javascript. It does crude browser detection and then concatenates a whole bunch of variables into another variable starting with an EMBED tag and finally does a document.writeln of the composed HTML to start a Java Applet.

What I want to do is override a variable which defines the application's look-and-feel., because the hard-coded Look and Feel called 'oracle' is horrible and very slow and I far prefer the 'generic' one.

When I view the launch page's source, the variable is just defined as:
  var xuilaf    = "oracle"

Which then later gets munged into a big string with:
  var NShtml = xHTMLpreApplet;
  NShtml += '<EMBED';
  ...
  NShtml += '    lookAndFeel="'      + xuilaf + '"';
  ...
  document.writeln(NShtml);

In Opera 9.x, it couldn't be more simple to override this - the user Javascript is simply:
window.opera.defineMagicVariable( 'xuilaf', function () { return "generic"; }, null );

But I cannot achieve the same result using Grease Monkey (I need to run this application in FireFox for other reasons)...

So In Grease Monkey I have tried:
unsafeWindow.xuilaf = "generic";

And I've tried:
unsafeWindow.watch('xuilaf',
                        function(property, oldval, newval) {
                                newval = 'generic'
                                alert('Hit')
                                return newval
                                }
**BUT** The watch never gets triggered unless I add a further line in Grease Monkey which changes the value. From what I can tell, any changes I make using GreaseMonkey seem to be actioned after it's already embedded the Java Applet launcher, which is too late.

I also tried to define unsafeWindow.xuilaf itself as a function which just returns "generic" but I kept getting syntax errors.

I've found nothing helpful in the GreaseMonkey documentation -- Can anyone point me in the right direction with this?

Thanks
Jonathan