var EXPORTED_SYMBOLS = [];

(({Preferences, Services}, {classes: Cc, interfaces: Ci, utils: Cu}) => {
    if (parseInt(Services.appinfo.version) < 58) return;

    var urls = new Set(), file = Services.dirsvc.get("ProfD", Ci.nsIFile);

    var skip = addon =>
        addon.type != "extension" || addon.bootstrap
        || ("location" in addon && addon.location != "app-profile")
        || addon.userDisabled || addon.appDisabled || addon.softDisabled;

    var files = (dir, callback) => {
        if (!dir.exists() || !dir.isDirectory()) return;
        var en = dir.directoryEntries;
        while(en.hasMoreElements()) {
            var file = en.getNext().QueryInterface(Ci.nsIFile);
            if (file.isFile()) callback(file);
        }
    }
    var fromZip = file => {
        var zr = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance(Ci.nsIZipReader);
        try {
            zr.open(file);
            var prfx = "jar:" + Services.io.newFileURI(file).spec + "!/";
            var en = zr.findEntries("defaults/preferences/*.js$");
            while(en.hasMore()) urls.add(prfx + en.getNext());
        }
        finally {zr.close();}
    }
    var fromDir = dir => {
        ["defaults", "preferences"].forEach(dir.append);
        if (dir.exists() && dir.isDirectory()) files(dir, file =>
            file.leafName.endsWith(".js") && urls.add(Services.io.newFileURI(file).spec)
        );
    }

    var staged = file.clone(), stagedIds = new Set();
    ["extensions", "staged"].forEach(staged.append);
    if (staged.exists() && staged.isDirectory()) files(staged, file => {
        if (!file.leafName.endsWith(".json")) return;
        var addon = JSON.parse(Cu.readFile(file));
        if (skip(addon)) return;

        stagedIds.add(addon.id);
        file.initWithPath(file.path.replace(/\.json$/, ".xpi"));
        if (file.exists() && file.isFile()) fromZip(file);
        else {
            file.initWithPath(file.path.slice(0, -4));
            if (file.exists() && file.isDirectory()) fromDir(file);
        }
    });

    file.append("extensions.json");
    if (file.exists() && file.isFile()) {
        var {addons} = JSON.parse(Cu.readFile(file));
        addons.forEach(addon => {
            if (skip(addon) || stagedIds.has(addon.id)) return;
            file.initWithPath(addon.path);
            if (!file.exists()) return;

            if (file.isFile()) fromZip(file);
            else if (file.isDirectory()) fromDir(file);
        });
    }
    if (!urls.size) return;

    var prefs = new Preferences({defaultBranch: true});
    var obj = {
        pref: function(key, val) {
            if (!/^chrome:\/\/.+\.properties$/.test(val))
                return prefs.set(key, val);
            var pls = Cc["@mozilla.org/pref-localizedstring;1"]
                .createInstance(Ci.nsIPrefLocalizedString);
            pls.data = val;
            prefs._prefBranch.setComplexValue(key, Ci.nsIPrefLocalizedString, pls);
        }
    };
    urls.forEach(url => {try {
        Services.scriptloader.loadSubScript(url, obj);
    } catch(e) {}});

})(Components.utils.import("resource://gre/modules/Preferences.jsm", {}), Components)

@@ -21,16 +21,90 @@
  = %5B%5D;%0A%0A
+// http://forum.mozilla-russia.org/viewtopic.php?pid=746461#p746461%0A%0Atry %7B
 ((%7BPrefe
@@ -165,24 +165,24 @@
 : Cu%7D) =%3E %7B%0A
-
     if (pars
@@ -1484,16 +1484,83 @@
 );%0A    %7D
+%0A    var readFile = %22readFile%22 in Cu ? %22readFile%22 : %22readUTF8File%22;
 %0A%0A    va
@@ -1816,33 +1816,33 @@
 SON.parse(Cu
-.
+%5B
 readFile
 (file));%0A   
@@ -1821,32 +1821,33 @@
 arse(Cu%5BreadFile
+%5D
 (file));%0A       
@@ -2305,17 +2305,17 @@
 e(Cu
-.
+%5B
 readFile
 (fil
@@ -2310,16 +2310,17 @@
 readFile
+%5D
 (file));
@@ -3221,16 +3221,16 @@
  %7B%7D%7D);%0A%0A
-
 %7D)(Compo
@@ -3306,9 +3306,24 @@
 ponents)
+;%7D catch(ex) %7B%7D
 %0A

Update defaultExtPrefs.jsm