Az oldal korlátolt funkcionalitással fog rendelkezni, amíg elvégezzük a felhasználói élményt javító karbantartást. Ha egy leírás nem oldja meg a problémáját, és kérdést tenne fel, akkor a támogatási közösségünk a @FirefoxSupport Twitter oldalon tud segíteni, vagy az /r/firefox oldalon a Redditen.

Támogatás keresése

Kerülje el a támogatási csalásokat. Sosem kérjük arra, hogy hívjon fel egy telefonszámot vagy osszon meg személyes információkat. Jelentse a gyanús tevékenységeket a „Visszaélés bejelentése” lehetőséggel.

További tudnivalók

A témacsoportot lezárták és archiválták. Tegyen fel új kérdést, ha segítségre van szüksége.

how to copy userchrome.css to installer

  • 4 válasz
  • 1 embernek van ilyen problémája
  • 1 megtekintés
  • Utolsó üzenet ettől: cor-el

more options

Copying userchrome.css to all profiles during installation of Firefox.

I want to copy "chrome/userchrome.css" automatically when a profile gets created.

Copying userchrome.css to all profiles during installation of Firefox. I want to copy "chrome/userchrome.css" automatically when a profile gets created.

Kiválasztott megoldás

You did only place the first part in autoconfig.js in the "defaults\pref" directory where the channel-prefs.js file is located and not the remainder code as well ?

// IMPORTANT: Start your code on the 2nd line
pref("general.config.filename", "autoconfig.cfg"); // filename needs to match name of autoconfig file 
pref("general.config.obscure_value", 0);
pref("general.config.sandbox_enabled", false); // disable sandbox

The remainder code that starts with the const line needs to be in autoconfig.cfg at the main level in the Firefox program folder where you also have the firefox.exe file.

const {classes: Cc, interfaces: Ci, utils: Cu } = Components;

Content of autoconfig.cfg: I've added some extra lines, so you can check this in the Browser Console that you can remove or comment out.

// autoconfig.cfg starts with a blank line
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.reportError("TESTING autoconfig.cfg");

let Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
Cu.import("resource://gre/modules/FileUtils.jsm");
 
var profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
var chromeDir = profileDir.clone();
chromeDir.append("chrome");

// If chrome folder isn't there, it's a new profile
if (!chromeDir.exists()) {
  Cu.reportError("chrome folder not found");
  var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile);
  defaultProfileDir.append("defaults");
  defaultProfileDir.append("profile");
  try {
    Cu.reportError("copying profile folder");
    copyDir(defaultProfileDir, profileDir);
  } catch (e) {
    Cu.reportError(e);
  }
}
  
function copyDir(aOriginal, aDestination) {
  var enumerator = aOriginal.directoryEntries;
  while (enumerator.hasMoreElements()) {
    var file = enumerator.getNext().QueryInterface(Ci.nsIFile);
    if (file.isDirectory()) {
      var subdir = aDestination.clone();
      subdir.append(file.leafName);
      try {
        subdir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
        copyDir(file, subdir);
      } catch (e) {
        Cu.reportError(e);
      }
    } else {
      try {
        file.copyTo(aDestination, null);
      } catch (e) {
        Cu.reportError(e);
      }
    }
  }
}

/* [CHROME:userChrome.css - userContent.css][bug 1541233][69] */
defaultPref("toolkit.legacyUserProfileCustomizations.stylesheets", true);

Válasz olvasása eredeti szövegkörnyezetben 👍 1

Összes válasz (4)

more options
more options

I updated the below code in autoconfig.js but userchrome.css is not getting copied to the current profile. Can you please let me know, what is wrong with this code.

// IMPORTANT: Start your code on the 2nd line pref("general.config.filename", "firefox.cfg"); pref("general.config.obscure_value", 0); pref("general.config.sandbox_enabled", false);

const {classes: Cc, interfaces: Ci, utils: Cu } = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); // var profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile); // var certDBFile = profileDir.clone(); // certDBFile.append("cert9.db")

// Copy userchrome.css to a new profile

var defaultProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile); defaultProfileDir.append("defaults"); defaultProfileDir.append("profile"); defaultProfileDir.append("chrome"); defaultProfileDir.append("userChrome.css");

copyDir(defaultProfileDir, profileDir);


function copyDir(aOriginal, aDestination) {

  var enumerator = aOriginal.directoryEntries;
  while (enumerator.hasMoreElements()) {
      var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile);
      if (file.isDirectory()) {
          var subdir = aDestination.clone();
          subdir.append(file.leafName);
          try {
              subdir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
              copyDir(file, subdir);
          } catch (e) {
              Components.utils.reportError(e);
          }
      } else {
          try {
              file.copyTo(aDestination, null);
          } catch (e) {
              Components.utils.reportError(e);
          }
      }
  }

}

more options

Kiválasztott megoldás

You did only place the first part in autoconfig.js in the "defaults\pref" directory where the channel-prefs.js file is located and not the remainder code as well ?

// IMPORTANT: Start your code on the 2nd line
pref("general.config.filename", "autoconfig.cfg"); // filename needs to match name of autoconfig file 
pref("general.config.obscure_value", 0);
pref("general.config.sandbox_enabled", false); // disable sandbox

The remainder code that starts with the const line needs to be in autoconfig.cfg at the main level in the Firefox program folder where you also have the firefox.exe file.

const {classes: Cc, interfaces: Ci, utils: Cu } = Components;

Content of autoconfig.cfg: I've added some extra lines, so you can check this in the Browser Console that you can remove or comment out.

// autoconfig.cfg starts with a blank line
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.reportError("TESTING autoconfig.cfg");

let Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
Cu.import("resource://gre/modules/FileUtils.jsm");
 
var profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
var chromeDir = profileDir.clone();
chromeDir.append("chrome");

// If chrome folder isn't there, it's a new profile
if (!chromeDir.exists()) {
  Cu.reportError("chrome folder not found");
  var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile);
  defaultProfileDir.append("defaults");
  defaultProfileDir.append("profile");
  try {
    Cu.reportError("copying profile folder");
    copyDir(defaultProfileDir, profileDir);
  } catch (e) {
    Cu.reportError(e);
  }
}
  
function copyDir(aOriginal, aDestination) {
  var enumerator = aOriginal.directoryEntries;
  while (enumerator.hasMoreElements()) {
    var file = enumerator.getNext().QueryInterface(Ci.nsIFile);
    if (file.isDirectory()) {
      var subdir = aDestination.clone();
      subdir.append(file.leafName);
      try {
        subdir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
        copyDir(file, subdir);
      } catch (e) {
        Cu.reportError(e);
      }
    } else {
      try {
        file.copyTo(aDestination, null);
      } catch (e) {
        Cu.reportError(e);
      }
    }
  }
}

/* [CHROME:userChrome.css - userContent.css][bug 1541233][69] */
defaultPref("toolkit.legacyUserProfileCustomizations.stylesheets", true);

Módosította: cor-el,

more options

The chrome folder with userChrome.css you want to copy needs to be in the defaults/profile folder in the Firefox installation folder (GreD).

  • <GreD>\defaults\profile\chrome\userChrome.css

All the files and folders in "\defaults\profile" will be copied to the current profile if the chrome folder isn't found.