Rewrite main.js with ExtensionUtils and new Preferences API.