[wpkg-users] Firefox and popup whitelist

Falko Trojahn nospam_ft at smi-softmark.de
Wed Mar 11 13:34:09 CET 2009


Hello Daniel,

> Seeing some activities about firefox, I have a question:
> 
> Does anyone of you succeed to manage the pop up white list ?
> 
> I search the web, ask on #firefox, it seems to be sqlite databases with
> firefox3, like for bookmarks (which are “places” now).
> 
> I want to add some configuration to thoses things without loosing the
> user settings (so no file copy).

You have two ways doing this:

The sqlite files are in the profile, so you can create the
default/prefs/permissions.sqlite file for a new user's firefox profile
using http://wpkg.org/Firefox#Firefox_with_extensions_and_default_profile
by placing it in fx_profile\defaults\pref\permissions.sqlite

-> every new user's profile gets the thing right.

For existing users, the permissions.sqlite is in the user profile,
so perhaps no simple way for Wpkg:
you need a script (called e.g. in domain logon script) which searches
for the profile and changes the permissions.sqlite database accordingly
(feel free to drop me a mail if you need such a script, we use it for
changing prefs.js).


To change the popup domains in permissions.sqlite,
I'd suggest the following:

install sqlite manager addon
  https://addons.mozilla.org/de/firefox/addon/5817
in firefox, open Extras -> sqlite manager
select profile database -> permissions.sqlite
-> have a look at the entries ...

Export the table "moz_hosts" as sql file, filter the file for "popup".

Now you have a file containing something like:
INSERT INTO "moz_hosts" VALUES(43,'www.immobilienscout24.de','popup',1);
INSERT INTO "moz_hosts" VALUES(44,'wetter.t-online.de','popup',1);
INSERT INTO "moz_hosts" VALUES(21,'www.mostlylisa.com','popup',1);
INSERT INTO "moz_hosts" VALUES(26,'www.bandeapart.fr','popup',1);

You must get rid of the id value, since it must be autoincremented,
e.g. using vi/vim via regex:

:%s/VALUES(\([0-9]*\),/ (host,type,permission) VALUES(

so you get
INSERT INTO "moz_hosts"  (host,type,permission)
VALUES('www.immobilienscout24.de','popup',1);
INSERT INTO "moz_hosts"  (host,type,permission)
VALUES('wetter.t-online.de','popup',1);
INSERT INTO "moz_hosts"  (host,type,permission)
VALUES('www.mostlylisa.com','popup',1);
INSERT INTO "moz_hosts"  (host,type,permission)
VALUES('www.bandeapart.fr','popup',1);

You can do the same procedure on command line, too,
using
http://www.sqlite.org/sqlite.html

Quit Firefox
Find permissions.sqlite in your Firefox profile and make a backup

echo "select host,type,permission from moz_hosts WHERE type='popup' ;" |
sqlite3 permissions.sqlite >moz_hosts_popups.sql

-> create a new file moz_hosts_new_popups.sql with only
the entries which you need for all users.

To delete the example entries, do e.g.:

sqlite3 permissions.sqlite
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> select * from moz_hosts where host='www.mostlylisa.com';
21|www.mostlylisa.com|popup|1
sqlite> delete  from moz_hosts where host='www.mostlylisa.com';
sqlite> select * from moz_hosts where host='www.bandeapart.fr';
26|www.bandeapart.fr|popup|1
sqlite> delete from moz_hosts where host='www.bandeapart.fr';
sqlite> .quit

Import the above created sql file:
sqlite3 permissions.sqlite < moz_hosts_new_popups.sql

Check if the import was successful:
sqlite3 permissions.sqlite
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> select * from moz_hosts where host='www.mostlylisa.com' or
host='www.bandeapart.fr';
74|www.mostlylisa.com|popup|1
75|www.bandeapart.fr|popup|1
sqlite> .quit


I don't know if duplicate entries in permissions.sqlite are a problem,
so perhaps the INSERT sql statement must be prefixed by according DELETE
statements (INSERT ON UPDATE is not supported by sqlite, IMHO).

Good luck
... and please provide a Wiki entry about this if you have successfully
deployed your settings this way.

Falko



More information about the wpkg-users mailing list