Caution... Never finished... Facts likely to be slightly awry

This is the second part of instructions of how to use complex javascript libraries when you write greasemonkey scripts. I broke this into two articles because WordPress was getting awully confused and putting all my content in div >> div >> div >> div >> div >> div >> div >> div >> div >> div >> div . You get the idea.

In the case of qooxdoo I had to create a file called qooxdoo-0.5.3-unix/demo/chromeinclude.js . How I knew to do that and what I put in it are the described now:

I first identified that =qooxdoo-0.5.3-unix/demo/demoinclude.js= is called from all the example pages in the qooxdoo-0.5.3-unix package.

  • In your case, you will have to try to interrupt the execution flow steadily until you get to a library that does not work.

  • Then look at the previous library as well as the broken library and see why it could not invoke the broken one.

  • This will almost certainly be because the broken library is still being requested relative to the http document, and not where the scripts are (chrome).

Back to _qooxdoo_ . This script =qooxdoo-0.5.3-unix/demo/demoinclude.js= had a telltale line which was =var output = "<script type=\"text/javascript\"= ==src = \""+srcLink+"\"== =></script>";=
see how the =src="= would be relative to the *web* location?

So I needed to change that =src="= to have a hardcoded prefix of =chrome://path/to/greasemonkeyfiles/= which all the scripts could then be relative to instead.

That's it. Combined with the next short step, you can now load quite a lot of things. How easy it will be for you totrace where _your_ library includes other files will depend on how well architected your library is.

To load the library functionality, you will need Greasemonkey to place a link to the libraries in the head of the of the incoming page.

o Reference external libary entities using unsafeWindow .

Invoke any black magic initialization code that your handler has overriden

All the examples here show 5 main regions.

1. global variables

2. global functions

3. greasemonkey code at =DOMContentLoaded= [ see here(external link) ].