Don't Unpack and Repack omni.ja[r]

If any step in your process to customize and deploy Firefox involves unpacking and repacking omni.ja[r], you're probably doing it wrong. Any modifications you need to make to Firefox, whether it be changing the default profiles, changing the default preferences or even overriding specific files can be done WITHOUT repackaging omni.ja[r].

If you really think you have a use case for unpacking the omni.ja[r], let me know and I'll try to prove you wrong.

Now you know...

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

122 thoughts on “Don't Unpack and Repack omni.ja[r]

  1. Well, generally I unpack omni.ja to change en-US locale to other locales... (3rd build, I don't want to build the same edition for different languages)

  2. As of FF 21:

    We unpack omni.ja to be able to disable the firstrun import browser settings wizzard by editing migration.js:

    if (this._autoMigrate) {
    //var nothing = document.getElementById("nothing");
    //nothing.hidden = false;
    document.documentElement.cancel();
    return;
    }

    which is critical for us.

    We also unpack the another omni.ja to be able to edit greprefs.js to define a config file which we ship with our FF:

    pref('general.config.obscure_value', 0);
    pref('general.config.filename', 'firefox-blah.cfg');

    in which we instruct FF to get its config from an URL:

    //
    lockPref("autoadmin.global_config_url","http://wpad/firefox-blah.js");
    lockPref("autoadmin.append_emailaddr",false);

    so we are flexible and don't have to reinstall FF every time when we change a single configuration/lockPref value.

    If this would be possible with CCK we'd be happy to use it instead of fiddling around with the omni files.

    • You can disable the migration wizard by creating a file called override.ini and placing in in the EXE directory (browser directory after Firefox 21). It's contents are

      [XRE]
      EnableProfileMigrator=0

      There's no need to put the prefs file inside of omni.ja[r]. If you put that same file into the defaults/prefs directory, it will work just as if it was in omni.ja.

  3. What about enabling group policy management controlled access to various browser features? I have done it in the past to allow group policy to set preference values, and to add preference-controlled security around things like about:config, lightweighttheme installations, etc..

    • You would have to be more specific.

      There aren't many things that need to be packaged in omni.jar. They can usually be done via an extension.

  4. Hello,

    until firefox-20.1 I used to extract and modify the greprefs.js file with fastjar (working on Debian/Linux) to lock a few user preferences and then repack the omni.ja file with the modified greprefs.js. Now, with version 21, I can't extract the greprefs.js file, command "fastjar -f omni.ja -x greprefs.js" outputs "Ick! 0x124d1c" and I can't lock user preferences anymore. Where do you put the modified preferences file? In Firefox's installation directory or in users' directories? And what should be the file name? prefs.js? I've tried to replace the original unmodified prefs.js in users directories with my modified version but it doesn't work.

    Thanks in advance for your help.

  5. Hi again,

    found how to get it working with the prefs.js file and the firefox.cfg one.

    Sorry for bothering and thanks a lot for the explanations!

  6. I need to do the following customization:

    1. Change the icon on Windows taskbar

    2. Update chrome\toolkit\content\global\netError.xhtml to use a custom message

    3. Update components\nsUpdateService.js

    Is it possible without having to unpack and repack omni.ja? I'm using Firefox 21. Thanks.

  7. Hi Mike

    Today i found your blog and i have one question: for my windows live cd (bartpe) i need to change a lot in several files, as example defaults\preferences\firefox.js in omni.ja. How can i setup this without unpack/pack omni.ja? In this file i need 14 changes/additions.

    I had other questions but some of them are now solved. ;-) Why override.ini no longer work in EXE folder as example.

  8. I want to change the context menu order (open in new tab vs. open in new window).

    I did this by changing the brwoser.xul in \chrome\browser\content\browser inside the omni.ja until now.

    I know there are extensions to do this, but I don't want to use them.

    Is there a possibility to do it without modifying the omni.ja?

    • Why would you not want to use an extension? Create a simple extension and placing it into the distribution directory is exactly how you would solve this problem.

  9. Hi Mike,

    I made all of my customization through creating a policies.js and override.ini files; 26 config options added to my mozilla.cdg file. Everything works great, but I need to restrict access to (file:\\) and about:config for my users. In the past this was accomplished by extracting Omni and modifying a .js file. The .js file that was used in the past does not exist in version 21 of FF. Do you know how I can restrict access to the config page and local hard drive access through the browser. The deployment is for terminal services.

    Thanks for any inforamtion you can provide.
    Dave B

    • I would recommend the CCK Wizard for blocking access to about:config.

      I also have an extension for blocking local file access.

      Both of these changes would be accomplished by putting extensions into the distribution directory. Please contact me at consulting@kaply.com and I will send you the extension.

  10. Hi Mike,

    util FF20 we un- and re-packed omni.jar to change the permissions of saved Bookmarks (json and html) from 0600 to 0644 (e.g. we patch the doExportToFile-Function in "BookmarkHTMLUtils.jsm" for HTML export and the PO_backupBookmarks in places.js for export to json).

    Since last week i'm trying to figure out the best way to achieve this behavior without modifying omni.ja for FF21.

    First I tried to use "override" in a chrome.manifest, but as far i can see BookmarkHTMLUtils.jsm is only accessible by a "resource://"-URI which is not supported by "override"!?

    Do you have any hints how to modify files like BookmarkHTMLUtils.jsm and places.js either directly in the firefox-dir or by a FF addon?

    Thanks in advance for your help.

    • I'm curious as to why you need to change the permissons? Have you tried simply modifying the permissions using autoconfig or something like that?

  11. Please prove me wrong, because I'd honestly love an easier solution. I'm looking at unpacking/repacking omni.ja so I can edit nsBrowserGlue to get rid of the warning dialog whenever I load it in safe mode. I know you're running in safe mode, Firefox — if I didn't want it that way, I'd execute without the safe mode command line switch.

    Check http://stackoverflow.com/questions/10707687/firefox-browser-disable-safe-mode/10708086#10708086 for more detail.

  12. I have the latest version of firefox and despite an entire day searching and attempting to "lock" access to addons and extensions within the browser menu, I'm having no luck. Ive tried the methods listed here: http://serverfault.com/questions/115774/is-there-a-way-for-administrators-to-disable-users-from-installing-firefox-exten and here: http://ilias.ca/blog/2005/03/locking-mozilla-firefox-settings/. I think the location of the files I need to change or edit has been altered with more recent versions of the program than that used in the examples above.

    The reason I want to do block or remove access to the addons and extensions is to prevent the adult-filter I have installed from being simply disabled or removed.

    I'd really appreciate it if someone could explain in layman's terms how to do this - the more explicit and clear the instructions the better as this is completely new to me (I guess that much is obvious).

  13. How about disabling the autocomplete="off" nonsense that prevents the Password Manager in the browser from storing passwords?

    Basically, what I want is to be able to store the passwords regardless of what the HTML says. I have tried all extensions that advertise doing that, none of them work in all cases. The only true reliable way is to find all places in .js files in omni.jar that check the autocomplete tag in HMTL and comment them out.

    The real killer is the websites that do not actually use autocomplete="off" trick. Instead, they allow you to store the password but they generate a random site name every time. This way you end up storing a new password each time you visit their site. The only way to solve that is to stick "if site=blah { site=foo; } in a very precise place in omni.ja.

    Having said that, there really ought to be a checkbox somewhere in the browser to force it to ignore these HMTL tags.

  14. I really hate all these idiotic SeaMonkey throbbers and logos. That is why I usually replace them in omni.ja with the Netscape's logo and icons. How I can replace icons and all this crap without repacking omni.ja since ver. 2.19?

  15. I repack omni.ja mainly to remove "hyphenation\*" "jsloader" "chrome\pdfjs" and maybe "modules\commonjs\sdk" to rebuild a personal version of firefox. Right now, optimizejars.py is not working very well anymore. I would like to know how the omni.ja is being built now.

  16. Hi,

    I use Seamonkey and unpack/pack omni.ja in order to edit chrome/toolkit/content/global/platformHTMLBindings.xml to get custom key bindings for cmd_scroll*

    Can you also prove me wrong that I don't neet omni.ja? :)

    Thank you!
    James

      • Hi,

        Thanks for your answer!

        I add the following for the browser (after ):

        in order to get vi-keybindings for moving within the browser windows.

        Kind regards,
        James

        • I add the following for the browser after

          <binding id="browser">
          <handlers>
          
                <handler event="keypress" key="h" command="cmd_scrollLeft"/>
                <handler event="keypress" key="j" command="cmd_scrollLineDown"/>
                <handler event="keypress" key="k" command="cmd_scrollLineUp"/>
                <handler event="keypress" key="l" command="cmd_scrollRight"/>

          (imagine the brackets...)

          in order to get vi-keybindings for moving within the browser windows.

  17. I need to unpackage the .ja file, but you say to tell you and you will prove that I have no need to. If there is no need to then is there a ways of getting the contents WITHOUT unpackaging it?
    There are things that I want to alter, but not in the .ja file itself. Because it's for use as another purpose. What is there that I can use to unpackage it?

    • To unpackage it, you just unzip it. Many files in the there can be overridden or overlaid. It's just a question of what you want to do.

  18. Users can put a userContent.css file in their profile to override CSS files present in omni.ja
    Is there a mechanism, similar to defaults/pref(erences), where installers can put
    CSS files in the program directory to override styles for all users of that system, without
    unpacking the omni.ja and without putting a userContent.css in all the user's profiles?
    It would seem natural that the program reads all .css files present in some directory,
    e.g. the chrome subdirectory of the program directory, similar to what it does to .js
    files in defaults/pref(erences). But it appears it doesn't.

  19. Hi Mike,

    First of all thank you for all the invaluable information on your website!

    Inspite of several hours of banging my head against the wall, i have still not solved one of the reasons i need to unpack and pack omni.ja.

    pdf.js uses a file call viewer.html that i want customize. I´ve tried in several ways to override it throug an extension, but firefox just wont cooperate with me.

    I belive that this is because pdf.js is a resource:// and not a chrome://

    Looking forward to being proven wrong.

    • You should be able to override it in chrome.manifest:

      override resource://pdf.js/web/viewer.htm PATH TO YOUR VERSION OF viewer.html

      Does that not work?

      • Mike,
        I tried your suggestion and it doesn't work. In chrome.manifest of my extension, I have this line:
        override resource://pdf.js/web/viewer.html myfiles/viewer.html
        where myfiles is a folder where I overrides all firefox files.

        Can you please try it out? Let's say we remove one of the buttons.

        Thanks.

        • Sadly I was wrong. You can't override resources URLs. Quite frustrating.

          I've looked through the PDF HTML and unfortunately there isn't even a unique CSS attribute that could be used to modify the page.

          I've opened a bug and hopefully they will add a custom attribute in so that the page can be customized.

          Sorry.

  20. Working on an unrelated problem to Hanif's, as far as I can tell, override does not seem to work for any resource:// URIs. I can view the resource:// URI and the intended replacement file:// URI, but Firefox will not override it. Firefox will however override chrome:// URIs, if there is such an URI to the resource you wish to replace and if you can find that URI.

    Please note that Marian J had noticed the same, with regards to resource:// URIs. That makes at least three persons on this blog post, including myself, reporting problems with resource:// URIs. A user Wladimir Palant at the Stack Overflow has also said that you can only override chrome:// URIs.

    In my particular case, I wish to override "Mozilla Firefox/browser/omni.ja!/components/nsBrowserContentHandler.js" aka "resource://app/components/nsBrowserContentHandler.js" to restore a pre-FF20 behaviour, but Firefox has ignored my overrides. A solution to my problem would be most appreciated.

    Especially since Firefox 23's /browser/omni.ja can no longer be unpacked (unzipped) correctly, even with Windows Explorer's built-in ZIP handler, which was the last commonly known ZIP handler able to unpack /browser/omni.ja. 7-zip 9.30, PeaZIP 5.01, ExtractNow, and even the JDK 7u25's jar.exe cannot unzip Firefox 23's /browser/omni.ja. If there are any ZIP handlers still able to unpack FF23's /browser/omni.ja, I would also appreciate learning of their names as a workaround until a better solution can be found. The other /omni.ja can still be unpacked by Windows Explorer's built-in ZIP handler.

    • So it looks like in your situation you would have to write a new component to override nsBrowserContentHandler. What was the pref FF20 behavior?

          • Like @Hanif Bali, I'd like to replace the whole thing. But a more basic need would be to remove the print and full screen buttons. It would be nice if this could be done with a simple overlay, but it can't. It might be accomplished by setting up a stream listener and injecting css when the content type is application/pdf, but I stopped short of trying that because it seems a little ridiculous that this would be the way to customize the viewer.

  21. Hi Mike
    We have a multilang xulrunner app and since xulrunner releases are delivered en-US only we used to combine the relevant parts of the specific firefox omni.ja (de, fr and it) into xulrunner's omni.ja. For this we need to unpack xulrunner's omni.ja, and add the other languages in and repack again. How can this be done w/o unpacking and repacking omni.ja?

  22. In former versions it was able to install FF on a server share and to create a file defaults/profile/cert_override.txt which contains all the self signed certificates used in the company.

    This file will be ignored completely in current version, so that each new user has to copy this file to his local profile manually. Extremely annoying.

    I don't know, if this file would be respected by firefox, if it was in the omni.ja container. But if I knew, how to pack that container again, at least I could try.

      • Is there a way to pre-populate a companies self-signed certs on the Mac version of Firefox? I'm evaluating FF24.0esr. When I capture cert8.db and move it to "/Applications/Firefox.app/Contents/MacOS/browser/defaults/profile/" I get security errors. The rest of my default profile loads fine after I remove cert8.db.

        • Self signed certificates are actually considered "overrides" so you're not really populating certificates per say.

          This features will be in the next CCK (CCK2)

  23. We currently dive into omni.ja (the one that sits in browser\) to edit the 'nsContextMenu.js' file. We alter the line with "context-setDesktopBackground" so that users cannot set a desktop background from inside the browser.

      • The common problem with all userChrome.css solutions is that there is no equivalent that operates for all users on the system.
        This is really something that should be fixed. Admins want easy solutions that they can apply to all users (at least by default) without having to resort to fixes like writing a custom extension.
        (especially because platform-specific solutions like Windows Group Policy are not supported)

        • I agree. That's why my recommendation is to write userChrome.css via autoconfig which means that it happens for all users of the browser.

          I'm working on better solutions for this.

  24. Hi from Paris/Fr - sorry for my poor english.

    I need to provide users with a simple way to re-initialize the profile. I know " firefox -safe-mode ", but users will have two choices ( rehinit or safe mode ) , that is for lot of them a showstoper ....

    So i duplicated the "global/content/AboutSupport.xhtml" in omni.ja and named it "global/content/ResetProfile.xhtml" , then i have suppressed things not in relation with the reset.

    Using "firefox -chrome url ..." ( in shortcut ) works fine , also in url ...
    I have planned to see how to add it in the menu , but missing time to learn how.

    I just read this article, and knowing that i have modified the omni.ja , i want to know if i can do better ( i am not a super developper ! ) , may be with an override somewhere ....

    thanks for your very interesting and useful web site.
    Regards, C.

    • What you're describing could happen with a very simple add-on.

      If you put that URL in an add-on, you could still have the -chrome shortcut and you could also easily add a menu item.

      • Thanks for the reply.

        I will look to do this way, may be someone have made an empty add-on nutshell ?
        That could help when you dont know the how to create an add-on.

  25. I use seamonkey (which is more compact than firefox + thunderbird separately).
    Back before omni.jar, I used to modify the mailWindowOverlay.js file in messenger.jar and repack it (deflate compressed), as well as modifying fr.jar (which comes only partly translated) and repack that (again deflate compressed), and seamonkey would load considerably quicker than with the unmodified versions. When omni.jar came along, it loaded (somewhat) slower than my modified versions before.
    (I timed it, but some of the slowness could have been due to added features between versions.)
    The reason I modified mailWindowOverlay.js is because I always turn off display of external content (images, etc) in email, in preferences, and somebody decided to put about 4 lines in the mail window every time external content was blocked, instead of the previous discrete (easily ignored) icon in the status bar. So when my bug report was rejected as WONTFIX (several times), I did a cludge which always disables displaying external content.
    So unless a preference can turn off this undesirable behavior (I've been told no), from what you said on this page, I would have to create an extension. In that case I would prefer a global extension that doesn't need to be activated for each profile. Could you give me pointers on how to do that ?
    (I would also like to do that for the modified language extension that I recreate every version. I do both of these modifications for others as well.)

    As for omni.ja, I would rather go back to the old multiple jar system, which could be sped up considerably by simply deflate compressing the *.jar files, without any reordering.
    That way I could avoid loading the partially translated language file.
    In any case, currently seamonkey pauses for about 1 minute before loading (even before I do any modification).
    Thanks in avance for any help.

  26. Hi Mike,

    I have to edit omni.ja because two capabilities are not exposed by about:config options.

    The first issue is: when dragging a link to a tab, the focus switches to that tab. That's annoying if you are trying to build a set of links in one tab for later reading.

    Solution: edit tabbrowser.xml, comment out this line in two places:

    this.selectedItem = tab;

    The second issue is the number of elements in the go back/forward buttons (history). It is set to 15 by default; that's too low. I set mine to 45 by editing browser.js like so:

    XPCOMUtils.defineLazyServiceGetter(this, "_ss",
    "@mozilla.org/browser/sessionstore;1",
    "nsISessionStore");
    PlacesMenu.call(this, aPopupShowingEvent,
    "place:sort=4&maxResults=45");

      • Similar to case1, before Seamonkey 2.19 I used to comment out several lines in mailWindowOverlay.js, to prevent a multiline banner from appearing to tell me that remote content had been blocked (as requested by configuration settings).
        This blocked all remote content in emails, invisibly to the user.
        With recent changes, it is more difficult but still possible to extract the file from omni.ja, but no longer possible to replace it with the modified file.
        What would you recommend to solve that ?
        Thanks in advance ...

  27. Hi Mike,
    I hope you can help me in this one.
    I'm changing the omni.ja from Thunderbird, I think it could work the same as Firefox.
    I want to change the position of the Thunderbird Attachment pane.
    The way I'm doing it is by editing omni.jar: the file chrome\messenger\content\messenger\messenger.xul
    and look for this line near the end

    Move that line up by 12 lines, to just below the
    msgNotificationBar.

    Do you know a way to have this file modified outside of the omni.ja?
    This really does need an extension but I don't know how to do something like that.
    For now I just edit the omni.ja every time it updates.
    Thanks in advance for your help.

  28. I have a GWT application which has a textarea. When the user types a wrong spelling, it gets underlined in red. When the user right clicks on the wrong spelling, the popup menu provides some suggestions; The user clicks on one of the suggestions but the wrong spelling does not get replaced.

    The javascript console contains the following error: [18:54:12.843] NS_ERROR_INVALID_POINTER: Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIInlineSpellChecker.replaceWord] @ resource://gre/modules/InlineSpellChecker.jsm:273

    Please let me know how to fix this problem.

  29. Quote: "You definitely can override the netError.xhtml to have a custom message via a chrome override, and the same with the icon if you are simply replacing it." Mike Kaply

    I need precise instruction in how to override chrome netError.xhtml and have a blank page put in it's place. The reason I want to do this is because I have a vast number of add generating web address in my hosts file and when I visit many websites via Firefox I'll have to view that rather ugly netError message and icon until I can replace it with a blank page.

    I tried entering the following command in console:
    override chrome://global/content/netError.xhtml data:text/html,Disabled
    And console's responded: SyntaxError: missing ; before statement
    I've no idea what "SyntaxError: missing ; before statement" means or how to correct the command or if it's even correctable and even if that command had been successful it would have only replaced the netError message with the word Disabled in it's place.

  30. Before I updated from FF17 to 24 I could pack/unpack omni.ja to very simply modify the nsloginmanager.js to a changed behavior: saved passwords can be used but the dialog to save new passwords was suppressed (for the most sites).
    You often say, that something could (possibly) done with an extension. To learn how to write extensions is much overhead for these simple modifications, isn't it? Why could the developers not use a standard packer?!
    Which (windows command line) tool can handle the damn format?
    Or how to plug in a changed nsloginmanager.js in Firefox? Thanks

  31. I was running Mozilla 7.0.1, which had all external files to make changes. I also have a closed network, no roaming profiles, and user accounts are deleted from Documents and Settings upon log off.

    I used the pref.js to set many about:config customizations
    I used bookmarks.html to hard set the same favorites for all users
    I used cert_override.txt to add for trusted connections to internal sites
    I used override.ini to set EnableProfileMigrator to False

    can you recommend a way to accomplish the above without unpacking the omin.ja?

    Thanks!
    Danny

      • So I used Winzip to unzip the omni.ja to the D: drive on a server. Under Omni>Defaults>Profile I added my bookmarks.html, cert8.db, and from a fresh FFX 17.0.11 install I configured the pref.js via about:config.

        I also created, under Program Files(x86)>Mozilla Firefox>defaults a folder named "profile" and added my bookmarks.html, cert8.db, and pref.js.

        I then zipped the folder back to omni.zip, renamed it omni.ja, and placed that under Program Files(x86)>Mozilla Firefox - when I launch firefox I get the Mozilla Crash Reporter.

        If I do not edit the omni.ja file on a fresh FFX install, but leave the Program Files(x86)>Mozilla Firefox>defaults>profile (bookmarks, cert8, and pref,js) it will launch, go to my specified homepage, but other settings (such as cert8) don't take affect

        Seems like I am corrupting the omni.ja somehow

        Any advice would be appreciated!

      • I found that I did not need any customization to the omni file - just adding those files to default/profile was enough (along with a well placed override.ini)

        Thanks!

  32. OK, so I must admit that I am also one of those omni.ja modifying guys ;-)
    Now I have stumbled over your advice and would like to do it correctly.
    I would like to change:

    intl.accept_languages
    helpers.global_mailcap_file

    Whenever I put the first one into some .js file into browser/defaults/preferences/
    like pref("intl.accept_languages", "de-DE,de,en-GB,en,es"); it gets completly
    ignored and I cannot change them any more in Content->Languages.

    And using pref("helpers.global_mime_types_file", "/usr/local/share/mime.types");
    is even worse, firefox24-esr doesn't start at all with this set.

    Everything else put into browser/defaults/preferences/ works great!

    • So the problem is that browser/default/preferences can be overridden by some Firefox preferences.

      My honest suggestion is that you put this in an AutoConfig file. That will guarantee they never get overwritten.

      You also might experiment with putting the preferences that aren't working in defaults/pref. Or even weirder, change the name of your JS file. Make it start with an a or z. sometimes file loading can affect this as well.

  33. We are launching firefox using the command line -profile option. This appears to create a new profile but doesn't apply /browser/defaults/profile settings. I was looking at modifying omin, but hoping you will have a better solution.

    • omni.ja can be a standard zip file.
      It works just as fast. The voodoo about loading in a certain order is just that, with the buffered large disks of today.

  34. Dear Mike. For a long time I unpacked onmi.jar and changed settings in all-thunderbird.js to prevent the Thunderbird from checking for updates (we have a large Windows domain deployment for students, staff and faculty). I re-package TB for Group Policy deployment. Is there a way to do this nowÉ

  35. and how do I un- and repack the omni.ja file?
    It looks like, it uses a slightly different zip-algorithm.

    And plz .. don't ask WHY I want to un- and repack it. I just wanna do it.
    Or am I mistaken and firefox/thunderbird is not any longer free software?

    • Unpacking can be a bit tricky, but repacking is straight forward.
      Just use the standard zip format.
      Ensure that it is named omni.ja, that is what counts.
      Probably because of the large caches on today's hard disks, it seems to load just as fast as the tricky format.

      As far as avoiding unpacking if possible (and easier), I think it is a good idea, but Mike has informed me that it doesn't seem to be possible for my particular use case.

  36. Hi how can we enable debug logs fr specific js files? like how to enable debug mode for WifiWorker.js?

    we are getting below error, and want see detailed log for this

    05-10 13:03:44.328 18378 18378 E GeckoConsole: [JavaScript Error: "NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsISettingsServiceCallback.handle]" {file: "jar:file:///system/b2g/omni.ja!/components/SettingsService.js" line: 119}]