Richard said:
Wouldn't that completely undermine the whole purpose of user
configuration, and blow a huge hole in the browser's security?
Well, shoot, I just can't slip anything past you guys
I tend to agree with you, but I found something interesting after I
installed GreaseMonkey. [For those not aware: GreaseMonkey is a
Firefox extension that allows one to run custom javascript (on your
local hard drive) whenever you encounter predesignated web pages. For
example, one might remove ads from the page, whenever one visits
yahoo.com].
GreaseMonkey allows you to set values that survive across invocations
of a given script (and are accessible only to that script). It does
this by writing the prefs.js file! Of course this doesn't exactly
match the conditions that I originally stated (vanilla security
environment).
The real motivation for my question is that I would like to be able to
hook into an event (via a GM script) so I can run a function when the
same GM script (even on a different page) has changed such a prefs.js
value. Of course, I could always monitor the value via
window.setInterval(...), but event driven would be much cleaner.
Evidently there is such a mechanism, described at:
http://kb.mozillazine.org/Dev_:_Using_preferences#Using_preferences_observers
However (being totally new to XUL, XPCOM, and extensions), from my
initial read and testing, the indicated script (note that last line
references the wrong variable) needs to be in an extension (as opposed
to just being in a <script> element on a page. I would love to be
corrected on this, even if it means having to alter a security setting
on Firefox.
But regardless of whether this event driven prefs.js monitoring is
possible from a GM script / <script> element, I would also like to get
a recommendation for a tutorial or simplest example of being able to
declare custom functions that will allow me to utilize the example's
scripts. Sort of like a "Hello World" thing. There are nice tutorials
at
http://www.xulplanet.com/references/xpcomref/group_Preferences.html
but these seem like a lot more than what I'm after right now.
Csaba