Fix autofocus

Autofocus was broken by some Firefox update, possibly version 29. This
commit fixes it again. It also fixes a bug where autofocus was prevented
even on blacklisted sites, and cleans the code a bit.

@akhodakivskiy, could you please take a look at this as soon as possible? I’m afraid that I messed something up. But it seems to work nicely. When this is merged I want to make a new release, so we finally get a version that fixes the most important Firefox 29 related bugs.