Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Writing Firefox's prefs.js with javascript

16 views
Skip to first unread message

Csaba Gabor

unread,
Feb 24, 2006, 8:55:18 AM2/24/06
to
Firefox's configuration settings (Prefs.js) can be accomplished via the
interface at about:config.

Q1. Is there any such setting that can be repeatedly altered via
javascript (in a vanilla security environment), without having to
request preivileges? By altered, I mean having it remain in effect the
next time Firefox is restarted.

Q2. If the answer to Q1 is affirmative, is there any such setting that
could have an event associated with it so that a page could trap for
such event?

Thanks,
Csaba Gabor from Vienna

Randy Webb

unread,
Feb 24, 2006, 1:23:46 PM2/24/06
to
Csaba Gabor said the following on 2/24/2006 8:55 AM:

> Firefox's configuration settings (Prefs.js) can be accomplished via the
> interface at about:config.
>
> Q1. Is there any such setting that can be repeatedly altered via
> javascript (in a vanilla security environment), without having to
> request preivileges? By altered, I mean having it remain in effect the
> next time Firefox is restarted.

I surely hope not. I don't want script changing my preferences :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Richard Cornford

unread,
Feb 24, 2006, 2:26:05 PM2/24/06
to
Csaba Gabor wrote:
> Firefox's configuration settings (Prefs.js) can be accomplished
> via the interface at about:config.
>
> Q1. Is there any such setting that can be repeatedly altered
> via javascript (in a vanilla security environment), without
> having to request preivileges? By altered, I mean having it
> remain in effect the next time Firefox is restarted.

Wouldn't that completely undermine the whole purpose of user
configuration, and blow a huge hole in the browser's security?

> Q2. If the answer to Q1 is affirmative, is there any such
> setting that could have an event associated with it so that
> a page could trap for such event?

In the event that the answer to Q1 was ever affirmative that significant
bug could be expected to be fixed in very short order.

Richard.


Csaba Gabor

unread,
Feb 26, 2006, 5:53:57 PM2/26/06
to
Richard Cornford wrote:
> Csaba Gabor wrote:
> > Firefox's configuration settings (Prefs.js) can be accomplished
> > via the interface at about:config.
> >
> > Q1. Is there any such setting that can be repeatedly altered
> > via javascript (in a vanilla security environment), without
> > having to request preivileges? By altered, I mean having it
> > remain in effect the next time Firefox is restarted.
>
> 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

0 new messages