Michael Kaply: Default Profile Directory Doesn’t Work in Firefox 46 |
It was recently discovered that support for using the defaults/profile directory to prepopulate a Firefox profile was removed in Firefox 46.
Here’s an AutoConfig file that adds back the functionality:
// const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); if (!Services.prefs.prefHasUserValue("browser.startup.homepage_override.mstone")) { // New profile var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile); defaultProfileDir.append("defaults"); defaultProfileDir.append("profile"); if (defaultProfileDir.exists()) { var profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile); try { copyDir(defaultProfileDir, profileDir); } catch (e) { Components.utils.reportError(e); } } } 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); } } } }
This should work for most file types, although it probably won’t work for bookmarks.html
I’ll also be adding this functionality to the next version of the CCK2 which will be released later today.
https://mike.kaply.com/2016/05/24/default-profile-directory-doesnt-work-in-firefox-46/
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |