Is it possible to set config settings on Firefox from a Addon
Asked Answered
I

2

6

I'm looking for a way to print from web without prompting the print dialog (I just made the question).

I found This method for Firefox and it seems to work, but it obviously will affect all websites. So I'm thinking of developing a Firefox Addon that makes this configuration to affect only specific websites.

I don't know nothing about building Firefox addons, but if it's possible to change settings this way I will learn how to do it.

So my question is.. Is it possible to set config settings on Firefox from a Addon and for specific websites?

Thanks a lot.

Iyeyasu answered 27/4, 2011 at 19:24 Comment(0)
B
6

If you are going to develop a Firefox addon you could "easily" replace the print button and delegate to the standard print action on normal websites. For a list of URLs, i.e. your web site, you temporarily set print.always_print_silent to true and be done with it.

For modifying a preference in an addon you would something like this:

// Get the "accessibility." branch
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
    .getService(Components.interfaces.nsIPrefService).getBranch("accessibility.");

// prefs is an nsIPrefBranch.
// Look in the above section for examples of getting one.
var value = prefs.getBoolPref("typeaheadfind"); 

// get a pref (accessibility.typeaheadfind)
prefs.setBoolPref("typeaheadfind", !value); // set a pref (accessibility.typeaheadfind)

(taken from this snippet).

Bertrand answered 27/4, 2011 at 22:5 Comment(1)
This won't work if the site has its own print button. Also, where possible, you should override the printSilent attribute rather than fiddling around with preferences.Kathrynekathy
K
0

One way is to provide your own implementation of the printing prompt service. You could then inspect the window being printed and turn on silent printing if you want to bypass the print dialog. You might need to retrieve the original service to handle the cases that you don't want to. I couldn't find much documentation but there's some related documentation here.

Kathrynekathy answered 1/5, 2011 at 23:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.