Skip to content

Options

Theemim edited this page Aug 13, 2017 · 13 revisions

The names, arrangement, and commenting of the options section will help you to understand what each setting does. Here are examples of how to accomplish some tasks.

1. Export only those prefs which are userset (not at their default values).

Set options.prefilter.status as shown below and perform your export. This type of export can be compared to prefs.js.

status: {
  incUserset:        true,            // Include prefs with status userset?
  incDefault:        false,           // Include prefs with status default?
  incLocked:         false,           // Include prefs with status locked?
},

2. Export the names of the preferences used by an application.

Set options.txtCsv as shown below and perform a txt or csv export.

txtCsv: {
    outputPrefName:      true,            // Output pref name field?
    outputPrefStatus:    false,           // Output pref status field?
    outputPrefType:      false,           // Output pref type field?
    outputPrefValue:     false,           // Output pref value field?
    outputPrefDefValue:  false,           // Output pref default value field?
    outputHeader:        false,           // Output header with field descriptions?
  },

3. Export prefs with names that match the RegExp /telemetry|reporting/i.

Set options.filter as shown below and perform your export.

filter: {
  include:            /telemetry|reporting/i,  // Include if matched
  exclude:            undefined,               // Exclude if matched (priority)
  reMatchPrefName:    true,                    // Apply RegExps to pref name
  reMatchPrefValue:   false,                   // Apply RegExps to pref value
  debug:              false,                   // In case of trouble with filtering
},

4. Export prefs with values that look like HTTP or HTTPS URLs.

Set options.filter as shown below and perform your export.

filter: {
  include:             /^https?:\/\/.+/i,    // Include if matched
  exclude:             undefined,            // Exclude if matched (priority)
  reMatchPrefName:     false,                // Apply RegExps to pref name
  reMatchPrefValue:    true,                 // Apply RegExps to pref value
  debug:               false,                // In case of trouble with filtering
},

5. Export prefs in function call format so that you can compare them to those in a source file. For example, diffing against someone's user.js or comparing simulated function call results via a tool like firefox-prefjs-surveyer.

Set options.exportFormat to "js", adjust options.js if necessary, and perform your export. Then compare your results.

6. Export prefs with names or values that match /privacy/i but don't include prefs with names that are on a list.

First create an array of the pref names you want to exclude and add that to the GeckoPrefsExporter source:

var excArray = [
  "privacy.clearOnShutdown.cache",
  "privacy.clearOnShutdown.cookies",
  "privacy.clearOnShutdown.downloads",
  "privacy.clearOnShutdown.formdata",
];

Then set options.filter as shown below and perform your export.

filter: {
  include:             /privacy/i,         // Include if matched
  exclude:             excArray,           // Exclude if matched (priority)
  reMatchPrefName:     true,               // Apply RegExps to pref name
  reMatchPrefValue:    true,               // Apply RegExps to pref value
  debug:               false,              // In case of trouble with filtering
},

7. Export prefs that are on your reference list but that have a different value.

First create an array of arrays containing the name:value pairs you want, and a function to perform the inclusion check, and add it to the source of GeckoPrefsExporter:

var refPrefs = [
  ["privacy.clearOnShutdown.cache", true],
  ["privacy.clearOnShutdown.cookies", true],
  ["privacy.clearOnShutdown.downloads", true],
  ["privacy.clearOnShutdown.formdata", true],
];

function incFunc(pref) {
  var index = refPrefs.findIndex(function(refPref) {
    return((pref.name === refPref[0]) && (pref.value !== refPref[1]));
  });
  return(index >= 0);
}

Then set the filter properties as shown below and perform your export.

filter: {
  include:             incFunc,            // Must match to be included.
  exclude:             undefined,          // If matches will be excluded (priority)
  reMatchPrefName:     true,               // Apply RegExps to pref name
  reMatchPrefValue:    true,               // Apply RegExps to pref value
  debug:               false,              // In case of trouble with filtering
},