Although this is technically a blog, it's primary content is a series of articles on how to get Firefox working in a corporate Windows environment. Later ones build on earlier ones, so you might want to use the Table of Contents on the right to read through it chronologically instead of reading straight down from here.

AutoConfiguring XMarks for the Logged In User (v4.0)

(These are the instructions for Firefox 4 and XMarks 3.9.10.  If you want the newest instructions, go here.)

It's been a couple of months since Firefox 4 was released, so we need to get with the times and roll it out.  The only problem is we were previously depending on XMarks BYOS to do the bookmarks sync.  That wasn't designed for Firefox 4 and it doesn't look like it's going to be updated, so as part of the upgrade we need to switch to XMarks proper.

What about Firefox Sync?  That's something to look into in the future, but since I'm already set up for XMarks BYOS switching to XMarks proper offers the path of least resistance.  Also, since XMarks is an extension we can edit the JavaScript source pretty easily and push out our custom version independently of Firefox.  If Firefox Sync is compiled into the binary we would have to do a custom build of Firefox itself and redo it with each release.  Much too much effort, XMarks it is.


Set up a WebDAV Server

If you've already done this for Firefox 3.6 and XMarks BYOS, you can skip this section.  If you're just joining us, read on.

You need a server for XMarks to sync to, and it supports both WebDAV and FTP.  They recommend WebDAV so that's what we're using.

I have a Windows Server 2003 machine I can add it to, so the rest of the instructions in this section are for IIS 6.  You can use Apache or whatever else you want but you're on your own.  This page might help though.

Add IIS and WebDAV to the server if they're not already installed.  Go to Control Panel > Add or Remove Programs > Add/Remove Windows Components > Application Server > Internet Information Services (IIS) > World Wide Web Service and check off Word Wide Web Service and WebDAV Publishing.

Now go to Administrative Tools > Internet Information Services (IIS) Manager, find your web site (Default Web Site or one you created if you already had it installed) and go into its Properties.

I personally changed the TCP port to 8082 and made a DNS alias "FirefoxBookmarks" to the server so I can move it around if need be, but that's not required.

Go to the Home Directory tab and make sure Read and Write are checked off.  You also want to go to the folder it shows under Local Path and make sure Everyone has read and write NTFS permissions on them (right click the folder in Explorer > Properties > Security.)

Go to the HTTP Headers tab and click MIME Types.  Add .json as text/css.

You should be all set on this part.  Make sure syncing works with a manually installed and configured copy of XMarks before continuing.


Pushing Out the Configuration

Hey, remember the script from this post?  Yeah, go get that.  Change the webDAVURL variable to point to the server you just set up.  You can run it manually on your own computer until you're sure it's working correctly, but when you roll this out you want it to be a login script in Active Directory.

These are the settings it creates for you in user.js:
  • extensions.xmarks.syncOnShutdown = 1
  • extensions.xmarks.syncOnShutdownAsk = false
    Remember how I like things to Just Work™?  Well part of that is not risking the server's copy going out of date so they're wondering where their new bookmarks are, so I force the shutdown sync.  It only takes a second or two, and this way they don't have an unnecessary popup asking them about it either.
  • extensions.xmarks.useOwnServer = true
  • extensions.xmarks.url-bookmarks = "[webDAVURL]/[username]-bookmarks.json"
    This is where their bookmarks are going to be saved.
  • extensions.xmarks.url-passwords = "[webDAVURL]/[username]-passwords.json"
    This is where their passwords will be saved if they set it up.  I didn't bother trying to make it happen automatically.
  • extensions.xmarks.username = "[username]"
    Don't know if it's strictly necessary, but we want XMarks to think it's fully configured so it doesn't open the setup window.
We still have the little problem of the password.  It isn't stored in user.js so we can't push it out that way.  It isn't required by WebDAV so we don't even need it, but XMarks thinks it does and will pop up the setup window without it.  Grr.

So it's time to hack XMarks.


Editing XMarks

Go get the XMarks XPI and unpack it as described in this article.  We have a few edits to make before packing it back up into a MSI.  These edits are all based on XMarks 3.9.10 so let me know if they stop working on newer versions and I need to update these instructions.

Open modules\settings.jsm.  The JavaScript in minified so all our instructions are going to rely on search and replace.  Search for "get passwordNoPrompt(){".  Immediately after the brace add:

return "ignore";

This makes XMarks think it always has a password.  However, this still isn't enough to make it not pop up that "almost done" notification so we have to take that out too.  Open chrome\content\foxmarks-overlay.js, search for "NewUserPopup", and delete this whole section:

a.NewUserPopup(b.decode(d));

Now it's configured and quiet, but XMarks doesn't sync as soon as it starts up.  We want it to do that so that when someone signs in to a new computer, their bookmarks are there immediately.  While still in chrome\content\foxmarks-overlay.js, search for "},2E3" and right before that brace add:

;Xmarks.fms.synchronize();

Don't forget that leading semicolon and be mindful of capitalization.  It's Xmarks here, not XMarks.

We're almost done, but XMarks annoyingly wants to open a tab of release notes every time it's updated.  We don't want to bug our users with this.  We can make it think it's already happened by setting "extensions.xmarks.lastUpdateVersion" in user.js, but unfortunately it can't be faked out with "99.99" like IE Tab Plus, it has to be an exact match.  We don't want to have to change this setting with every release of XMarks, and since we're editing it anyway it's easier to just disable the code.  Open modules\service.jsm, search for "firefox/upgrade", and delete everything from "Xmarks.OpenInNewTab" before it to "FoxmarksBuildPostData(b));" after it.

That's all our changes.  You can now package and push out your edited copy of XMarks as an MSI using the rest of the instructions here.  When making a new package in Active Directory, make sure you select the Advanced deployment method and set it to upgrade your previous XMarks BYOS package on the Upgrade tab.  That will cause the old version to be uninstalled before installing this one.

Hey, couldn't I have just done all this for you and let you download the pre-hacked MSI?  No.  XMarks isn't open source, so I can't redistribute it.  I can just give you instructions on how to do it yourself.